Presentation is loading. Please wait.

Presentation is loading. Please wait.

Spatialite Created by Alessandro Furieri (Italy) Created by Alessandro Furieri (Italy) First release published in 2008 First release published in 2008.

Similar presentations


Presentation on theme: "Spatialite Created by Alessandro Furieri (Italy) Created by Alessandro Furieri (Italy) First release published in 2008 First release published in 2008."— Presentation transcript:

1 Spatialite Created by Alessandro Furieri (Italy) Created by Alessandro Furieri (Italy) First release published in 2008 First release published in 2008 SpatiaLite is an open source library intended to extend the SQLite core to support fully fledged Spatial SQL capabilities. SpatiaLite is an open source library intended to extend the SQLite core to support fully fledged Spatial SQL capabilities. SpatiaLite is smoothly integrated into SQLite to provide a complete and powerful Spatial DBMS (mostly OGC-SFS compliant). SpatiaLite is smoothly integrated into SQLite to provide a complete and powerful Spatial DBMS (mostly OGC-SFS compliant).

2 SQLite Created by Richard Hipp Created by Richard Hipp First release published in 2000 First release published in 2000 SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. A single lightweight library implementing the full SQL engine A single lightweight library implementing the full SQL engine standard SQL implementation: almost complete SQL-92 standard SQL implementation: almost complete SQL-92 no complex client/server architecture no complex client/server architecture no installation, no configuration no installation, no configuration

3 What do you need to get started? Spatialite Spatialite Spatialite_GUI Program Spatialite_GUI Program SQLite SQLite SQLite Manager (Firefox plugin) SQLite Manager (Firefox plugin) Install extension from Firefox browser Install extension from Firefox browser

4 Resources SQLite:http://www.sqlite.org/ -File based relational database Spatialite:http://www.gaia-gis.it/gaia-sins/ -SQLite extension for gis functionality GDAL:http://www.gdal.org/ -Set of libraries for ETL operations with multiple GIS formats QGIS:http://www.qgis.org/ -Open Source GIS application OSGeo4W:http://trac.osgeo.org/osgeo4w/ -Installer for suite of open source GIS software and tools GIS

5 Spatialite GUI Application

6 SQLite database files

7 DEMO Spatialite GUI Spatialite GUI Shapefile loader Shapefile loader GDAL Command line GDAL Command line Load shapefile, file geodatabase Load shapefile, file geodatabase

8 Loading Shapefile in Spatialite GUI Load Shapefil e

9 Using GDAL to load data into Spatialite

