简体   繁体   English

输入几何具有未知 (0) SRID

[英]Input geometry has unknown (0) SRID

in the below posted i make some queries and it works fine.在下面的帖子中,我做了一些查询,它工作正常。 however when i add the lines that do the coordinates conversion and the line that query the geom i receive the following error when i run the web-service但是,当我添加执行坐标转换的行和查询geom的行时,我在运行 Web 服务时收到以下错误

Input geometry has unknown (0) SRID

i am new to postgis and i hope to help me to fix this issue我是 postgis 的新手,我希望能帮助我解决这个问题

code :代码

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)

Some PostGIS functions rely on SRS, such as ST_Transform .一些 PostGIS 函数依赖于 SRS,例如ST_Transform You have to specify which SRS you're transforming from, otherwise the conversion script has no reference to compute the new coordinates, eg from EPSG:25832 to EPSG:4326 :您必须指定要转换的 SRS,否则转换脚本没有参考来计算新坐标,例如从EPSG:25832EPSG:4326

SELECT ST_Transform('SRID=25832;POINT(1 1)',4326);

.. otherwise it will raise an exception ..否则会引发异常

SELECT ST_Transform('POINT(1 1)',4326); -- <-- WKT literal without SRS
ERROR:  ST_Transform: Input geometry has unknown (0) SRID

With ST_SetSRID you can set the SRS to geometries in case they haven't any - as your example suggests, eg .使用ST_SetSRID ,您可以将 SRS 设置为几何图形,以防它们没有任何几何图形 - 正如您的示例所暗示的那样,例如 .

SELECT ST_Transform(
         ST_SetSRID('POINT(1 1)'::geometry,25832),
         4326);

The same principle goes for CREATE TABLE and INSERT / UPDATE statements. CREATE TABLEINSERT / UPDATE语句的原理相同。 When creating a table we declare the SRS as follows..创建表时,我们将 SRS 声明如下..

CREATE TABLE t (geom geometry(point,4326));

.. so PostGIS expects that all incoming geometries have the same SRS.. .. 所以 PostGIS 期望所有传入的几何图形都具有相同的 SRS ..

INSERT INTO t VALUES ('SRID=4326;POINT(1 1)'); 

.. otherwise it raises an exception too ..否则它也会引发异常

INSERT INTO t VALUES ('SRID=25832;POINT(1 1)'); 
ERROR:  Geometry SRID (25832) does not match column SRID (4326)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更改几何的SRID - Change the SRID of a geometry 不会在“未知SRID”上引发异常 - Does not raise exception on “Unknown SRID” GeoDjango ORM查找错误地将几何转换为SQL中不需要的SRID - GeoDjango ORM lookup wrongly transforms geometry to unwanted SRID in SQL 带有 srid 4326 的 GeoDjango 距离查询返回“SpatiaLite 不支持对具有大地坐标系的几何字段进行距离查询。” - GeoDjango distance query with srid 4326 returns 'SpatiaLite does not support distance queries on geometry fields with a geodetic coordinate system.' “注册” object 没有属性“几何” - 'Registration' object has no attribute 'geometry' 模块“匀称”没有属性“几何”错误 - module 'shapely' has no attribute 'geometry' error tkinter 框架没有几何形状 python tkinter - tkinter frame has no geometry python tkinter 输入张量<name>以形状 () 进入循环,但具有形状<unknown>一次迭代后 - Input tensor <name> enters the loop with shape (), but has shape <unknown> after one iteration imageCollection().filterBounds() 未显示几何输入的结果 - imageCollection().filterBounds() is not showing results from geometry input 如何在当前 model 中使用另一个 model 作为层,其中输入的形状未知 - How to use another model as a layer in current model which input has unknown shape
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM