Skip to content
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

Drop M/Z values algorithm doesn’t remove Z values in KML #53362

Open
1 of 2 tasks
diegoalarc opened this issue Jun 5, 2023 · 9 comments
Open
1 of 2 tasks

Drop M/Z values algorithm doesn’t remove Z values in KML #53362

diegoalarc opened this issue Jun 5, 2023 · 9 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers Processing Relating to QGIS Processing framework or individual Processing algorithms

Comments

@diegoalarc
Copy link

What is the bug or the crash?

When I try to remove the Z values from a KML, the algorithm converts them to 0. But if I try to convert them to geojson, these values are removed.

Steps to reproduce the issue

  1. Go to 'Processing Toolbox'.
  2. Click on 'Drop M/Z values'.
  3. Run the algo using a file with Z values and save it as KML
  4. Open the file as text.
  5. See error

Versions

version 3.30.3

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@diegoalarc diegoalarc added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jun 5, 2023
@nicogodet
Copy link
Member

I believe this is by design.
KML always contains X, Y Z (https://docs.ogc.org/is/12-007r2/12-007r2.html)

@nicogodet nicogodet added the Feedback Waiting on the submitter for answers label Jun 5, 2023
@diegoalarc
Copy link
Author

Were you able to find a paragraph where in this doc they mention that it's always 3D? thanks in advance.

@nicogodet
Copy link
Member

§6.2

The KML encoding of every kml:Location and coordinate tuple uses geodetic longitude, geodetic latitude, and altitude (in that order) as defined in Annex B.

@nicogodet
Copy link
Member

But https://docs.ogc.org/is/12-007r2/12-007r2.html#1212 says that altitude is optional.

@nicogodet nicogodet removed the Feedback Waiting on the submitter for answers label Jun 5, 2023
@diegoalarc
Copy link
Author

But, shouldn’t the "Drop M/Z values" drop the Z value anyway?

@agiudiceandrea
Copy link
Member

agiudiceandrea commented Jun 5, 2023

@nicogodet the issue also occur if the input layer of the "Drop M/Z values" processing algorithm is e.g. a plain Point (without Z and M) layer and the output layer is a KML layer.

@agiudiceandrea
Copy link
Member

agiudiceandrea commented Jun 5, 2023

The issue is not related to the "Drop M/Z values" processing algorithm itself. In fact the issue also occur with any other processing algorithm when the output layer is a KML layer: e.g. using the Dissolve algorithm with a plain Point (without Z and M) input Layer, a MultiPointZ KML layer is created instead of a MultiPoint KML layer.
It seems to me the issue is due to the fact that GDAL has 2 KML drivers (the KML driver and the LIBKML driver) and that the processing algorithms use the LIBKML driver instead of the KML driver (used when a layer is exported via Export->Save Features As...).
@diegoalarc, to avoid the issue, you can disable the LIBKML driver in Settings->Options->Data Sources->GDAL->Vector Drivers.
Probably @rouault knows if this issue can be fixed in GDAL and or in QGIS.

@rouault
Copy link
Contributor

rouault commented Jun 5, 2023

Probably @rouault knows if this issue can be fixed in GDAL and or in QGIS.

With a 2D geometry, GDAL calls libkml with just latitute, and longitude, but my quick scan at libkml itself is that it always add a Z=0 is not explicitly provided. So I don't think this can be fixed in GDAL. QGIS could potentially auto-switch to the KML driver for that algorithm.

@agiudiceandrea
Copy link
Member

agiudiceandrea commented Jun 5, 2023

QGIS could potentially auto-switch to the KML driver for that algorithm.

@rouault, it seems that all the processing algorithms in QGIS use the LIBKML driver so a KML layer created by any processing algorithm (with vector output) has an added Z coordinate.

@agiudiceandrea agiudiceandrea added Processing Relating to QGIS Processing framework or individual Processing algorithms Data Provider Related to specific vector, raster or mesh data providers labels Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

No branches or pull requests

4 participants