Last active
December 16, 2016 05:19
-
-
Save chiragtoor/03bec4f68e9f2f681db253ade9abb001 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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