Skip to content

Instantly share code, notes, and snippets.

@kuanb
Created July 6, 2017 00:29
Show Gist options
  • Select an option

  • Save kuanb/c85ef6c3c5ceeb000356c6967f9fb249 to your computer and use it in GitHub Desktop.

Select an option

Save kuanb/c85ef6c3c5ceeb000356c6967f9fb249 to your computer and use it in GitHub Desktop.
from copy import copy
import geopandas as gpd
from shapely.wkt import loads
geodataset_geom_count = 30000
# two generic shapes
a = loads('MULTIPOLYGON (((649141.3988551921 119588.0508027334, 649205.3394444393 119586.6252604292, 649204.4036520078 119547.1810296645, 649203.3471333382 119400.7549073702, 649137.6164607083 119401.7231623645, 649141.3988551921 119588.0508027334)))')
b = loads('MULTIPOLYGON (((638329.3738409473 104950.4713290278, 637929.373791253 104951.4454448997, 637929.3737395091 105287.3536795844, 638329.3738592704 105287.3537065834, 638329.3738409473 104950.4713290278)))')
# make a geoseries that represents a series of all unique geometries in the geodataset
gs = gpd.GeoSeries([copy(b) for i in range(geodataset_geom_count)])
# now get the distance from the first geom to all those in the GeoSeries
d = gs.distance(a)
print(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment