Skip to content

Instantly share code, notes, and snippets.

@ritvikmath
Created April 9, 2019 03:19
Show Gist options
  • Select an option

  • Save ritvikmath/53f7f6079403b008e5fab3e12226ee85 to your computer and use it in GitHub Desktop.

Select an option

Save ritvikmath/53f7f6079403b008e5fab3e12226ee85 to your computer and use it in GitHub Desktop.
remove starbucks locations outside la county
#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