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

Appending/over-writing KML file results in introduction of Z-dimension #424

Open
nicholas-ys-tan opened this issue Jun 15, 2024 · 0 comments

Comments

@nicholas-ys-tan
Copy link
Contributor

This issue was encountered in writing the tests for PR #421.

When over-writing a KML file, a Z-dimension was undesirably added to the co-ordinates. This arose when testing appending to the KML file as it involves writing into an existing file. It appears that when writing to an existing file, the driver uses LIBKML even if driver='KML' is specified resulting in the addition of the Z-dimension The addition of a Z-dimension is an artifact of the LIBKML driver.

Investigation of the .kml file does suggest any appending or over-writing an existing KML file produces a file format consistent with the LIBKML driver.

points = [Point(10, 20), Point(30, 40), Point(50, 60)]
gdf = gpd.GeoDataFrame(geometry=points, crs="EPSG:4326")
output_path = r'/home/nicholas/dev/data/ogr_test/temporary_kml_file2.kml'
write_dataframe(
    gdf, output_path, layer="tmp_layer", driver="KML", use_arrow=True
)

write_dataframe(
    gdf, output_path, layer="tmp_layer", driver="KML", use_arrow=True
)

print(gdf_read.geometry)
0    POINT Z (10 20 0)
1    POINT Z (30 40 0)
2    POINT Z (50 60 0)
Name: geometry, dtype: geometry

It is possible that the KML driver does not allow the opening of a file in update mode (called via ogr_open executing GDALOpenEx with the GDAL_OF_UPDATE flag) which then silently falls back on the LIBKML driver.

Additionally, if the LIBKML driver is not available - as it is not in the ubuntu-small CIs, we are unable to append to the file and raises a misleading error message: "It might help to specify the correct driver explicitly by prefixing the file path with ':', e.g. 'CSV:path'" despite explicitly specifying the KML driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant