Created
June 5, 2019 18:48
-
-
Save sergiolucero/3fb564309163c2b663e4e18dd2c53043 to your computer and use it in GitHub Desktop.
shapefile_geojson from CSV
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 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
depending on the geometry, we can also
from shapely.geometry import MultiGeometry, Polygon...