Bug report #11542

Error when saving a shapefile as GPX

Added by Howard Frederick about 10 years ago. Updated about 10 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:-
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:19812

Description

Saving a point layer as a GPX file always gives an error:

Export to vector file failed.
Error: creation of layer failed (OGR error:Geometry type of `Multi Point' not supported in GPX.
)

Checking the WKT (copy feature), the geometry is all POINT not MULTIPOINT. See attached shapefile for example.

Saving GPX lines works just fine in comparison.

point_example.zip (49.9 KB) Howard Frederick, 2014-11-04 02:33 AM

pts_test_gpsu.zip - Point shapefile created by GPS Utility (13.7 KB) Howard Frederick, 2014-11-07 11:25 PM

pts_test_gpsu_qgis.zip - Point shapefile created by QGIS (16.4 KB) Howard Frederick, 2014-11-07 11:25 PM


Related issues

Related to QGIS Application - Bug report #10584: Saving as SpatiaLite fails with "save as" dialog when inp... Closed 2014-06-14

Associated revisions

Revision 11c2bae7
Added by Jürgen Fischer about 10 years ago

vector file writer: scan shape file geometries instead of just assuming multi geometry types (followup 528c4cacb, refs #10584, fixes #11542, fixes #11597)

Revision 881e25ba
Added by Jürgen Fischer about 10 years ago

vector file writer: scan shape file geometries instead of just assuming multi geometry types (followup 528c4cacb, refs #10584, fixes #11542, fixes #11597)

History

#1 Updated by Giovanni Manghi about 10 years ago

  • Affected QGIS version changed from 2.6.0 to master
  • Subject changed from Error when saving as GPX waypoints to Error when saving a shapefile as GPX
  • Priority changed from Normal to Severe/Regression
  • Target version changed from Version 2.6 to Version 2.8
  • Operating System deleted (Mac OS X)
  • OS version deleted (10.9.4)

The conversion operation is made by ogr2ogr and the message is from it and is right, if the input shape has multi geometries than it cannot be converted to GPX.

@giovanni@sibirica:~/Desktop/point_example > ogr2ogr -f GPX ogr4.gpx point\\ example.shp -dsco GPX_USE_EXTENSIONS=YES
ERROR 6: Geometry type of `Multi Point' not supported in GPX.

ERROR 1: Terminating translation prematurely after failed
translation of layer point example (use -skipfailures to skip errors)@

After converting the shapefile to singlepart (with the proper tool in the vector menu) you can convert the shape to GPX using directly ogr2ogr or QGIS, however it seems that in QGIS 2.6 something is wrong as it continues to give the same error message, while in previous QGIS releases it works are expected.

#2 Updated by Howard Frederick about 10 years ago

Having done some more testing, discovered some odd behaviour.

Using ogr2ogr to convert a point shapefile NOT generated by QGIS 2.6 works just fine! See the attached file pts_test_gpsu, which was created by GPS Utility:

ogr2ogr -f GPX pts_test_gpsu.gpx pts_test_gpsu.shp -dsco GPX_USE_EXTENSIONS=YES

This works just fine. However, if I open that GPSU-created shapefile in QGIS, then save-as SHP with a different filename, the created point file cannot then be converted by ogr2ogr:
ogr2ogr -f GPX pts_test_gpsu_qgis.gpx pts_test_gpsu_qgis.shp -dsco GPX_USE_EXTENSIONS=YES
ERROR 6: Geometry type of `Multi Point' not supported in GPX.

ERROR 1: Terminating translation prematurely after failed
translation of layer pts_test_gpsu_qgis (use -skipfailures to skip errors)

I have tried first converting to a Spatialite file - but that also creates a multipoint.

Workaround: as GM suggests, using the 'multipart to singlepart' tool creates a correct single-part shapefile.

#3 Updated by Howard Frederick about 10 years ago

Another workaround, from command line at least - use the -explodecollections flag:

ogr2ogr -f GPX pts_test_gpsu_qgis.gpx pts_test_gpsu_qgis.shp -dsco GPX_USE_EXTENSIONS=YES -explodecollections

However, trying to put that into the save-as dialogue in QGIS (under layer or data source options) has no effect, still get same problem.

#4 Updated by Paolo Cavallini about 10 years ago

Original issue confirmed here, on Debian.

#5 Updated by Giovanni Manghi about 10 years ago

Howard Frederick wrote:

This works just fine. However, if I open that GPSU-created shapefile in QGIS, then save-as SHP with a different filename, the created point file cannot then be converted by ogr2ogr:

this is not a bug, is a limitation (or feature) of the gpx format, that cannot have multigeometries.

#6 Updated by Giovanni Manghi about 10 years ago

However, trying to put that into the save-as dialogue in QGIS (under layer or data source options) has no effect, still get same problem.

this is the real (qgis) bug, it cannot save as gpx also legit singlepart layers.

#7 Updated by Howard Frederick about 10 years ago

this is not a bug, is a limitation (or feature) of the gpx format, that cannot have multigeometries.

Understood; problem is that QGIS itself is mangling the spatial format, creating MULTIPOINT when in fact it is all POINT (as verified by copy-paste of WKT directly from QGIS).

#9 Updated by Giovanni Manghi about 10 years ago

Understood; problem is that QGIS itself is mangling the spatial format, creating MULTIPOINT

the problem is that it assumes as "multi" also shapes that have no multipart geometries. And this is the regression.

#10 Updated by Giovanni Manghi about 10 years ago

the problem is that it assumes as "multi" also shapes that have no multipart geometries. And this is the regression.

I don't think is related and I don't think that this question is about a bug: it is normal that when you import data into postgis you must choose if you need a layer that accepts multipart geometries or not. By default the layers are created as "multi", but the user can choose otherwise (and when editing, if a multipart geometry is added it will give error on save).

#11 Updated by Jürgen Fischer about 10 years ago

  • Status changed from Open to Closed

#12 Updated by Jukka Rahkonen about 10 years ago

Sorry about commenting a closed issue, but the fix could be finalized by adding a check box to Save as dialogue which would add a "-lco PROMOTE_TO_MULTI" layer creation option http://www.gdal.org/ogr2ogr.html. Multipoints are rare and it is almost always correct to create a POINT layer if selection does not contain multipoints. However, for lines and polygons it is very often better to create a MULTI-layer or otherwise users cannot later add multilinestrings or multipolygons to the layers in PostGIS or Spatialite. Multigeometries are also often created by spatial functions automatically from simple geometries.

#13 Updated by Paolo Cavallini about 10 years ago

Agreed, better opening a different ticket. IMHO multi should be on by default for lines and polygons, off by default for points

Also available in: Atom PDF