[英]How can I store Geojson response into Postgres Database using node-express?
NOTE: Geojson response contains coordinates datatype, which needs to be stored in Postgres as geometry datatype. 注意: Geojson响应包含坐标数据类型,需要将其作为几何数据类型存储在Postgres中。
I don't want to use any 3rd party software like Qgis or ArcGIS, or command line tool such as geojson2psql in Postgis. 我不想使用任何第三方软件(例如Qgis或ArcGIS)或命令行工具(例如Postgis中的geojson2psql)。
It's simple to query a jsonb column for specific attributes, using the ->
operator. 使用
->
运算符查询jsonb列中的特定属性很简单。 For example, assuming a column name of "geodata", this query: 例如,假设列名称为“ geodata”,则此查询:
SELECT geodata->'geometry'->'coordinates' AS coords FROM geo_example;
...would return [-104.99404, 39.75621] from this GeoJSON example I grabbed from Leaflet : ...将从我从Leaflet抓取的这个GeoJSON示例返回[-104.99404,39.75621] :
{
"type": "Feature",
"properties": {
"name": "Coors Field",
"amenity": "Baseball Stadium",
"popupContent": "This is where the Rockies play!"
},
"geometry": {
"type": "Point",
"coordinates": [-104.99404, 39.75621]
}
};
Here's a SQL Fiddle showing a couple examples. 这是一个SQL Fiddle,显示了几个示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.