Skip to content

Instantly share code, notes, and snippets.

@jqtrde
Last active December 20, 2015 23:18
Show Gist options
  • Save jqtrde/6211044 to your computer and use it in GitHub Desktop.
Save jqtrde/6211044 to your computer and use it in GitHub Desktop.
HOWTO: Convert your CSV's to a reprojected GeoJSON with leaving the terminal.

CSV to a reprojected geojson

I've never liked having to open up QGIS or ArcGIS to convert a CSV into a shapefile/geojson. It always seemed like there should be an easier way, and it turns out that there is.

First, you'll want to install @tmcw's csv2geojson library, and GDAL.

npm install -g csv2geojson && brew install gdal

Second, let's convert your CSV to a GeoJSON

csv2geojson data.csv > output.geojson

Lastly, depending on how you collect and use your data, that may be all you need to do. I like to store as much of my spatial data on Github as possible, which requires reprojecting the data from UTM Zone 19(EPSG:26919) to WGS 84(EPSG:4326). With ogr2ogr, this is pretty simple.

ogr2ogr -F geojson -s_srs epsg:26919 -t_srs epsg:4326 projected.geojson output.geojson

Hope that helps!

long lat
594162 4932451
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "long": "594162", "lat": "4932451" }, "geometry": { "type": "Point", "coordinates": [ -67.814745063622965, 44.539239545393343 ] } }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment