Created
April 9, 2019 03:19
-
-
Save ritvikmath/53f7f6079403b008e5fab3e12226ee85 to your computer and use it in GitHub Desktop.
remove starbucks locations outside la county
This file contains hidden or 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
| #open up the LA Geojson | |
| with open('laMap.json') as f: | |
| laArea = json.load(f) | |
| #convert the MultiPolygon part of the LA Geojson into a shapely Polygon object for easier inclusiveness checking | |
| laPolygon = Polygon(laArea['features'][0]['geometry']['coordinates'][0][0]) | |
| #keep store if and only if it is within the LA polygon | |
| keepLAStores = [] | |
| for store in laStores: | |
| #geojson needs (long, lat) format instead of (lat, long) | |
| #convert the (long, lat) pair into a shapely Point object | |
| point = Point(float(store[3]), float(store[2])) | |
| if laPolygon.contains(point): | |
| keepLAStores.append(store) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment