Update of "ZippedSHP"
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: f4198393ed6084c2dbe6ea0bb6a8c615bdc7d3ad
Page Name:ZippedSHP
Date: 2020-07-18 17:55:08
Original User: sandro
Parent: 3da774363fc236b7060d15c330f90b976386bf5b
Content

Back to 5.0.0-doc main page

Reading SHP and DBF files directly from within a Zipfile

Starting since version 5.0.0 SpatiaLite has the capability to directly read any Shapefile (or DBF file) contained within a compressed Zipfile.
Several closely related SQL functions have been introduced as well.

Please note: all the following SQL functions will access a Zipfile from the local file-system, and will consequently pose security concerns.

All them will be effectively available only if the external variable SPATIALITE_SECURITY=relaxed has been set.

Accessing a Zipped SHP

All these new SQL functions are now supported:
We'll now start a quick tutorial about using all these new SQL functions. Note: the tutorial is based on the dataset you can download from here
SELECT Zipfile_NumSHP ( 'c:/users/afuri/Downloads/Limiti01012020.zip' )
------------
4
SELECT Zipfile_shpN ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 1 )
------
Limiti01012020/Com01012020/Com01012020_WGS84

SELECT Zipfile_shpN ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 2 )
------
Limiti01012020/ProvCM01012020/ProvCM01012020_WGS84

SELECT Zipfile_shpN ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 3 )
------
Limiti01012020/Reg01012020/Reg01012020_WGS84

SELECT Zipfile_shpN ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 4 )
-------
Limiti01012020/RipGeo01012020/RipGeo01012020_WGS84
SELECT PROJ_GuessSridFromZipSHP ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 'Limiti01012020/Com01012020/Com01012020_WGS84' )
------------
32632
Please note: the SQL function PROJ_GuessSridFromZipSHP() will be available only when SpatiaLite is linked to a recent version of PROJ (PROJ.6.x.x or any later).
SELECT ImportZipSHP ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 
                      'Limiti01012020/Com01012020/Com01012020_WGS84' , 
                      'comuni', 'UTF-8' ) 
---------
7904
The ImportZipSHP() closely mimics ImportSHP(), except in that it requires one more argument specifying the pathname of the Zipfile containing the Shapefile to be imported.
On success it will return the number of features inserted into the Spatial Table that has just been created; on failure it will just return NULL.

In its simplest form it requires just four arguments:
SELECT ImportZipSHP ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 
                      'Limiti01012020/Reg01012020/Reg01012020_WGS84' , 
                      'regioni', 'UTF-8' , 32632 , 'the_geom' , 'cod_reg' ,
                      'MULTIPOLYGON' , 0 , 0 , 1 , 0 , 'LOWER' , 1 , 0 ) 
-------------
20
In its complete form ImportZipSHP() supports these further optional arguments:


Accessing a Zipped DBF

All these new SQL functions are now supported:
We'll continue to use the same Zipfile in this tutorial too.
SELECT Zipfile_NumDBF ( 'c:/users/afuri/Downloads/Limiti01012020.zip' )
------------
4
SELECT Zipfile_dbfN ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 1 )
------
Limiti01012020/Com01012020/Com01012020_WGS84.dbf

SELECT Zipfile_dbfN ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 2 )
------
Limiti01012020/ProvCM01012020/ProvCM01012020_WGS84.dbf

SELECT Zipfile_dbfN ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 3 )
------
Limiti01012020/Reg01012020/Reg01012020_WGS84.dbf

SELECT Zipfile_dbfN ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 4 )
-------
Limiti01012020/RipGeo01012020/RipGeo01012020_WGS84.dbf
SELECT ImportZipDBF ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 
                      'Limiti01012020/Com01012020/Com01012020_WGS84.dbf' , 
                      'comuni_dbf', 'UTF-8' ) 
---------
7904
The ImportZipDBF() closely mimics ImportDBF(), except in that it requires one more argument specifying the pathname of the Zipfile containing the DBF file to be imported.
On success it will return the number of rows inserted into the Table that has just been created; on failure it will just return NULL.

In its simplest form it requires just four arguments:
SELECT ImportZipDBF ( 'c:/users/afuri/Downloads/Limiti01012020.zip' , 
                      'Limiti01012020/Reg01012020/Reg01012020_WGS84.dbf' , 
                      'regioni_dbf', 'UTF-8' , 'cod_reg' , 1 , 'LOWER' ) 
-------------
20
In its complete form ImportZipDBF() supports these further optional arguments:

GUI support for importing SHP and DBF datasets directly from a Zipfile

  1. Using the standard file selection dialog box you simply have to select the intended Zipfile.
  2. This Zipfile will be automatically scanned so to identify all Shapefiles (or respectively DBF files) it contains:
    • If the Zipfile does not contain any Shapefile (or DBF file) an error message will be shown and the whole import operation will faiil.
    • Otherwise the dialog box shown on the side figure will be shown.
      Select one of the Shapefiles (of DBF file= from the list an then confirm.
GUI_1
A slightly modified version of the dialog box allowing to set all import options will appear.
Set any appropriate option and then continue as usual.

If you wish to import more than a single Shapefile (od DBF file) from the same Zipfile you must reapete the same procedure for each dataset.


Selecting multiple datasest in a single pass is not allowed.
GUI_2



Back to 5.0.0-doc main page