Feature request #5242

Open KMZ without needing to unzip

Added by Andrew DeMerchant almost 12 years ago. Updated about 8 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Data Provider
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:14977

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 f8c4b3a2
Added by Jürgen Fischer over 8 years 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

#1 Updated by Giovanni Manghi almost 12 years ago

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

#2 Updated by Alister Hood over 11 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...

#3 Updated by Alister Hood over 11 years ago

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

#4 Updated by Alister Hood over 11 years ago

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

#5 Updated by Larry Shaffer over 11 years ago

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

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

#6 Updated by Alister Hood over 11 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)

#7 Updated by Alister Hood over 11 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")

#8 Updated by Pirmin Kalberer over 11 years ago

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

#9 Updated by Giovanni Manghi over 9 years ago

  • Status changed from Feedback to Open

#10 Updated by Médéric RIBREUX over 8 years 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 !

#11 Updated by Jürgen Fischer over 8 years ago

  • Status changed from In Progress to Closed

#12 Updated by Salvatore Larosa about 8 years 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

#13 Updated by Jürgen Fischer about 8 years 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 PDF