0

I have a huge point dataset with almost 300.000 points and I want to intersect them with a country geometry that has a complex geometry (multiple islands and borders). What I've done so far is to construct a GeoPandas dataframe and then clip it, however the process takes almost 50 minutes whereas if I perform the same task with ArcGIS the entire process takes only 43 seconds. I've been searching for a way to improve the process without success.

gdf = gpd.GeoDataFrame(
    merged_data,
    crs='EPSG:4326',
    geometry=[Point(xy) for xy in zip(merged_data.longitude, merged_data.latitude)])
poly = country_boundary.geometry.unary_union
points_clip = gdf[gdf.geometry.intersects(poly)]
1
1

Use geopandas.clip for clipping. That is an efficient way how to do so, especially with GeoPandas 0.8.0 and pygeos.

points_clip = gpd.clip(gdf, country_boundary)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.