2

I have a geopackage containing point features. Most features are single points but some are multipoints. When I attempt to import to PostGIS using ogr2ogr, I received the following error:

ERROR: Geometry type (MultiPoint) does not match column type (Point)

I then attempted to create a table beforehand where the geometry column is defined as multipoint. When attempting to load the geopackage into this table, I received this error:

ERROR 1: ERROR: Geometry type (Point) does not match column type (MultiPoint)

Is it thus impossible to have a PostGIS table containing both single points and multi-points? Can I convert the singular point features to multi-points?

4
  • IIRC, the -nlt option can be used during imports (not just table creation). Adding -nlt MULTIPOINT to the commandline you're using to load the geopackage might do the trick. Nov 21, 2019 at 17:44
  • 2
    You can also write it as -nlt promote_to_multi. Or create the table beforehand to use generic geometry type "geometry".
    – user30184
    Nov 21, 2019 at 18:30
  • @user30184: The former suggestion worked, and the latter did not. Thank you Nov 21, 2019 at 19:34
  • The latter should really work also. You can reach the same result by converting data into new PostGIS table with ogr2ogr by using -nlt geometry.
    – user30184
    Nov 21, 2019 at 20:47

1 Answer 1

2

In a more systematic way than the comments above - yes, you can, but depends on the definition of the table. You can define the geometry of the table as an abstract 'Geometry', then anything would go, or as a Multipoint, and coerce single Points to it, too. That is what happens in the recommendation above by an ogr2ogr script.

In general, having mixed geometry types can lead to problems with downstream clients (GIS, eg ArcGIS or QGIS, andpossibly some libraries), expecting homogenous collections. This is not a problem with points in a multipoint table as much as say combinations of points, lines and polygons.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.