在CSV查看器中加载geojson多边形

时间:2014-01-21 12:16:10

标签: json geojson ckan

我想在csv查看器中加载一个包含geojson多边形的列的csv,但我不能这样做。

我正在使用ckan 2.2。

我有这个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]]}"

我想加载csv查看器,选择map和Geojson,但那没用。

我可以加载点但不能加载多边形。在此查看器中是否可以加载多边形?

此CSV适用于点:

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]}"

1 个答案:

答案 0 :(得分:1)

是的,CKAN使用的Recline查看器支持所有GeoJSON几何。

问题是您的多边形不正确,您需要:

  1. 坐标周围有一组额外的[](请参阅spec
  2. 重复第一个坐标对
  3. 关闭多边形

    所以这个文件可以工作(你可能需要5个坐标对来绘制方形多边形):

    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]]]}"
    

    在行动here

    中查看