geolime.operations.polygon.geometry_calculations

Classes:

Polygon(data, metadata)

Functions:

bounding_polygon_from_points(points_df, crs)

Compute bouding concave polygon of a set of points.

bounding_polygon_from_sub_points(sub_points_gdf)

Compute bouding concave polygon of a subset of points.

df_to_gdf(df[, x_col, y_col, crs])

Converts a DataFrame to a GeoDataFrame

gdf_to_df(gdf[, copy])

Converts a DataFrame to a GeoDataFrame

select_points_inside_polygon(polygon, points)

Filters points in 2D and keep only the one inside the given polygon.

geolime.operations.polygon.geometry_calculations.bounding_polygon_from_points(points_df: pandas.core.frame.DataFrame, crs: str, alpha: float = 0.0, max_size: int = 100000)

Compute bouding concave polygon of a set of points. Degree of concavity is determined with alpha parameter. Return convex hull by default

Parameters
  • points_df (pd.DataFrame) – DataFrame containing set of points

  • crs (str) – Coordinates Reference System

  • alpha (float, optional) – Parameter of concavity degree alpha = 0. means convex hull alpha = 2. means concave hull

  • max_size (int, optional) – Custom parameter to avoid memory issue by spliting process

Returns

Polygon GeoLime object

Return type

Polygon

Notes

In order to avoid memory issue, big dataset are split into chunks of limited size.

geolime.operations.polygon.geometry_calculations.bounding_polygon_from_sub_points(sub_points_gdf: pandas.core.frame.DataFrame, alpha: float = 0.0)

Compute bouding concave polygon of a subset of points. Degree of concavity is determined with alpha parameter.

Parameters
  • sub_points_gdf (pd.DataFrame) – DataFrame containing subset of points

  • alpha (float, optional) – Parameter of concavity degree alpha = 0. means convex hull alpha = 2. means concave hull

Returns

Geopandas polygon of subset points

Return type

gpd.GeoDataFrame

geolime.operations.polygon.geometry_calculations.select_points_inside_polygon(polygon: geolime.objects.polygon.Polygon, points: pandas.core.frame.DataFrame, split_by_chunks_of: int = 1000000)

Filters points in 2D and keep only the one inside the given polygon. Using Geopandas Spatial Join in the background.

Parameters
  • polygon (Polygon) – polygon against which points are filtered

  • points (pd.DataFrame) – points to filter

  • split_by_chunks_of (int) – maximum number of points checked at the same time. useful for reducing memory footpring when datasets are big

Returns

The points that are within the polygon

Return type

pd.DataFrame