Skip to content

Commit

Permalink
functions now take arbitrary path if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
crisjf committed Mar 13, 2020
1 parent bda6744 commit 43f6553
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions geofence.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import osmnx as ox
from download_shapeData import SHAPES_PATH,SHAPE_LEVELS

def check_shapes(year_version = '2019'):
def check_shapes(year_version = '2019',shapesPath=SHAPES_PATH):
'''
Check if shapes have been downloaded
'''
for shape_level in SHAPE_LEVELS:
if not os.path.isdir(os.path.join(SHAPES_PATH,year_version+'_'+shape_level.lower())):
if not os.path.isdir(os.path.join(shapesPath,year_version+'_'+shape_level.lower())):
raise NameError('Missing shapefiles for:',shape_level)

def getZips(bounds=None,cbsaCode=None,zipShapes=None,asList=True,quietly=True):
def getZips(bounds=None,cbsaCode=None,shapesPath=SHAPES_PATH,zipShapes=None,asList=True,quietly=True):
'''
Get the zipcodes for the given bounds or for the given cbsaCode
Expand All @@ -22,6 +22,9 @@ def getZips(bounds=None,cbsaCode=None,zipShapes=None,asList=True,quietly=True):
Polygon of bounds in WGS84 (EPSG:4326).
cbsaCode : str
CBSA Code of metro area to select
shapesPath : str
Path to shapes: SHAPES_PATH.
> SHAPES_PATH = 'tables/shapes/'
zipShapes : geopandas.GeoDataFrame (optional)
If provided, it will not loaded.
Providing the shapes is preferred when running this function multiple times.
Expand Down

0 comments on commit 43f6553

Please sign in to comment.