forked from gdobler/cussac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeoLocator.py
25 lines (19 loc) · 859 Bytes
/
geoLocator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import geopandas as gp
from shapely.geometry import Point
import matplotlib.pyplot as plt
import os
class GeoLocator:
def __init__(self):
# Creating a geo pandas data frame from the nybb.shp shape file
self.boros = gp.GeoDataFrame.from_file('nybb_14c/nybb.shp')
# setting the BoroCode to be the data frame index
self.boros.set_index('BoroCode', inplace=True)
# Converting the coordinates system to lonlat
target_crs = {'datum':'WGS84', 'no_defs':True, 'proj':'longlat'}
self.boros.to_crs(crs=target_crs, epsg=None, inplace=True)
# Return True iff the point given is in NYC
def isNYC (self, lat, long):
for index, row in self.boros.iterrows():
if row.geometry.contains(Point(long,lat)):
return True
return False