flopy.utils.geometry module¶
Container objects for working with geometric information
-
class
Collection(geometries=())[source]¶ Bases:
listThe collection object is container for a group of flopy geometries
This class acts as a base class for MultiPoint, MultiLineString, and MultiPolygon classes. This class can also accept a mix of geometries and act as a stand alone container.
Parameters: geometries (list) – list of flopy.util.geometry objects -
bounds¶ Method to calculate the bounding box of the collection
Returns: Return type: tuple (xmin, ymin, xmax, ymax)
-
-
class
LineString(coordinates)[source]¶ Bases:
flopy.utils.geometry.Shape-
bounds¶
-
has_z= False¶
-
pyshp_parts¶
-
shapeType= 3¶
-
type= 'LineString'¶
-
x¶
-
y¶
-
z¶
-
-
class
MultiLineString(linestrings=())[source]¶ Bases:
flopy.utils.geometry.Collection- Container for housing and describing multilinestring geometries (e.g. to be
- read or written to shapefiles or other geographic data formats)
- polygons : list
- list of flopy.utils.geometry.LineString objects
-
class
MultiPoint(points=())[source]¶ Bases:
flopy.utils.geometry.Collection- Container for housing and describing multipoint geometries (e.g. to be
- read or written to shapefiles or other geographic data formats)
- polygons : list
- list of flopy.utils.geometry.Point objects
-
class
MultiPolygon(polygons=())[source]¶ Bases:
flopy.utils.geometry.Collection- Container for housing and describing multipolygon geometries (e.g. to be
- read or written to shapefiles or other geographic data formats)
- polygons : list
- list of flopy.utils.geometry.Polygon objects
-
class
Point(*coordinates)[source]¶ Bases:
flopy.utils.geometry.Shape-
bounds¶
-
has_z= False¶
-
pyshp_parts¶
-
shapeType= 1¶
-
type= 'Point'¶
-
x¶
-
y¶
-
z¶
-
-
class
Polygon(exterior, interiors=None)[source]¶ Bases:
flopy.utils.geometry.Shape-
bounds¶
-
patch¶
-
plot(ax=None, **kwargs)[source]¶ Plot the feature. :param ax: :type ax: matplotlib.pyplot axes instance :param Accepts keyword arguments to descartes.PolygonPatch. Requires the: :param descartes package (pip install descartes).:
-
pyshp_parts¶
-
shapeType= 5¶
-
type= 'Polygon'¶
-
-
class
Shape(shapetype, coordinates=None, exterior=None, interiors=None)[source]¶ Bases:
objectParent class for handling geo interfacing, do not instantiate directly
- type : str
- shapetype string
- coordinates : list or tuple
- list of tuple of point or linestring coordinates
- exterior : list or tuple
- 2d list of polygon coordinates
- interiors : list or tuple
- 2d or 3d list of polygon interiors
-
static
from_geojson(geo_interface)[source]¶ Method to load from geojson
Parameters: geo_interface (geojson, dict) – geojson compliant representation of a linestring Returns: Return type: Polygon, LineString, or Point
-
geojson¶
-
get_polygon_area(geom)[source]¶ Calculate the area of a closed polygon
Parameters: geom (geospatial representation of polygon) – accepted types:
vertices np.array([(x, y),….]) geojson.Polygon shapely.Polygon shapefile.Shape
Returns: area – area of polygon centroid Return type: float
-
get_polygon_centroid(geom)[source]¶ Calculate the centroid of a closed polygon
Parameters: geom (geospatial representation of polygon) – accepted types:
vertices np.array([(x, y),….]) geojson.Polygon shapely.Polygon shapefile.Shape
Returns: centroid – (x, y) of polygon centroid Return type: tuple
-
is_clockwise(*geom)[source]¶ Determine if a ring is defined clockwise
Parameters: *geom (geospatial representation of polygon) – accepted types:
vertices [(x, y),….] geojson.Polygon shapely.Polygon shapefile.Shape x and y vertices: [x1, x2, x3], [y1, y2, y3]
Returns: clockwise – True when the ring is defined clockwise, False otherwise Return type: bool
-
rotate(x, y, xoff, yoff, angrot_radians)[source]¶ Given x and y array-like values calculate the rotation about an arbitrary origin and then return the rotated coordinates.
-
shape(pyshp_shpobj)[source]¶ Convert a pyshp geometry object to a flopy geometry object.
Parameters: pyshp_shpobj (shapefile._Shape instance) – Returns: shape Return type: flopy.utils.geometry Polygon, Linestring, or Point Notes
Currently only regular Polygons, LineStrings and Points (pyshp types 5, 3, 1) supported.
Examples
>>> import shapefile as sf >>> from flopy.utils.geometry import shape >>> sfobj = sf.Reader('shapefile.shp') >>> flopy_geom = shape(list(sfobj.iterShapes())[0])