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

Impossible to read KMZ file #444

Open
remi-braun opened this issue Jul 8, 2024 · 8 comments
Open

Impossible to read KMZ file #444

remi-braun opened this issue Jul 8, 2024 · 8 comments

Comments

@remi-braun
Copy link

remi-braun commented Jul 8, 2024

GeoPandas 1.0+ is not able to read KMZ files with pyogrio's engine, when setting engine=fiona works:

With fiona:

gpd.read_file(
    "AOI_kmz.kmz", driver="KMZ", layer="General Information", engine="fiona"
)
>>>   Name  ...                                           geometry
>>> 0   03  ...  MULTIPOLYGON Z (((-72.31143 -36.56225 0, -72.5...
>>> [1 rows x 13 columns]

With pyogrio:

gpd.read_file(
    "AOI_kmz.kmz", driver="KMZ", layer="General Information"
)
>>>   pyogrio.errors.DataSourceError: 'AOI_kmz.kmz' not recognized as a supported file format. It might help to specify the correct driver explicitly by prefixing the file path with '<DRIVER>:', e.g. 'CSV:path'.

Here is the file:
AOI_kmz.zip


Versions:

geopandas.__version__
'1.0.1'
pyogrio.__version__
'0.9.0'
fiona.__version__
'1.9.6'
@remi-braun remi-braun changed the title Impossible Error in reading KMZ Impossible to read KMZ file Jul 8, 2024
@martinfleis
Copy link
Member

Hi, how did you install geopandas and pyogrio? In my installation from conda-forge, the snippet above works. Can you also show thew output of pyogrio.list_drivers()?

import pyogrio

pyogrio.list_drivers()

@remi-braun
Copy link
Author

The install is done via pip in a Docker (without conda) on Debian 11

The drivers are:

{'PCIDSK': 'rw', 'PDS4': 'rw', 'VICAR': 'rw', 'PDF': 'rw', 'MBTiles': 'rw', 'EEDA': 'r', 'OGCAPI': 'r', 'ESRI Shapefile': 'rw', 'MapInfo File': 'rw', 'UK .NTF': 'r', 'LVBAG': 'r', 'OGR_SDTS': 'r', 'S57': 'rw', 'DGN': 'rw', 'OGR_VRT': 'r', 'Memory': 'rw', 'CSV': 'rw', 'GML': 'rw', 'GPX': 'rw', 'KML': 'rw', 'GeoJSON': 'rw', 'GeoJSONSeq': 'rw', 'ESRIJSON': 'r', 'TopoJSON': 'r', 'OGR_GMT': 'rw', 'GPKG': 'rw', 'SQLite': 'rw', 'WAsP': 'rw', 'OpenFileGDB': 'rw', 'DXF': 'rw', 'FlatGeobuf': 'rw', 'Geoconcept': 'rw', 'GeoRSS': 'rw', 'VFK': 'r', 'PGDUMP': 'rw', 'OSM': 'r', 'GPSBabel': 'rw', 'OGR_PDS': 'r', 'WFS': 'r', 'OAPIF': 'r', 'EDIGEO': 'r', 'SVG': 'r', 'Idrisi': 'r', 'ODS': 'rw', 'XLSX': 'rw', 'Elasticsearch': 'rw', 'Carto': 'rw', 'AmigoCloud': 'rw', 'SXF': 'r', 'Selafin': 'rw', 'JML': 'rw', 'PLSCENES': 'r', 'CSW': 'r', 'VDV': 'rw', 'MVT': 'rw', 'NGW': 'rw', 'MapML': 'rw', 'GTFS': 'r', 'PMTiles': 'rw', 'JSONFG': 'rw', 'TIGER': 'r', 'AVCBin': 'r', 'AVCE00': 'r', 'HTTP': 'r'}

@remi-braun
Copy link
Author

remi-braun commented Jul 8, 2024

KML files are read fine, only KMZ files fail

@martinfleis
Copy link
Member

I think that the reason is that the PyPI wheels contain the KML driver while the conda-forge contain LIBKML driver.

@remi-braun
Copy link
Author

Is there a workaround to replicate the conda behaviour natively with pypi?

@theroggy
Copy link
Member

theroggy commented Jul 8, 2024

You can normally prepend the filename with "/vsizip/" to use the virtual filesystem feature of GDAL to do the unzipping.

I wonder if there is something wrong with the test file you uploaded... because for another .kmz this workaround works, but not for your test file.

import geopandas as gpd

print(gpd.read_file(r"/vsizip/C:/Temp/example.kmz"))

@remi-braun
Copy link
Author

remi-braun commented Jul 8, 2024

This file has been part of the test suite for years and worked :'(

I have other KMZ that fails too, so maybe there is an issue inside that is weird?

Unfortunately, the /vsizip/ workaround fails too for me

@theroggy
Copy link
Member

theroggy commented Jul 8, 2024

This file has been part of the test suite for years and worked :'(

Hmm... indeed, I can open it without problems in e.g. QGIS, so apparently the "KML" driver doesn't only limit the support to uncompressed .kml files but also to a subset of them... so it seems you'll really need the "LIBKML" 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

3 participants