I merged lines in a shapefile layer and need to copy them to a postgreSQL database layer. If I paste them to the pg db layer, it does not work. If I merge them, after I pasted to QGIS, it crashes. 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. 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. 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:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.