Bug report #11542
Error when saving a shapefile as GPX
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.
Related issues
Associated revisions
History
#1
Updated by Giovanni Manghi almost 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 almost 10 years ago
- File pts_test_gpsu_qgis.zip added
- File pts_test_gpsu.zip added
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 almost 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 almost 10 years ago
Original issue confirmed here, on Debian.
#5
Updated by Giovanni Manghi almost 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 almost 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 almost 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 almost 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 almost 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 almost 10 years ago
- Status changed from Open to Closed
Fixed in changeset 11c2bae74079ab008d7e7fb9233d714409aff008.
#12
Updated by Jukka Rahkonen almost 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 almost 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