Search code examples
postgisshapefileqgis

Can't export all rows of table to shapefile in postgis (mixed geometry types)


I am working in postgis and created a table with LineStrings as geometry. I work with postgis all the time and I am used to saving my tables to shapefiles with the plugin Postgis Shapefile and dbf loader. For some reason the table I am referring to now gives the error

Exporting with configuration: table, schema, table ERROR: Incompatible mixed geometry types in table Table export failed.

Whit QGIS I tried to save it as a shapefile. It does succeed but excludes 6 rows of my table. These rows have a different geom then the other rows that do work. The ones that work start with 010500002 and the ones that dont with 01020000E. I have added two examples below.

Any idea how I can fix my geom's so I can export the table as shapefile?

Works "0105000020407100000100000001020000002A0000007F6ABC74D1C6F140A4703D0AFFA81A41560E2DB2C1C6F140A4703D8A09A91A41105839B4A4C6F1404C37894121A91A416DE7FBA989C6F140C520B0F239A91A41FED478E976C6F140C1CAA1C54AA91A414C37894168C6F1401D5A64BB5AA91A413108AC1C56C6F140B6F3 (...)"

Does not work "01020000E0407100001C000000A01A2FDDE1E908411283C0CAD89A1E41F4FDD478E9260240000000004049F240EE7C3F353BEA0841CBA14536CE9A1E41894160E5D02202405839B4C8F649F240448B6CE7A9EA08411F85EBD1C19A1E411F85EB51B81E024054E3A59BD84AF2409EEFA7C645EB0841068195C3B19A1E417F6ABC (...)"


Solution

  • With the following statement you can find out what geometrytypes are in your table.

    SELECT DISTINCT ST_geometryType(your_geom_column) FROM your_table 
    

    In my situation I found out I had one point in my table with a lot of linestrings. I looked at the point in QGIS and saw I did not need it and deleted it from the table. Afterwards the export worked and it was fixed.