Question

I want to load in the csv viewer a csv with a column that contains a geojson polygons, but i can´t do that.

I´m using ckan 2.2.

I have this csv:

NAME,GEOJSON

"P1", "{""type"":""Polygon"",""coordinates"": [[9.0114910478323 , 45.35880131440966], [9.014491488013135 , 45.35880097314403], [9.0144909480813 , 45.35668565341486]]}"
"P2", "{""type"":""Polygon"",""coordinates"": [[9.014491488013135 , 45.35880097314403], [9.017491928134044 , 45.358800553060284], [9.017491276410173 , 45.35668523336193]]}"
"P3", "{""type"":""Polygon"",""coordinates"": [[9.017491928134044 , 45.358800553060284], [9.02049236818262 , 45.35880005415845], [9.020491604666724 , 45.356684734496675]]}"

I want to load in the csv viewer, selecting map and Geojson, but thats no work.

I can load points but no polygon. Is factible load polygons in this viewer?

This CSV works with points:

NAME,GEOJSON

"P1", "{""type"":""Point"",""coordinates"":[-3.620039398822976,40.41977058365936]}"
"P2", "{""type"":""Point"",""coordinates"":[-3.72974339439061,40.41108768721466]}"
"P3", "{""type"":""Point"",""coordinates"":[-3.702445264167018,40.3876818541849]}"
Was it helpful?

Solution

Yes, the Recline viewer that CKAN uses supports all GeoJSON geometries.

The problem is that your polygons are not correct, you need:

  1. An extra set of [] around your coordinates (See the spec)
  2. Close your polygons by repeating the first coordinate pair

So this file will work (you probably want 5 coordinate pairs to draw a square polygon):

name,geom
"P1", "{""type"":""Polygon"",""coordinates"": [[[9.0114910478323 , 45.35880131440966], [9.014491488013135 , 45.35880097314403], [9.0144909480813 , 45.35668565341486],[9.0114910478323 , 45.35880131440966]]]}"
"P2", "{""type"":""Polygon"",""coordinates"": [[[9.014491488013135 , 45.35880097314403], [9.017491928134044 , 45.358800553060284], [9.017491276410173 , 45.35668523336193],[9.014491488013135 , 45.35880097314403]]]}"
"P3", "{""type"":""Polygon"",""coordinates"": [[[9.017491928134044 , 45.358800553060284], [9.02049236818262 , 45.35880005415845], [9.020491604666724 , 45.356684734496675],[9.017491928134044 , 45.358800553060284]]]}"

See it in action here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top