简体   繁体   English

如何在 QGIS 的 Postgresql 数据库层中将几何类型从 LINESTRING 更改为 MULTILINESTRING

[英]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.

相关问题 如何从PostGIS中的MultiLineString获取第N个LineString? - How to get the Nth LineString from a MultiLineString in PostGIS? 如何从以下 json 数组类型创建线串几何? - How to create from a the following json array type a linestring geometry? 谷歌云 SQL - PostgreSQL 来自第三方的 QGIS 数据库连接 - Google Cloud SQL - PostgreSQL database connection from QGIS for third parties 创建 postgresql 触发器 function 以更新线串几何列 - Creating a postgresql trigger function to update a Linestring geometry column 如何通过两列聚合多个点并从中创建一个LineString / MultiLineString - How to aggregate multiple points by two columns and create a LineString / MultiLineString out of them 如何检查多线串是否真的是多线串? - How to check if multilinestring really is multilinestring? 如何修复“请求的未知数据库类型几何,Doctrine\DBAL\Platforms\PostgreSQL100Platform 可能不支持它。” - How to fix “Unknown database type geometry requested, Doctrine\DBAL\Platforms\PostgreSQL100Platform may not support it.” 在Perl中解析Postgresql几何类型? - Postgresql Geometry Type parseing In Perl? 如何将字段添加到qgis中加载的postgis层 - How to add fields to postgis layer loaded in qgis PostgreSQL 中的多边形区域与 QGIS 不同 - Polygon area in PostgreSQL differs from QGIS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM