[Qgis-developer] Load zipped shapefiles with python
Ziegler Stefan
Stefan.Ziegler at bd.so.ch
Fri Dec 5 06:04:31 PST 2014
Thanks Richard. It was the missing second slash.
If you drag n drop a zipped shapefile into the map canvas a selection dialog appears with all the layers inside the zip file. Is this behaviour also possible out-of-the-box with python?
Regards
Stefan
> -----Ursprüngliche Nachricht-----
> Von: Richard Duivenvoorde [mailto:rdmailings at duif.net]
> Gesendet: Freitag, 28. November 2014 09:57
> An: Ziegler Stefan; 'qgis-developer at lists.osgeo.org'
> Betreff: Re: [Qgis-developer] Load zipped shapefiles with python
>
> On 27-11-14 13:08, Ziegler Stefan wrote:
> > Hi
> >
> > Is it possible to load zipped shapefiles with python? I have some zip files with several
> shapefiles in it. I tried something like this:
> >
> > vlayer = QgsVectorLayer("/vsizip/home/stefan/Downloads/2546.zip/lfp3.shp", LFP3,
> "ogr")
> >
> > But the layer is not valid.
>
> Hi Stefan,
>
> maybe you already figured out?
>
> qgis.utils.iface.addVectorLayer("/vsizip//data/disk/home/richard/geodata/nl/autowegen.
> zip",
> "wegen", "ogr")
>
> loads a layer to me. Note though that you get the 'crs' popup in between.
>
> vlayer =
> QgsVectorLayer("/vsizip//data/disk/home/richard/geodata/nl/autowegen.zip",
> "wegen", "ogr")
>
> also works.
>
> Note:
> - /vsizip// <= double /
> - "ogr" <= no capitals
> (second argument is a string)
>
> Regards,
>
> Richard Duivenvoorde
>
>
More information about the Qgis-developer
mailing list