spatialite_gui
v.1.5.0
a quick tutorial
ISTAT is the Italian National Census Authority: we'll use some data-sets of their own in order to
test and explain new features supported by v.1.5.0
You can freely download such data-sets at the following URLs:
http://www.istat.it/ambiente/cartografia/non_generalizzati/2011/reg2011.zip
Regions: Shapefile
http://www.istat.it/ambiente/cartografia/non_generalizzati/2011/prov2011.zip
Counties: Shapefile
http://www.istat.it/ambiente/cartografia/non_generalizzati/2011/com2011.zip
Local Councils: Shapefile
http://www.istat.it/strumenti/definizioni/comuni/tutti_i_file_xls.zip
miscellaneous Microsoft Excel spreadsheets (statistics data)
As usual, our first step is the one to create a new DB-file, named italy.sqlite
Please note: the following tutorial closely mimics a corresponding one extensively explained in
the Cookbook.
This time we'll mainly focus out attention on new features supported by SpatiaLite v.3.0.0 and
spatialite_gui v.1.5.0
Anyway the current tutorial can be used as a first contact experience for absolute beginners and
novice users as well.
Then we'll access an external Shapefile via the VirtualShapefile driver. This way the Shapefile still
remains on the file-system, and no data at all will be loaded into the DB itself.
Simply a virtual link is created, supporting full SQL access on the external data-source.
Please note: accessing an external data-source is an intrinsically slow and inefficient process:
anyway this could be a really useful option on many cases.
This VirtualShapefile connection is intended to access comuni (i.e. Local Councils).
In order to establish a proper VirtualShapefile connection, you must simply specify the following
arguments:
•
•
•
the name of the corresponding SQL table
the SRID [System Reference ID]: for ISTAT 23032 (i.e. ED50 / UTM zone 32N) is the right
value to be used.
the charset encoding: in this case CP1252, i.e. Windows Latin 1
Now we'll access two external DBF files via the VirtualDBF driver. Exactly as for Shapefiles, this
way the DBF still remains on the file-system, and no data at all will be loaded into the DB itself.
The first VirtualDBF connection is intended to access province (i.e. Counties); the second one is
intented to access regioni (i.e. Regions).
Please note: both province and regioni actually are Shapefiles.
But we already have Geometries represented at the lowest Local Council level, so storing
Geometries at highest hierarchic levels is absolutely redundant and unneeded.
Accessing the bare DBF (data attributes) is enough for our intended purposes.
In order to establish a proper VirtualDBF connection, you must simply specify the following
arguments:
•
•
the name of the corresponding SQL table
the charset encoding: in this case CP1252, i.e. Windows Latin 1
Please, repeat again this step, so to connect regioni as well via VirtualDBF.
New/Changed: as you can easily notice, now the Tables tree-view is clearly shown by distinct
categories. SQLite doesn't support the SCHEMA level, but this visual representation come very
close (just for visual/GUI purposes).
Any Table containing ordinary data is now placed under the User Data tree-node.
Any other tree-node contains special or system tables, i.e. tables not at all intended to be directly
accessed by lay users.
The default behavior is the one to show the User Data node in its expanded, state, whilst any other
special/system node is shown in the collapsed state.
You can obviously explicitly expand the appropriate special node, then querying any hidden table,
exactly as before: all them are simply displaced into a most convenient location.
Please note: a further meta-data table is now supported: spatialite_history
Its intended scope is the one to register the most relevant events affecting the DB-file (think of
something like an internal logfile).
SQL snippet:
SELECT c.nome_com AS LocalCouncil, p.nome_pro AS County,
r.nome_reg AS Region
FROM com2011 AS c
JOIN prov2011 AS p ON (c.cod_pro = p.cod_pro)
JOIN reg2011 AS r ON (c.cod_reg = r.cod_reg)
ORDER BY LocalCouncil;
New/Changed: you can now safely JOIN Virtual Tables. As you can notice, the above JOIN is fully
based on VirtualShapefile and VirtualDBF tables.
Please note: any JOIN operation involving one (or more) Virutal Table is intrinsically slow and
inefficient. Consider this options simply as an useful tool to be used during preliminary data
handling / exploration.
Never attempt to widely use such feature for any serious production task: loading your data into real
DB tables is very simple, and can offer you a by far better environment effectively supporting full
query optimization and fast data access.
New/Changed: a further Virtual driver is now supported: VirtualXL
This is intended to access (read only mode) any Microsoft Excel spreadsheet stored in the BIFF
binary format (aka .xls).
Please note: only .xls documents are supported.
The VirtualXL driver isn't able to read the newest Office Open XML based spreadsheets (.docx
or .docm)
This VirtualXL connection is intended to access elenco_comuni_italiani_30_giugno_2011.xls a
spreadsheet shipping useful statistic data for Local Councils