geometry module provides comprehensive spatial operations for working with geographic data, including coordinate reference system (CRS) management, distance calculations, spatial joins, geometry validation, and parcel analysis.
Coordinate Reference Systems
get_crs()
Returns the appropriate CRS for a GeoDataFrame based on the specified projection type.Input GeoDataFrame
Type of projection:
'latlon', 'equal_area', 'equal_distance', or 'conformal'Appropriate CRS for the specified projection type
get_crs_from_lat_lon()
Return a Coordinate Reference System (CRS) suitable for the requested projection type at the given latitude/longitude location.Latitude
Longitude
The desired projection type:
'latlon', 'equal_area', 'equal_distance', or 'conformal'The desired units:
'ft' or 'm'The appropriate Coordinate Reference System
Distance Calculations
distance_km()
Calculates the distance in kilometers between two latitude/longitude points.Latitude of the first point
Longitude of the first point
Latitude of the second point
Longitude of the second point
Distance in kilometers
offset_coordinate_km()
Offset a lat/long coordinate by the designated number of kilometers.Latitude
Longitude
Number of kilometers to offset latitude by
Number of kilometers to offset longitude by
The offset latitude, longitude pair (in degrees)
offset_coordinate_m()
Offset a lat/long coordinate by the designated number of meters.Latitude
Longitude
Number of meters to offset latitude by
Number of meters to offset longitude by
The offset latitude, longitude pair (in degrees)
offset_coordinate_feet()
Offset a lat/long coordinate by the designated number of feet.Latitude
Longitude
Number of feet to offset latitude by
Number of feet to offset longitude by
The offset latitude, longitude pair (in degrees)
Geometry Creation
create_geo_circle()
Creates a GeoDataFrame containing a circle centered at the specified latitude and longitude.Latitude
Longitude
Coordinate Reference System
Radius of the circle, in kilometers
Number of points used to approximate the circle
A GeoDataFrame containing the circle
create_geo_rect()
Creates a GeoDataFrame containing a rectangle centered at the specified latitude and longitude.Latitude
Longitude
Coordinate Reference System
Width in kilometers
Height in kilometers
Anchor point of the rectangle:
'center' or 'nw' (northwest)A GeoDataFrame containing the rectangle
Geometry Processing
ensure_geometries()
Parse a DataFrame whose geometry column may be in various formats (Shapely, WKT, WKB, hex-encoded WKB).Input DataFrame
Name of the geometry column
Coordinate Reference System
A brand-new GeoDataFrame with a clean geometry column
clean_geometry()
Preprocess a GeoDataFrame by diagnosing and fixing common geometry issues.The input GeoDataFrame with geometries
If True, removes non-polygon geometries
If specified, ensures the GeoDataFrame is in this CRS
A cleaned and fixed GeoDataFrame
Spatial Joins
geolocate_point_to_polygon()
Assign each point (latitude/longitude) in a DataFrame to a containing polygon ID.GeoDataFrame of polygon geometries (must include a geometry column and the parcel ID field)
Input DataFrame with at least latitude and longitude columns
Name of the column in df_in containing latitude values
Name of the column in df_in containing longitude values
Name of the parcel ID column in gdf to attach to each point
Copy of df_in with a new column containing the ID of the polygon that contains each point. Rows with no containing polygon will have NaN.
Parcel Analysis
identify_irregular_parcels()
Detect and flag irregular parcel geometries based on shape metrics.Must contain a geometry column of Polygon geometries, plus precomputed fields:
geom_rectangularity_num: numeric rectangularity measure (0-1)geom_aspect_ratio: width/height ratio of each parcel
If True, print timing and progress for each processing phase
Simplification tolerance (projection units) for reducing geometry complexity
Minimum vertex count (post-simplification) for a parcel to be considered ‘complex’
Maximum rectangularity below which a high-vertex-count geometry is flagged as irregular
Minimum bounding-box aspect ratio that qualifies a parcel as ‘elongated’
A copy of the input with these added columns:
geom_vertices: int count of vertices after simplificationis_geom_complex: bool flag for complex non-rectangular shapesis_geom_elongated: bool flag for elongated shapesis_geom_irregular: bool flag if any irregular condition is met
Parquet CRS Detection
detect_crs_from_parquet()
Return CRS and geometry column name from GeoParquet metadata.Path to the parquet file
Name of the geometry column to check
Tuple containing:
crs: pyproj.CRS or Nonegeometry_column_used: the geometry column name detected or provided