2

I would like to display some countries region on a map. I have an CSV file with coordinates for each polygons (regions) as polygon; [[x,y],[x1,Y1],[xn,yn]].

When I import it to CartoDB, the_geom column = null and I have an invalid_the_geom column with coordinates.

Any ideas?

1
  • 1
    I think if you use csv CartoDB expects x,y only, ie, points, as there is no way to know that an arbitrary number of xy pairs is supposed to represent a polygons. Perhaps use GeoJSON or WKT instead. Commented Feb 9, 2016 at 16:54

1 Answer 1

1

As far as I remember, CartoDB allows upload of geojson files. So open your csv in libre office calc or excel or wherever and concatenate it in this structure:

{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "value": 1234, "label": "polygon1" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 10, 45 ], [ 11, 45 ], [ 11.8, 47.4 ] ] ] } },
{ "type": "Feature", "properties": { "value": 0815, "label": "polygon2" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1, 45 ], [ 9, 45 ], [ 10, 47 ] ] ] } }
]
}

As you can see, each polygon has its coordinate pairs in the end at

"type": "Polygon", "coordinates": [ [ 

save it as a geojson file like "file.geoJSON" and upload it as a new dataset to cartodb.

The above mentioned example is visible here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.