Feature request #5242

Open KMZ without needing to unzip

Added by Andrew DeMerchant about 5 years ago. Updated about 1 year ago.

Status:Closed Start Date:03/27/2012
Priority:Normal Due date:
Assigned to:- % Done:

90%

Category:Data Provider
Target version:Future Release - Nice to have
Platform: Resolution:
Platform version: Pull Request or Patch supplied:No
Status info: Tag:

Description

It would be awfully nice if we could import KMZ files directly, without needing to unzip and import the KML files.

Associated revisions

Revision f8c4b3a21cb13cc0871cb0fb2ec9b231742b71d5
Added by Jürgen Fischer over 1 year ago

Merge pull request #2571 from medspx/work_newfile_extensions

Add formats extensions/protocol already supported by GDAL/OGR
(fixes #3799, fixes #4362, fixes #5242, fixes #6197)

History

Updated by Giovanni Manghi about 5 years ago

  • Category set to Vectors
  • Target version set to Version 2.0.0

Updated by Alister Hood over 4 years ago

FWIW, gdal/QGIS can already open a KMZ file, using the vsizip driver:

e.g.

H:\>ogrinfo /vsizip/C:\ZZ\test2.kmz
Had to open data source read-only.
INFO: Open of `/vsizip/C:\ZZ\test2.kmz'
      using driver `KML' successful.
1: test2 (Point)

And if I manually edit a .qgs file to add the kmz layer like this, then QGIS can open it:

<datasource>/vsizip/C:/ZZ/test2.kmz/test2.kml</datasource>

So I think all that is needed is to get QGIS and/or GDAL to automatically recognise the kmz layer. I guess it would be better to do this in GDAL than in QGIS...

Updated by Alister Hood over 4 years ago

Also, shouldn't the category for this ticket be data providers, not vectors?

Updated by Alister Hood over 4 years ago

Of course, the obvious workaround is to rename the .kmz to .zip

Updated by Larry Shaffer over 4 years ago

  • Category changed from Vectors to Data Provider
  • Status changed from Open to Feedback

See also: http://gis.stackexchange.com/questions/32082/can-qgis-open-kmz-files

Summary: On a Mac, where QGIS uses the Kyngchaos.com GDAL 1.9 Complete framework, or on any platform where QGIS has been compiled against a GDAL build with support for the Google LIBKML driver, you can open .kmz files directly using the open dialog and selecting the All Files (*) option, or simply drag/drop onto QGIS.

Not sure if the file structure of a ZIP archive is identical to that of a KMZ archive. Using Google's LIBKML driver might handle any issues. Currently GDAL in the Windows installers and Linux packages does not provide the LIBKML driver.

I tried Alister's workaround (change .kmz to .zip) and, on drag/drop, was presented with the Open ZIP Layer dialog, which led to the Open KML dialog, when a .kml file was chosen. Resulting in:

<datasource>/vsizip//Downloads/br_sv.zip/br_sv.kml|layername=Bathymetry Contours</datasource>

When br_sv.zip was changed back to br_sv.kmz (in project file) and the project reloaded, the given data source was treated the same as a ZIP, confirming Alister's findings on Mac, as well.

In lieu of waiting for different platforms to provide LIBKML driver support, Alister's suggestion to have .kmz treated as .zip sounds good, since users are already accessing the archived data in the same manner, just manually.

One issue I found: when drag/drop of .zip file, there was a cyclical reopening of the ZIP layers dialog, after importing KML layers. A simple Cancel dismissed the dialog. If not cancelled the second time around ends with "/Downloads/br_sv.zip is not a valid or recognized data source". May be a bug in QGIS ZIP support.

Multi-layered kml embedded in .kmz file for testing: http://coastal.er.usgs.gov/flash/google_earth/br_sv.kmz

Updated by Alister Hood over 4 years ago

Oh, I didn't see your reply, and had just found out about the libkml driver myself. It turns out there is a ticket for Windows:
http://trac.osgeo.org/osgeo4w/ticket/291

One issue I found: when drag/drop of .zip file, there was a cyclical reopening of the ZIP layers dialog, after importing KML layers.

Do you use QGIS 1.8?
That sounds like #6225 (fixed in master)

Updated by Alister Hood over 4 years ago

Alister Hood wrote:

And if I manually edit a .qgs file to add the kmz layer like this, then QGIS can open it:

Easier to run this in the Python console:
qgis.utils.iface.addVectorLayer("/vsizip/C:/ZZ/test2.kmz/test2.kml","test","ogr")

Updated by Pirmin Kalberer over 4 years ago

  • Target version changed from Version 2.0.0 to Future Release - Nice to have

Updated by Giovanni Manghi almost 3 years ago

  • Status changed from Feedback to Open

Updated by Médéric RIBREUX over 1 year ago

  • Status changed from Open to In Progress
  • % Done changed from 0 to 90

Hello, bug triage...

QGIS 2.13 master can open kmz files... but it lacks the *.kmz filter in the OGR file selector.

I am going to add it soon !

Updated by Jürgen Fischer over 1 year ago

  • Status changed from In Progress to Closed

Updated by Salvatore Larosa about 1 year ago

On Windows platform is not possible to load KMZ file (pointed out on the IT mailing list). GDAL from osgeo4w seem have not the LIBKML driver included. There is this ticket on the bug tracker [0]

[0] - https://trac.osgeo.org/osgeo4w/ticket/291

Updated by Jürgen Fischer about 1 year ago

Salvatore Larosa wrote:

On Windows platform is not possible to load KMZ file (pointed out on the IT mailing list). GDAL from osgeo4w seem have not the LIBKML driver included. There is this ticket on the bug tracker [0]

[0] - https://trac.osgeo.org/osgeo4w/ticket/291

Downstream issued fixed.

Also available in: Atom