[Qgis-developer] Load zipped shapefiles with python

Richard Duivenvoorde rdmailings at duif.net
Fri Nov 28 00:57:03 PST 2014


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