flopy.utils.geometry module¶
Container objects for working with geometric information
- class Collection(geometries=())[source]¶
Bases:
list
The 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
- property bounds¶
Method to calculate the bounding box of the collection
- Return type
tuple (xmin, ymin, xmax, ymax)
- class LineString(coordinates)[source]¶
Bases:
flopy.utils.geometry.Shape
- property bounds¶
- has_z = False¶
- property pyshp_parts¶
- shapeType = 3¶
- type = 'LineString'¶
- property x¶
- property y¶
- property 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)
- polygonslist
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)
- polygonslist
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)
- polygonslist
list of flopy.utils.geometry.Polygon objects
- class Point(*coordinates)[source]¶
Bases:
flopy.utils.geometry.Shape
- property bounds¶
- has_z = False¶
- property pyshp_parts¶
- shapeType = 1¶
- type = 'Point'¶
- property x¶
- property y¶
- property z¶
- class Polygon(exterior, interiors=None)[source]¶
Bases:
flopy.utils.geometry.Shape
- property bounds¶
- property 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).:
- property pyshp_parts¶
- shapeType = 5¶
- type = 'Polygon'¶
- class Shape(shapetype, coordinates=None, exterior=None, interiors=None)[source]¶
Bases:
object
Parent class for handling geo interfacing, do not instantiate directly
- typestr
shapetype string
- coordinateslist or tuple
list of tuple of point or linestring coordinates
- exteriorlist or tuple
2d list of polygon coordinates
- interiorslist 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
- Return type
Polygon, LineString, or Point
- property 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
- point_in_polygon(xc, yc, polygon)[source]¶
Use the ray casting algorithm to determine if a point is within a polygon. Enables very fast intersection calculations!
- Parameters
xc (np.ndarray) – 2d array of xpoints
yc (np.ndarray) – 2d array of ypoints
polygon (iterable (list)) – polygon vertices [(x0, y0),….(xn, yn)] note: polygon can be open or closed
- Returns
mask – True value means point is in polygon!
- Return type
np.array
- project_point_onto_xc_line(line, pts, d0=0, direction='x')[source]¶
Method to project points onto a cross sectional line that is defined by distance. Used for plotting MODPATH results on to a cross section!
- linelist or np.ndarray
numpy array of [(x0, y0), (x1, y1)] that defines the line to project on to
- ptslist or np.ndarray
numpy array of [(x, y),] points to be projected
d0 : distance offset along line of min(xl) direction : string
projection direction “x” or “y”
- Returns
np.ndarray of projected [(x, y),] points