[英]How to change geometry type from LINESTRING to MULTILINESTRING in a Postgresql database layer in QGIS
I merged lines in a shapefile layer and need to copy them to a postgreSQL database layer.我在 shapefile 层中合并了行,需要将它们复制到 postgreSQL 数据库层。 If I paste them to the pg db layer, it does not work.
如果我将它们粘贴到 pg db 层,它就不起作用。 If I merge them, after I pasted to QGIS, it crashes.
如果我合并它们,在我粘贴到 QGIS 后,它会崩溃。 I figured out that it works, if I export the pg db layer to a geopackage or shapefile layer and set the geometry from linestring to multilinestring.
我发现它可以工作,如果我将 pg db 层导出到地理包或 shapefile 层并将几何从线串设置为多线串。 The problem is that I need it to bring to the data base layer.
问题是我需要将它带到数据库层。 Anyone can give me a hint how I configure the db layer in the right way?
任何人都可以给我一个提示,我如何以正确的方式配置数据库层?
Thank you!谢谢!
I would change the geometry type in PostgreSQL not in the geopackage or shapefile.我将更改 PostgreSQL 中的几何类型,而不是在 geopackage 或 shapefile 中。 The problem seems to be in the geometry type column.
问题似乎出在几何类型列中。 You could use this to change it:
你可以用它来改变它:
ALTER TABLE [table_name]
ALTER COLUMN [geometry_column] TYPE geometry(MULTILINESTRING) USING ST_Multi([geometry_column]);
OR或者
You could import in PostgreSQL the lines without merging them and to that in with postgis while altering the geometry type of the column:您可以在 PostgreSQL 中导入这些行而不合并它们,并在更改列的几何类型时使用 postgis 合并它们:
ALTER TABLE [table_name]
ALTER COLUMN [geometry_column] TYPE geometry(MULTILINESTRING) USING ST_Union([geometry_column]);
Also, this might help you: https://gis.stackexchange.com/questions/68071/how-to-create-a-multilinestring-feature-with-a-postgis-layer-in-qgis此外,这可能会对您有所帮助: https://gis.stackexchange.com/questions/68071/how-to-create-a-multilinestring-feature-with-a-postgis-layer-in-qgis
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.