Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Created June 5, 2019 18: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/3fb564309163c2b663e4e18dd2c53043 to your computer and use it in GitHub Desktop.
Save sergiolucero/3fb564309163c2b663e4e18dd2c53043 to your computer and use it in GitHub Desktop.
shapefile_geojson from CSV
import pandas as pd
from geopandas import GeoDataFrame
from shapely.geometry import Point
import fiona
df = pd.read_csv('data.csv')
geometry = [Point(xy) for xy in zip(df.x, df.y)]
crs = {'init': 'epsg:2263'} #http://www.spatialreference.org/ref/epsg/2263/
geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)
geo_df.to_file(driver='ESRI Shapefile', filename='data.shp')
gdf.to_file(filename='fase1.json', driver="GeoJSON") # might need cleaning up of some columns
@sergiolucero
Copy link
Author

depending on the geometry, we can also
from shapely.geometry import MultiGeometry, Polygon...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment