【发布时间】:2021-05-26 05:07:55
【问题描述】:
在下面的帖子中,我进行了一些查询,并且效果很好。但是,当我添加执行坐标转换的行和查询 geom 的行时,我在运行 Web 服务时收到以下错误:
Input geometry has unknown (0) SRID
我是 Postgis 的新手。我该如何解决这个问题?
代码:
query = """ WITH data AS (
SELECT '{featuresArray}'::json AS featuresCollection
)
SELECT gid,geom,type::text,properties::text,
array_to_string(array_agg(x_4326||' '||y_4326 ORDER BY gid),',') AS g4326,
array_to_string(array_agg(x_25832||' '||y_25832 ORDER BY gid),',') AS g25832
FROM (
SELECT
ROW_NUMBER() OVER () AS gid,
ST_AsText(ST_GeomFromGeoJSON(feature->>'geometry')) AS geom,
feature->>'type' AS type,
feature->>'properties' AS properties,
ST_X((ST_DumpPoints((ST_GeomFromGeoJSON(feature->>'geometry')))).geom) x_4326,
ST_Y((ST_DumpPoints((ST_GeomFromGeoJSON(feature->>'geometry')))).geom) y_4326,
ST_X((ST_DumpPoints((ST_Transform(ST_GeomFromGeoJSON(feature->>'geometry'),25832)))).geom) x_25832,
ST_X((ST_DumpPoints((ST_Transform(ST_GeomFromGeoJSON(feature->>'geometry'),25832)))).geom) y_25832
FROM (SELECT json_array_elements(featuresCollection->'features') AS feature FROM data) AS f) j
GROUP BY gid,type::text,properties::text,geom
ORDER BY gid;""".format(featuresArray=featuresArray)
【问题讨论】:
-
您好。请添加
CREATE TABLE和UPDATE/INSERT语句。 -
嗨,我不做任何更新或仅插入选择
-
@JimJones 我解决了它..它现在可以工作了..谢谢你..你在上一个问题中发布的提示是必不可少且有用的
-
为了完整起见,我也会在这里添加它作为答案
-
@JimJones 是的,当然。请做
标签: python postgresql postgis