Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用shapely在_geom字段中插入SRID_Python_Geo_Shapely - Fatal编程技术网

Python 使用shapely在_geom字段中插入SRID

Python 使用shapely在_geom字段中插入SRID,python,geo,shapely,Python,Geo,Shapely,我在数据库中有一个列,叫做_geom a geometry type,我将srid设置为sql alchemy的4326 当我尝试在此字段中插入wkt多边形时,他们会给出以下错误: DataError: (psycopg2.DataError) Geometry SRID (0) does not match column SRID (4326) 我使用shapely获得多边形。我得到了与您完全相同的错误消息,并通过将多边形的wkt包装在ST_GeomFromText中解决了问题 PostGI

我在数据库中有一个列,叫做_geom a geometry type,我将srid设置为sql alchemy的4326

当我尝试在此字段中插入wkt多边形时,他们会给出以下错误:

DataError: (psycopg2.DataError) Geometry SRID (0) does not match column SRID (4326)

我使用shapely获得多边形。

我得到了与您完全相同的错误消息,并通过将多边形的wkt包装在ST_GeomFromText中解决了问题

PostGIS数据库示例:

cursor.execute(
    "INSERT INTO a_table (the_geom) VALUES (ST_GeomFromText(%(polygon)s, 4326))",
    {'polygon': polygon.wkt}
)