如何处理CKAN DataStore中的GeoJson?

How to deal with GeoJson in CKAN DataStore?

CKAN DataStore 真的能够处理 GeoJson 吗?我没有在文档中看到任何参考,除了 link 关于 DataStore Map 可视化,说:

Shows data stored on the DataStore in an interactive map. It supports plotting markers from a pair of latitude / longitude fields or from a field containing a GeoJSON representation of the geometries.

因此,我假设 GeoJson 在 DataStore 列中被接受。无论如何,我有 not found 任何 GeoJson CKAN 类型,因此,我再次猜测简单的 Json 类型必须用于此目的。

有人可以证实吗?谢谢!

编辑 1

我已经创建了一个资源和一个数据存储以及一个与该资源关联的 "recline_map_view"。然后,我更新了一个值,由 datastore_search 操作显示:

$ curl -X POST "https://host:port/api/3/action/datastore_search" -d '{"resource_id":"14418d40-de42-4fdd-84f7-3c51244c7469"}' -H "Authorization: xxx" -k
{"help": "https://host:port/api/3/action/help_show?name=datastore_search", "success": true, "result": {"resource_id": "14418d40-de42-4fdd-84f7-3c51244c7469", "fields": [{"type": "int4", "id": "_id"}, {"type": "text", "id": "label"}, {"type": "json", "id": "geojson"}], "records": [{"_id": 1, "geojson": {"type": "Point", "coordinates": [48.856699999999996, 2.3508]}, "label": "Paris"}], "_links": {"start": "/api/3/action/datastore_search", "next": "/api/3/action/datastore_search?offset=100"}, "total": 1}}

然而,CKAN 中没有显示任何内容:(

编辑 2

这是我的 CKAN 的问题。我已经在 demo.ckan.org 测试了 Ifurini 的解决方案并且它有效。

GeoJSON 只是一种(特殊类型的)JSON,因此它没有作为数据库字段的特殊处理方式。

因此,您可以从一个简单的 CSV 文件创建一个带有 GeoJSON 字段的资源,如下所示:

Name,Position
"Paris","{""type"":""Point"",""coordinates"":[2.3508,48.8567]}"

(注意 double 双引号 "" 而不是 single 双引号 "

如果您调用列 "GeoJSON"(或 "geojson"、"gEoJsOn" 等,因为大小写并不重要),地图视图将自动使用该字段来标记数据在地图中,而不是让您手动 select 使用哪个字段。