Created
October 25, 2017 20:00
-
-
Save debboutr/514016c0e2b7a84b8856bcba7adff85a to your computer and use it in GitHub Desktop.
Load selected rows from shapefile into a geoDF
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
import fiona | |
import geopandas as gpd | |
from datetime import datetime as dt | |
def getRows(fn, lookupList, col=None): | |
reader = fiona.open(fn) | |
crs = reader.crs | |
if col == None: | |
return gpd.GeoDataFrame.from_features([reader[x] for x in lookupList],crs=crs) | |
else: | |
return gpd.GeoDataFrame.from_features([reader[x] for x in range(len(reader)) if reader[x]['properties'][col] in lookupList],crs=crs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment