Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Created August 23, 2018 13:35
Show Gist options
  • Save sergiolucero/b82664d64a06eee7d083813bc2ddea91 to your computer and use it in GitHub Desktop.
Save sergiolucero/b82664d64a06eee7d083813bc2ddea91 to your computer and use it in GitHub Desktop.
point in geometry
import geopandas
import pandas as pd
from shapely.geometry import Point
gdf = gp.read_file('http://quant.cl/static/DATA/GEO/comunas13.json')
rand = pd.np.random.randn
points=[Point((-70.7+0.1*rand(),-33.4+0.1*rand())) for _ in range(10)]
for point in points:
for cid,comuna in gdf.iterrows():
if point.within(comuna['geometry']):
print(point,comuna['NOMBRE'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment