shp
, shx
and dbf
files. GeoPandas
package can read shape files into DataFrames and matplotlib
can be used to plot them, Link. geopandas.read_file(...)
can be used to read a zip file containing shp
, shx
and dbf
files, and output a GeoDataFrame
, which a pandas
DataFrame with a column specifying the geometry of the item. GeoDataFrame.plot()
can be used to plot the polygons. GeoDataFrame.crs
checks the coordinate system used in the data frame. GeoDataFrame.to_crs("epsg:326??")
or GeoDataFrame.to_crs("epsg:326??)
can be used to convert from degree-based coordinate system to meter-based coordinate system. ??
in the European Petroleum Survey Group (EPSG) code specifies the Universal Transverse Mercator (UTM) zone: Link. cmap
or colormaps specify the colors for the hue visual encoding for a column of numerical values, and the names of the colormaps can be found here: Link. Point(x, y)
creates a point at \(\left(x, y\right)\). LineString([x1, y1], [x2, y2])
or LineString(Point(x1, y1), Point(x2, y2))
creates a line from \(\left(x_{1}, y_{1}\right)\) to \(\left(x_{2}, y_{2}\right)\). Polygon([[x1, y1], [x2, y2], ...])
or Polygon([Point(x1, y1), Point(x2, y2), ...])
creates a polygon connecting the vertices \(\left(x_{1}, y_{1}\right)\), \(\left(x_{2}, y_{2}\right)\), ... Polygon.buffer(r)
computes the geometry containing all points within a r
distance from the polygon. If Point.buffer(r)
is used, the resulting geometry is a circle with radius r
around the point, and Point.buffer(r, cap_style = 3)
is a square with "radius" r
around the point: Doc. geopandas.overlay(x, y, how = "intersection")
computes the polygons that is the intersection of polygons x
and y
: Doc, if GeoDataFrame
has geometry x
, GeoDataFrame.intersection(y)
computes the same intersection: Doc geopandas.overlay(x, y, how = "union")
computes the polygons that is the union of polygons x
and y
, Doc, if GeoDataFrame
has geometry x
, GeoDataFrame.union(y)
computes the same union: Doc GeoDataFrame.unary_union
is the single combined MultiPolygon
of all polygons in the data frame: Doc. GeoDataFrame.convex_hull
computes the convex hull (smallest convex polygon that contains the original polygon): Link, Doc geopy
provide geocoding services to convert a text address into a Point
geometry that specifies the longitude and latitude of the location: Link geopandas.tools.geocode(address)
returns a Point
object with the coordinate for the address. box(0, 0, 1, 1)
: yes, all rectangles are convex. Point(0, 0).buffer(1)
: yes, all circles (or polygon approximations of circles) are convex. Polygon([[0, 0], [1, 0], [0, 1]]
: yes, any triangle is convex. box(0, 0, 2, 2).intersect(box(1, 1, 3, 3))
: yes, the intersection here is just box(1, 1, 2, 2)
, and in general, the intersection between any two convex shapes is still convex. box(0, 0, 2, 2).union(box(1, 1, 3, 3))
: no, the line segment between (0, 2)
and (1, 3)
is not inside the shape. box(0, 0, 2, 2).union(box(1, 1, 3, 3)).convex_hull
: yes, the convex hull of any shape is convex. Point(0, 0).buffer(1).boundary
: no, the boundary is a circle without the inside (approximated by a lot of line segments), and the line segment connecting any two distinct points on the circle is not on the boundary, and in general, the boundary of any shape with strictly positive area is not convex. Last Updated: November 18, 2024 at 11:43 PM