10 -Load shapefile into Spatialite database ogr2ogr –update –append –f SQLite C:\GISData\NDIC\ndic.sqlite C:\GISData\NDIC\shapefiles\Horizontals_Lines.shp Horizontals_Lines –nln Horizontals_Lines Shapefile directory to Spatialite (windows): for %f in (/GISData/NDIC/*.shp) do ( ogr2ogr -update -append -t_srs ESPGS:4267 -f SQLite C:\GISData\NDIC\ndic.sqlite GISData\NDIC\%f -nln layers) ( ogr2ogr -update -append -t_srs ESPGS:4267 -f SQLite C:\GISData\NDIC\ndic.sqlite GISData\NDIC\%f -nln layers) -Load file geodatabase feature class into Spatialite database ogr2ogr –update –append –f SQLite C:\GISData\NDIC\ndic.sqlite MTND_CadNSDI.gdb PLSSFirstDivision –nln Landgrid_PLSS_Sections Using GDAL to load data into Spatialite

11 DEMO Firefox SQLite Manager Firefox SQLite Manager Spatialite GUI Spatialite GUI

12 Using Firefox SQLite Manager -Basic query

13 Spatialite GUI -Basic query

14 Spatialite GUI -query with spatial function

15 Using Firefox SQLite Manager -Trying to use spatial functions in query

16 SQLite vs Spatialite new database structure Empty Spatial Metadata

17 Pros Cross-platform Cross-platform No custom installation to use No custom installation to use Single file for transport Single file for transport Simple access to SQL queries Simple access to SQL queries Large spatial function library Large spatial function library Transform geometries within sql query Transform geometries within sql query Fast prototyping of geodatase modeling and analysis Fast prototyping of geodatase modeling and analysisCons Only simple multi-editor environment, no conflict management Only simple multi-editor environment, no conflict management Less performant than server based RDBMS Less performant than server based RDBMS

18 Who is Spatialite for? Non-Enterprise user Non-Enterprise user Users with reasonable size datasets Users with reasonable size datasets User wanting to get started with SQL User wanting to get started with SQL Users needing another GIS tool in their belt Users needing another GIS tool in their belt User familiar with SQL wanting access to spatial functions User familiar with SQL wanting access to spatial functions User who needs functionality of RDBMS but does not have access to servers User who needs functionality of RDBMS but does not have access to servers

19 Who is Spatialite NOT for? Enterprise user who needs maximum performance Enterprise user who needs maximum performance Users who need a robust multi-editor environment with conflict management Users who need a robust multi-editor environment with conflict management User who have very large datasets User who have very large datasets

20 DEMO Spatialite GUI Spatialite GUI Query examples Query examples

21 Spatialite GUI -Basic query

22 Spatialite GUI -query with spatial function

23 USE database IF OBJECT_ID('tempdb..#NDIC_HORZ_LIST') IS NOT NULL DROP TABLE #NDIC_HORZ_LIST SET NOCOUNT OFF -- Create temp table to hold the OBJECTID and apply filter on wells without enough points SELECT lineID = identity (int,1,1), OBJECTID INTO #NDIC_HORZ_LIST FROM database.dbo.API12_PATHS CREATE CLUSTERED INDEX idx_NDIC_HORZ_LIST_lineid ON #NDIC_HORZ_LIST(lineID) CREATE INDEX idx_NDIC_HORZ_LIST_objectid ON #NDIC_HORZ_LIST(OBJECTID) geometry numeric(25,20) numeric(25,20) numeric(25,20) numeric(25,20) numeric(25,20) numeric(25,20) numeric(25,20) = 0 numeric(25,20) = 0 numeric(25,20) int int INT geometry geometry geometry NVARCHAR(MAX) = 1 -- Outer loop to iterate over lines in table, using the counts from the temp table <= (SELECT COUNT(*) FROM #NDIC_HORZ_LIST) BEGIN -- Assign OBJECTID FROM Temp table to variable = (SELECT OBJECTID FROM #NDIC_HORZ_LIST WHERE lineID -- Assign SHAPE From table to geometry variable = (SELECT SHAPE FROM database.dbo.API12_PATHS WHERE OBJECTID / 2 = 'LINESTRING(' = 1 -- Loop through points in line until the working length is longer than half the line length BEGIN -- For first point add start point from line = 1 BEGIN + AS VARCHAR(10)) + ' ' + AS VARCHAR(10)) + ')' END ELSE BEGIN -- Strip the trailing ) from the line string text = - 1) + ',' + AS VARCHAR(10)) + ' ' + AS VARCHAR(10)) + ')' = 4267) = geometry::STGeomFromText('LINESTRING(' + - 1).STX AS VARCHAR(10)) + ' ' + - 1).STY AS VARCHAR(10)) + ',' + AS VARCHAR(10)) + ' ' + AS VARCHAR(10)) + ')', 4267) BEGIN = - 1).STX = - 1).STY = = = * = * = geometry::STGeomFromText('POINT(' + AS VARCHAR(25)) + ' ' + AS VARCHAR(25)) + ')',4267) INSERT INTO database.dbo.API10_SHL(OBJECTID,SHAPE) SELECT ROW_NUMBER() OVER(ORDER BY FROM database.dbo.API12_PATHS AS t2 END END + 1 END + 1 END SQL Server Non-Spatial Queries SQL Server MGMT Studio – Midpoint on Linestring Multiple While Loop Operations SLOWER

24 Spatialite GUI -query with spatial function

25 Spatialite GUI -attach to another sqlite database SQL Query GUI

26 Spatialite GUI -Query using join to attached database

27 Spatialite Spatial Functions GeomFromExifGpsBlobPointFromWKBIsSimpleNumPointsSingleSidedBufferSridFromAuthCRS MakePointLineFromWKBIsValidPointNSharedPathsShiftCoords MakePointZLineStringFromWKBBoundaryCentroidLine_Interpolate_PointShiftCoordinates MakePointMPolyFromWKBEnvelopeAreaLine_Interpolate_Equidistant_PointsST_Translate MakePointZMPolygonFromWKBExpandExteriorRingLine_Locate_PointST_Shift_Longitude MakeLineMPointFromWKBNPointsNumInteriorRingLine_SubstringNormalizeLonLat TriangularGridMultiPointFromWKBNRingsNumInteriorRingsClosestPointScaleCoords HexagonalGridMLineFromWKBReverseInteriorRingNShortestLineScaleCoordinates BuildMbrMultiLineStringFromWKBForceLHRNumGeometriesSnapRotateCoords BuildCircleMbrMPolyFromWKBSanitizeGeometryGeometryNCollectRotateCoordinates ExtentMultiPolygonFromWKBCompressGeometryMbrEqualCollectReflectCoords ToGARSGeomCollFromWKBUncompressGeometryMbrDisjointLineMergeReflectCoordinates GARSMbr GeometryCollectionFromWK B CastToPointMbrTouchesBuildAreaSwapCoords MbrMinXBdPolyFromWKBCastToLinestringMbrWithinPolygonizeSwapCoordinates MbrMinYBdMPolyFromWKBCastToPolygonMbrOverlapsUnaryUnionInitSpatialMetaData MbrMaxXAsTextCastToMultiPointMbrIntersectsDissolveSegmentsInsertEpsgSrid MbrMaxYAsWKTCastToMultiLinestringEnvelopesIntersectsDissolvePointsAddGeometryColumn ST_MinZAsBinaryCastToMultiPolygonMbrContainsLinesFromRingsRecoverGeometryColumn MaxZAsSVG CastToGeometyCollecti on EqualsLinesCutAtNodesDiscardGeometryColumn MinMAsKmlCastToMultiDisjointRingsCutAtNodesRegisterVirtualGeometry MaxMGeomFromKmlCastToSingleTouchesCollectionExtractDropVirtualGeometry GeomFromTextAsGmlCastToXYWithinLocateAlongMeasureCreateSpatialIndex ST_WKTToSQLGeomFromGMLCastToXYZOverlapsLocateBetweenMeasuresCreateMbrCache PointFromTextAsGeoJSONCastToXYMCrossesDelaunayTriangulationDisableSpatialIndex LineFromTextGeomFromGeoJSONCastToXYZMIntersectsVoronojDiagramCheckSpatialIndex LineStringFromTextAsEWKBXContainsConcaveHullRecoverSpatialIndex PolyFromTextGeomFromEWKBYCoversMakeValidUpdateLayerStatistics PolygonFromTextAsEWKTZCoveredByMakeValidDiscardedCreateTopologyTables MPointFromTextGeomFromEWKTMRelateSegmentizeCheckSpatialMetaData MultiPointFromTextAsFGFStartPointDistanceSplitAutoFDOStart MLineFromTextGeomFromFGFEndPointPtDistWithinSplitLeftAutoFDOStop MultiLineStringFromTextDimensionLengthIntersectionSplitRightInitFDOSpatialMetaData MPolyFromTextCoordDimensionPerimeterDifferenceAzimuthAddFDOGeometryColumn MultiPolygonFromTextNDims Geodesic Length GUnionSnapToGrid RecoverFDOGeometryColum n GeomCollFromTextIs3D Great Circle Length GUnionGeoHash DiscardFDOGeometryColum n GeometryCollectionFromTe xt IsMeasuredIsClosedSymDifferenceAsX3DFilterMbrWithin BdPolyFromTextGeometryTypeIsRingBufferMaxDistanceFilterMbrContains BdMPolyFromTextSRIDPointOnSurfaceConvexHull3DDistanceFilterMbrIntersects GeomFromWKBSetSRIDSimplifyHausdorffDistance3DMaxDistanceBuildMbrFilter ST_WKBToSQLIsEmpty SimplifyPreserveTopol ogy OffestCurveTransformRTreeIntersects RTreeDistWithinRTreeContainsRTreeWithin

28 Using Spatialite in ArcMap Read-only access was added at 10.2 Read-only access was added at 10.2 Can use geoprocessing tools with layers but with limitations Can use geoprocessing tools with layers but with limitations Using layers for geoprocessing input and output to different format seems to work pretty well. Using layers for geoprocessing input and output to different format seems to work pretty well. Can write results to sqlite database, but pretty buggy at Can write results to sqlite database, but pretty buggy at Recommend using as read-only access at current version Recommend using as read-only access at current version Cannot be published to ArcGIS Server Cannot be published to ArcGIS Server Cannot be edited through ArcMap Cannot be edited through ArcMap

29 DEMO Spatialite functions Spatialite functions SQL in Spatialite GUI SQL in Spatialite GUI View layers in ArcMap View layers in ArcMap

30 Spatialite GUI -Interpolated point along line -Use as midpoint

31 ArcMap - Midpoints

32 Spatialite GUI -Line offset -Geometry transformation inline function

33 ArcMap -Line offset

34 Spatialite GUI Single Sided Buffer

35 Spatialite GUI Buffer

36 ArcMap Single Sided Buffer

37 ArcMap Single Sided Buffer vs Buffer

38 Spatialite GUI -Convex Hull vs Concave Hull

39 ArcMap Convex Hull Concave Hull

40 Using Spatialite in QGIS Read/Write Access Read/Write Access Direct Editing of features Direct Editing of features DBManager – Execute queries on SQLite database inside QGIS DBManager – Execute queries on SQLite database inside QGIS

41 DEMO Spatialite editing in QGIS Spatialite editing in QGIS SQL in QGIS DB Manager SQL in QGIS DB Manager

42 Spatialite Editing -Connecting to Spatialite database

43 Spatialite Editing -Creating new table SQL Query Editor

44 Spatialite Editing -Add Geometry Column

45 Spatialite Editing -Add new table to map

46 Spatialite Editing -Editing new layer

47 Spatialite Editing -Query new feature in Spatialite

48 Spatialite Editing -View new feature in ArcMap

49 QGIS Query Layer Single Sided Buffer

50 QGIS

51 THE END

52 QGIS Query Layer - DBManager spatial query and add to map

53 QGIS Line offset

54 QGIS – DBManager -Sql window, create new layer from sql query

55 QGIS – DBManager -Sql window, create new layer from sql query -Subset of data based on ST_Intersects

56 Resources SQLite:http://www.sqlite.org/ -File based relational database Spatialite:http://www.gaia-gis.it/gaia-sins/ -SQLite extension for gis functionality Geopackage:http://www.geopackage.org -OGC standard for exchange format GDAL:http://www.gdal.org/ -Set of libraries for ETL operations with multiple GIS formats QGIS:http://www.qgis.org/ -Open Source GIS application OSGeo4W:http://trac.osgeo.org/osgeo4w/ -Installer for suite of open source GIS software and tools GIS

57 Spatialite GUI -Interpolated points along line -Geometry transformation inline function

58 ArcMap - Interpolated points along line

59 Spatialite GUI Delaunay Triangulation

60 ArcMap


Download ppt "Spatialite Created by Alessandro Furieri (Italy) Created by Alessandro Furieri (Italy) First release published in 2008 First release published in 2008."

Similar presentations


Ads by Google