在下面发布的查询中,我想查询以下信息
ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(feature->>'geometry'),4326),25832) AS LIDARDataPolygonsAsGeometry
featuresCollection
是一个 geojson 对象。
如何从 geojson 对象查询?
query="""
WITH data AS (
SELECT '{featuresCollection}'::json AS featuresCollection
)
SELECT
LIDARDataPolygonsAsGeometry,
FROM (
SELECT
ST_Transform(ST_SetSRID(ST_GeomFromGeoJSON(feature->>'geometry'),4326),25832) AS LIDARDataPolygonsAsGeometry
FROM (SELECT json_array_elements(featuresCollection->'features') AS feature
FROM data) AS f) j
GROUP BY LIDARDataPolygonsAsGeometry
""".format(table=config['PostgreDB']['table_name_test'], width=config['Grid']['cell_width'], height=config['Grid']['cell_height'],bufferRadius=config['Grid']['buffer_radius'],featuresCollection=featuresCollection)
答案 0 :(得分:1)
只需在子查询中解压缩您的特征集合,提取几何图形并应用您想要的转换,例如来自名为 account.drafts.get(id=reply_to_item_id)
的表,其中列 t
包含 GeoJSON 字符串:
geojson