mapbox / csv2geojson

magically convert csv files to geojson files
http://mapbox.github.io/csv2geojson/
MIT License
363 stars 82 forks source link

grouping geojson to create polygon #1

Closed lonelydatum closed 11 years ago

lonelydatum commented 11 years ago

Hi Tom,

Thanks for the code.

I would like to format the geojson into a specific format. As you can see from the sample csv, Alcona is a polygon that is composed of the 3 points. Is there a way to output Alcona as 1 polygon? Currently its only outputting as 3 points. Thanks in advance!

This is a sample of the csv: LABEL,Longitude,Latitude Alcona,-83.31528,44.59827 Alcona,-83.3164,44.59826 Alcona,-83.31735,44.59826

This is what its outputting: { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "LABEL": "Alcona", "Longitude": "-83.31528", "Latitude": "44.59827" }, "geometry": { "type": "Point", "coordinates": [ -83.31528, 44.59827 ] } }, { "type": "Feature", "properties": { "LABEL": "Alcona", "Longitude": "-83.3164", "Latitude": "44.59826" }, "geometry": { "type": "Point", "coordinates": [ -83.3164, 44.59826 ] } }, { "type": "Feature", "properties": { "LABEL": "Alcona", "Longitude": "-83.31735", "Latitude": "44.59826" }, "geometry": { "type": "Point", "coordinates": [ -83.31735, 44.59826 ] } } ] }

This is how I'd like the geojson to look like: { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "LABEL": "Alcona"
}, "geometry": { "type": "Polygon", "coordinates": [[[-83.31528,44.59827],[-83.3164,44.59826],[-83.31735,44.59826]]] } } ] }

tmcw commented 11 years ago

Polygon and line support added in eb89bd3e36908d8980e023375752989f3d714f85

lonelydatum commented 11 years ago

Thanks for this Tom :)

tmcw commented 11 years ago

no problem, thx for the good idea!