Analyzing Exported Shapefile - geopaparazzi/Spatialite-Tasks-with-Sql-Scripts GitHub Wiki
Analyzing a Shape File
- You can download the Shape file used in this sample here:
- '20140722.berlin_plz_segments.zip' - 24.4 kB
wget https://raw.github.com/geopaparazzi/Spatialite-Tasks-with-Sql-Scripts/master/Shapefiles_import/20140722.berlin_plz_segments.zip
- '20140722.berlin_plz_segments.zip' - 24.4 kB
<-- 'Index Page for Importing Shapefiles'
<-- 'creating a Shapefile from spatialite database from using QGIS'
--> 'Using spatialite_gui for Shapefiles'
As we all know, all roads leads toward Rome
- the question is only which should be taken for this case:
ogrinfo- a
gdaltool for Vector Formats (gdalinfobeing only for Rasters)
- a
QGIS- where the Shapefile can be loaded
spatialite_gui- with use of
virtualshapeor - the
guiFunctionLoad Shapefile
- with use of
ogrinfo
- the following command will list the first record
- including the
geometryasWKT(Well Known Text)-al:List all features of all layers- with
Featuresthe fields are meant
- with
-where:SQL WHERE statement. Only features matching the attribute query will be reported- here we will show the first record with
'fid in(0)'fid: when usingogrthisvirtualfield will always exists- and starts with
0 'fid' is a special field recognized by OGR SQL.
- and starts with
- here we will show the first record with
- including the
Since our goal is to find out
- how the Shapefile is structures (i.e. which fields it has)
- we use this general solution on any
ogrsource
- we use this general solution on any
ogrinfo -al -where 'fid in(0)' berlin_plz_segments/berlin_plz_segments.shp
INFO: Open of `berlin_plz_segments/berlin_plz_segments.shp'
using driver `ESRI Shapefile' successful.
Layer name: berlin_plz_segments
Geometry: Line String
Feature Count: 1
Extent: (18405.673758, 16709.072001) - (30386.451847, 26751.219329)
Layer SRS WKT:
PROJCS["DHDN_Soldner_Berlin",
GEOGCS["GCS_DHDN",
DATUM["Deutsches_Hauptdreiecksnetz",
SPHEROID["Bessel_1841",6377397.155,299.1528128]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Cassini_Soldner"],
PARAMETER["latitude_of_origin",52.41864827777778],
PARAMETER["central_meridian",13.62720366666667],
PARAMETER["false_easting",40000],
PARAMETER["false_northing",10000],
UNIT["Meter",1],
PARAMETER["scale_factor",1.0]]
name: String (254.0)
notes: String (254.0)
admin_leve: String (254.0)
belongs_to: String (254.0)
belongs__1: String (254.0)
valid_sinc: Date (10.0)
valid_unti: Date (10.0)
OGRFeature(berlin_plz_segments):0
name (String) = C,NW
notes (String) = (null)
admin_leve (String) = 3
belongs_to (String) = 1101780000
belongs__1 (String) = 1105580000
valid_sinc (Date) = 1862/05/15
valid_unti (Date) = 1873/07/24
LINESTRING (24409 21404,24325.60068222816335 21373.160422727149125,24174.132778051218338 21358.822013509026874,24191 21148)
Note:
- by chance, the first
LINESTRINGhere is short- with other geometries the output can be much bigger
--
The original Spatialite SpatialTable used to create the Shape file looked like this:

Note:
- since Shapesfiles use the
DBASEDatabase format- the field-names have been 'raped', due to the 8 Character field-name restriction
belongs_to_01is nowbelongs_tobelongs_to_02is nowbelongs__1
- the field-names have been 'raped', due to the 8 Character field-name restriction
Later we will show a way how to import a shape-file
- with the final table have usable, or if known the original, field-names
QGIS
-
to load a
Shape-Filesall you need to do is toDrag and Droptheberlin_plz_segments.shpintoQGIS- I believe,
gdal(to whichogris a part of) Drivers- are used with
Drag and Dropas default
- are used with
- I believe,
-
Select
berlin_plz_segments: right-Mouse: selectOpen Attribute Table- will show the following

- will show the following
-
Select
berlin_plz_segments: right-Mouse: selectPropetries- select
Fields- will show the following

- will show the following
- select
You can download the Shape file used in this sample here:
--> 'Using spatialite_gui for Shapefiles'
2014-07-22: Mark Johnson, Berlin Germany