-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to import SHP multipolygons into PostGIS working copy #616
Comments
Haven't actually gotten to this yet but from the output it's clear that the geometry column is being imported as type POLYGON which causes issues as the geometry column actually contains at least one MULTIPOLYGON, which PostGIS won't allow in a POLYGON column. As a workaround in the meantime, you could try to make sure that all geometries in your source file are of uniform type - all POLYGON, or all MULTIPOLYGON. |
@olsen232 that's the thing. Shapefiles are by definition always multipolygons, even if they only contain single polygons. I think that the problem relies in the fact that kart assumes that the shapefile only contains single polygons (maybe by reading the first element?!) I haven't tried importing a shapefile only containing multipolygons to see what happens. |
Ah I see. We don't parse shapefiles directly but use osgeo.ogr to open them and adapt them to its common interface - I don't know off the top of my head if OGR reports the column-type by reading the appropriate column-metadata or by sampling the first element (or a mixture of both depending on whether the column-metadata contains all the relevant information). If I understand correctly, this means the fix should be straight forward in this instance - if OGR says "POLYGON" then we should import as MULTIPOLYGON, same logic for POLYLINE. I'll test to see if POINT and MULTIPOINT work as expected since it seems shapefiles treat those as distinct. |
Shapefiles don't distinguish between single- and multi- versions of these geometry types - so we promote the column to the multi-type on import in case there are any multi- instances in that column.
Fix for #616 - import .shp as MULTI-LINETRING, -POLYGON
Describe the bug
This error is returned while trying to import a shapefile containing multifeature into a PostGIS working copy.
The problem does not happen if the shape only has single polygons features. It also doesn't happen if the working copy is a geopackage.
To Reproduce
Steps to reproduce the behaviour:
https://mega.nz/file/sAFTHQrB#XMWdLccbPlCWcCY0ypJ4irlyxw3XzZ7M_FNGp8dvclo
Expected behaviour
What did you expect to happen?
Output
Add the output you're seeing to help explain your problem.
**Version Info **
Kart v0.11.1, Copyright (c) Kart Contributors
» GDAL v3.3.2; PROJ v8.1.1
» PyGit2 v1.9.0; Libgit2 v1.4.2; Git v2.34.0.windows.1.13.g93318cbc8d
» SQLAlchemy v1.4.29; pysqlite3 v2.6.0/v3.31.1; SpatiaLite v5.0.0; Libpq v11.0.9
» SpatialIndex v1.9.3
The text was updated successfully, but these errors were encountered: