Created
April 17, 2019 15:13
-
-
Save ValerieAnne563/46015fba18247c103966f31045f60ee6 to your computer and use it in GitHub Desktop.
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
| # Demonstrates the ability to open a Fiona collection through VSI bindings | |
| # Based on the following example but with the correct source URL: | |
| # https://gis.stackexchange.com/questions/225586/reading-raw-data-into-geopandas | |
| import fiona | |
| import gdal | |
| import requests | |
| import uuid | |
| import geopandas as gpd | |
| request = requests.get('https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip') | |
| vsiz = '/vsimem/{}.zip'.format(uuid.uuid4().hex) #gdal/ogr requires a .zip extension | |
| gdal.FileFromMemBuffer(vsiz,bytes(request.content)) | |
| with fiona.Collection(vsiz, vsi='zip', layer ='poly') as f: | |
| gdf = gpd.GeoDataFrame.from_features(f, crs=f.crs) | |
| print(gdf.head()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment