Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Created March 24, 2021 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiolucero/a3fffa0c028857df4277efdd166e4919 to your computer and use it in GitHub Desktop.
Save sergiolucero/a3fffa0c028857df4277efdd166e4919 to your computer and use it in GitHub Desktop.
Street splitter
# shape source: https://geoine-ine-chile.opendata.arcgis.com/datasets/186b78e22db44f96a016f9254de44dd4_0
import geopandas as gp
gdf = gp.read_file('MAESTRO_CALLES',init={'epsg:3857'})
gdf = gdf.to_crs('epsg:4326')
gdf.columns=[c.lower() for c in gdf.columns]
for comuna, cdf in gdf.groupby('comuna'):
ddf = cdf[['comuna','nombre_aux','geometry']]
ddf.to_file(f'CALLES/{comuna.replace(" ","_")}.json', engine='GeoJSON', single_file=True)
print(comuna,len(ddf))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment