Skip to content

Instantly share code, notes, and snippets.

@chiragtoor
Last active December 16, 2016 05:19
Show Gist options
  • Save chiragtoor/03bec4f68e9f2f681db253ade9abb001 to your computer and use it in GitHub Desktop.
Save chiragtoor/03bec4f68e9f2f681db253ade9abb001 to your computer and use it in GitHub Desktop.
from shapely.geometry import Polygon, Point
def blockInZone(block, zone):
boundaryPoints = []
for pair in block:
# reverse the order because from the file
# coordinates data was read in lat, long
# and for Shapely we need to put the data
# as long, lat
boundaryPoints.append((pair[1], pair[0]))
blockPolygon = Polygon(boundaryPoints)
boundaryPoints = []
for pair in zone:
boundaryPoints.append((pair[1], pair[0]))
zonePolygon = Polygon(boundaryPoints)
return blockPolygon.intersects(zonePolygon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment