location-aware computing · 2019. 10. 17. · spatial database: modeling and implementation with...
TRANSCRIPT
Location-aware Computing Spatial Databases: POSTGIS
Prof. Marco Di Felice Department of Computer Science and Engineering
University of Bologna
Context Aware Systems
http://www.cs.unibo.it/difelice/
Location-aware services
2
COMPONENTSofLOCATION-BASEDSERVICESARCHITECTURE
Source:http://geoawesomeness.com/
WewillconsiderDBMSforLocationbasedServiceandContent
Providers
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
Location-aware services
3
GeoDataACQUISITION
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
GeoDataMODELING
GeoDataSTORAGE
GeoDataVISUALIZATION
GeoDataAnalytics
Database Management Systems (DBMS)
4SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² DATABASEMANAGEMENTSYSTEMS(DBMS)² Softwaresystemthatisabletomanagedatacollections:large,
sharedandpersistent,inasecureandefficientway.² AhomogeneousdatacollectionwhichismanagedbyaDMBS
iscalleddatabase(e.g.databaseofstudentsatUNIBO).Ø Datamodeling,accordingtoalogicdatamodelØ Dataaccessandcreate/read/write/update(CRUD)operationsØ DataproceduresandtriggersØ Datasharingamongmultipleusers/applicationsØ DataencryptionanddataaccessprotectionØ DatashardinginnetworkeddistributeddeploymentsØ …
COMMONOPERATIONS
DBMS: Characteristics
5
ConcurrencyEfficiency
DBMS
Reliability Security
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
Spatial DBMS
6SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² ASpatialDatabaseManagementSystem(SDBMS)maybedefinedasaDBMSthatoffersspatialdatatypesinitsdatamodelandquerylanguage,andsupportsspatialdatatypesinitsimplementation[1].
[1]http://www.geol-amu.org/notes/m14b-4-4.htm
1.SDBMSsprovidenewdatatypesinordertomodelsome
geospatialfeatures.
https://do
cs.oracle.com/
7SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² ASpatialDatabaseManagementSystem(SDBMS)maybedefinedasaDBMSthatoffersspatialdatatypesinitsdatamodelandquerylanguage,andsupportsspatialdatatypesinitsimplementation[1].
[1]http://www.geol-amu.org/notes/m14b-4-4.htm
2.SDBMSsprovidespatialjoinsandspatialquery
methods.
Relationshipsbetweendataobjects
[2]DavidBlasby,POSTGIStutorial,BuildingaSpatialDatabaseinPostgreSQL
Spatial Relationships
Distance between a toxic waste dump and a piece of property you were considering buying.
SINGLEDISTANCE
Source:[2]
Spatial DBMS
Spatial Relationships
Distance to various pubs8
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
² ASpatialDatabaseManagementSystem(SDBMS)maybedefinedasaDBMSthatoffersspatialdatatypesinitsdatamodelandquerylanguage,andsupportsspatialdatatypesinitsimplementation[1].
[1]http://www.geol-amu.org/notes/m14b-4-4.htm
Relationshipsbetweendataobjects
[2]DavidBlasby,POSTGIStutorial,BuildingaSpatialDatabaseinPostgreSQL
MULTI-DISTANCE
Source:[2]
2.SDBMSsprovidespatialjoinsandspatialquery
methods.
Spatial DBMS
Spatial Relationships
Adjacency: All the lots which share an edge9
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
² ASpatialDatabaseManagementSystem(SDBMS)maybedefinedasaDBMSthatoffersspatialdatatypesinitsdatamodelandquerylanguage,andsupportsspatialdatatypesinitsimplementation[1].
[1]http://www.geol-amu.org/notes/m14b-4-4.htm
Relationshipsbetweendataobjects
[2]DavidBlasby,POSTGIStutorial,BuildingaSpatialDatabaseinPostgreSQL
ADJACENCY
Source:[2]
2.SDBMSsprovidespatialjoinsandspatialquery
methods.
Spatial DBMS
10SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² ASpatialDatabaseManagementSystem(SDBMS)maybedefinedasaDBMSthatoffersspatialdatatypesinitsdatamodelandquerylanguage,andsupportsspatialdatatypesinitsimplementation[1].
[1]http://www.geol-amu.org/notes/m14b-4-4.htm
Relationshipsbetweendataobjects
[2]DavidBlasby,POSTGIStutorial,BuildingaSpatialDatabaseinPostgreSQL
Source:[2]
Connectivity: Tributary relationships in river networks
CONNECTIVITY 2.SDBMSsprovidespatialjoinsandspatialquery
methods.
Spatial DBMS
11SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² ASpatialDatabaseManagementSystem(SDBMS)maybedefinedasaDBMSthatoffersspatialdatatypesinitsdatamodelandquerylanguage,andsupportsspatialdatatypesinitsimplementation[1].
[1]http://www.geol-amu.org/notes/m14b-4-4.htm
[2]DavidBlasby,POSTGIStutorial,BuildingaSpatialDatabaseinPostgreSQL
R-TREE3.SDBMSsprovidespatial
indexingfordatamanagementandqueryoptimization
https://do
cs.oracle.com/
Spatial DBMS
12SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
SpatialDatabaseManagementSystems(SDBMSs)
NativeSDBMS GenericDBMSwithSpatialExtensions
² SmallWorld ² OracleSpatial² MySQLGIS² PostGIShttps://seekingalpha.com
Spatial DBMS
Spatial DBMS: PostGIS
13SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² Postgres(QL)https://www.postgresql.org² Open-sourceRelationalDBMS(RDBMS)² Firstversionsreleasedin1990(1996withthisname)bya
teamofBerkeley(US)graduatestudents² Transactional,ACID-compliant² PL/pgSQLproceduralprogramminglanguage² Replicationsupportindistributedenvironments² Client-serverarchitecture² …
DBMS: Data Modeling
14
² OriginallyproposedbyE.Coddin1969.² DMBSsupportingtherelationalmodelarealsoknownasRDBMS.² Largelythemostuseddatamodellingapproach.² Basedonnotionsofrelationalalgebra.² SQLàProgramminglanguagesupporting/implementingthemodel.
RELATIONALMODEL
² Dataitemsarestructuredasfixedlengthrecords,andgroupedintocollectionsoflogical-relatedinformationcalledtables.
INFORMALDEFINITION
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
DBMS: Data Modeling
15
Name Code Lecturer
Databasesystems 0121 A.York
Networksecurity 1213 M.Write
MachineLearning 1455 R.Penrose
q Columnsofthetable(Propertiesofinterest)àAttributesq Headerofthetable(i.e.nameofthetable+nameoftheattributes)àSchemaq RowsàInstancesofthetable
² Dataitemsarestructuredasfixedlengthrecords,andgroupedintocollectionsoflogical-relatedinformationcalledtables.
COURSES
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
DBMS: Data Modeling
16
² Dataitemsarestructuredasfixedlengthrecords,andgroupedintocollectionsoflogical-relatedinformationcalledtables.
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
² Tablesandrelations² NULLvalues² Primarykey² Foreignkey² Normalforms² …
MAINELEMENTSOFTHERELATIONALMODEL
DBMS: Data Modeling
17
² StructuredQueryLanguage(SQL)àProgramminglanguageusedbyDBMSbasedontherelationaldatamodel(RBDMS).
Name Code LecturerCode
Databasesystems 0121 00
Networking 1213 01
Security 1455 02
COURSES
SELECTLECTURERCODEFROMCOURSESWHEREName=“Networking”
RetrievethecodeofthelecturerwhoisteachinganyNetworkingcourse
SQLCODE
01
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
18
² POSTGISàSpatialdatabaseextenderforthePostgreSQLDBMS.² StartedasaprojectofRefractionsResearch.² Adoptedandimprovedonbygovernments,public
organizationsandprivatecompanies.² UndertheumbrellaoftheOpenSourceGeospatial
Foundation(OSGeo).
SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGISMARCODIFELICE
CREATEDATABASEpostgis_trial;CREATEEXTENSIONpostgis;
Spatial DBMS: PostGIS
19SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
PostGISinAction,SecondEditionReginaO.ObeandLeoS.Hsu
April2015ISBN9781617291395ManningEdition
Aquitecompletereference…
Spatial DBMS: PostGIS
20SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGIScomponentsinthistutorial² SpatialDataTypes² Creatingnewgeometry/geographicdata² Geometryrelationshipsandgeo-queries² Importingandexportingspatialdata² POSTGISviewingtools² Spatialindexing
Spatial DBMS: PostGIS
21SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGISoffersfourmainspatialtypes
² GeometryàplanartypebasedonCartesianmath(elements:points,lines,polygons,…).
² Geographyàspheroidalgeodetictype(linesandpolygonsaredrawnonacurvedsurface).
² Topologyàrelationalmodeltype.Objectsarerepresentedasanetworkofnodesandedges.
² Rasteràspaceismodeledasagridofrectangularcells,eachcontaininganumericvalue.
Spatial DBMS: PostGIS
22SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
Geometry/geographysubtypes² Thesimplestgeometrysubytpe:Points
CREATETABLEmyPoints(idSERIALPRIMARYKEY,descriptionVARCHAR(10),pointGEOMETRY(POINT),3dpointGEOMETRY(POINTZ),pointsrdGEOMETRY(POINT,4326)
);
Spatial DBMS: PostGIS
23SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
Geometry/geographysubtypes² Thesimplestgeometrysubytpe:Points
Ø POINTàapointinthe2Dspacewith(X,Y)coordinatesØ POINTZàapointinthe3Dspacewith(X,Y,Z)coordinatesØ POINTMàapointinthe2Dspacewithameasuredvalue(M)Ø POINTZMàapointinthe3Dspacewithameasuredvalue(M)
Spatial DBMS: PostGIS
24SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
Geometry/geographysubtypesLINESTRINGLINESTRINGZLINESTRINGMLINESTRINGZMPOLYGONMULTIPOINTMULTIPOLYGONGEOMETRYCOLLECTION
CREATETABLEgeometries(namevarchar,geomgeometry);INSERTINTOgeometriesVALUES('Point','POINT(00)'),('Linestring','LINESTRING(00,11,21,22)'),('Polygon','POLYGON((00,10,11,01,00))'),('PolygonWithHole','POLYGON((00,100,1010,010,00),(11,12,22,21,11))'),('Collection','GEOMETRYCOLLECTION(POINT(20),POLYGON((00,10,11,01,00)))');
Spatial DBMS: PostGIS
25SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
Geometry/geographysubtypes
POLYHEDRALSURFACETIN(triangularirregularnetworks)
CIRCULARSTRINGSCOMPOUNDCURVESCURVEPOLYGONS
Spatial DBMS: PostGIS
26SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
SRID(SpatialReferenceIdentifier)² Spatialreferencesystemcurrentlyemployed
Ø Geoidandprojectionmodelinuse² Itcanbeomittedforgeometrytypedata² Itmustbeprovidedforgeographicaltypedata² Numericidàprimarykeyvalueofthetable
spatial_ref_sys
psridGEOMETRY(POINT,4269)
Spatial DBMS: PostGIS
27SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGIScomponentsinthistutorial² SpatialDataTypes² Creatingnewgeometry/geographicdata² Geometryrelationshipsandgeo-queries² Importingandexportingspatialdata² POSTGISviewingtools² Spatialindexing
Spatial DBMS: PostGIS
28SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² ConstructorfunctionsallowcreatingnewPOSTGISspatialobjects.² Buildnewobjectsfromrawdataininput² Startfromexistingdataandapplysome
transformation(e.g.decompose,slice,splice,dice).Ø ST_GeomFromTextàBuildgeometriesfromwellknowtextØ ST_GeomFromWKBàBuildgeometriesfromabinaryrepresentationØ ST_GeomFromGeoJSONàBuildgeometriesfromaGEOJSONformatØ ST_GeomFromKMLàBuildgeometriesfromaKMLformat
Spatial DBMS: PostGIS
29SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² ConstructorfunctionsallowcreatingnewPOSTGISspatialobjects.² Buildnewobjectsfromrawdataininput² Startfromexistingdataandapplysome
transformation(e.g.decompose,slice,splice,dice).
[1]Examplefrom:https://live.osgeo.org/archive/11.0/it/quickstart/postgis_quickstart.html
CREATETABLEcities(idint4primarykey,namevarchar(50),the_geomgeometry(POINT,4326));
INSERTINTOcities(id,the_geom,name)VALUES(1,ST_GeomFromText('POINT(-0.125751.508)',4326),'London,England');INSERTINTOcities(id,the_geom,name)VALUES(2,ST_GeomFromText('POINT(-81.23342.983)',4326),'London,Ontario');INSERTINTOcities(id,the_geom,name)VALUES(3,ST_GeomFromText('POINT(27.91162491-33.01529)',4326),'EastLondon,SA');
Spatial DBMS: PostGIS
30SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² ConstructorfunctionsallowcreatingnewPOSTGISspatialobjects
[1]Examplefrom:https://live.osgeo.org/archive/11.0/it/quickstart/postgis_quickstart.html
SELECT*FROMcities;id|name|the_geom----+-----------------+----------------------------------------------------1|London,England|0101000020E6100000BBB88D06F016C0BF1B2FDD2406C149402|London,Ontario|0101000020E6100000F4FDD478E94E54C0E7FBA9F1D27D45403|EastLondon,SA|0101000020E610000040AB064060E93B4059FAD005F58140C0(3rows)
BinarySpatialDatarepresentation
Spatial DBMS: PostGIS
31SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² ConstructorfunctionsallowcreatingnewPOSTGISspatialobjects
[1]Examplefrom:https://live.osgeo.org/archive/11.0/it/quickstart/postgis_quickstart.html
SELECTid,ST_AsText(the_geom),ST_AsEwkt(the_geom),ST_X(the_geom),ST_Y(the_geom)FROMcities;id|st_astext|st_asewkt|st_x|st_y----+------------------------------+----------------------------------------+-------------+-----------1|POINT(-0.125751.508)|SRID=4326;POINT(-0.125751.508)|-0.1257|51.5082|POINT(-81.23342.983)|SRID=4326;POINT(-81.23342.983)|-81.233|42.9833|POINT(27.91162491-33.01529)|SRID=4326;POINT(27.91162491-33.01529)|27.91162491|-33.01529(3rows)
Spatial DBMS: PostGIS
32SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGIScomponentsinthistutorial² SpatialDataTypes² Creatingnewgeometry/geographicdata² Geometryrelationshipsandgeo-queries² Importingandexportingspatialdata² POSTGISviewingtools² Spatialindexing
Spatial DBMS: PostGIS
33SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGISdistance-basedoperators
floatST_Distance(geometryg1,geometryg2);floatST_Distance(geographygg1,geographygg2);floatST_Distance_Sphere(geographygg1,geographygg2);floatST_Distance_Spheroid(geographygg1,geographygg2);
SELECTp1.name,p2.name,ST_Distance_Sphere(p1.the_geom,p2.the_geom)FROMcitiesASp1,citiesASp2WHEREp1.id>p2.id;name|name|st_distance_sphere-----------------+-----------------+--------------------London,Ontario|London,England|5875766.85191657EastLondon,SA|London,England|9789646.96784908EastLondon,SA|London,Ontario|13892160.9525778(3rows)
Spatial DBMS: PostGIS
34SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGISarea-basedoperators
floatST_Area(geometryg1);
SELECTST_AREA(R1.GEOM)/1000000,R1.DEN_REGFROMREGIONISCHEMA.REGIONIASR125393.8763609287|"Piemonte”3258.90668928528|"Valled'Aosta”23862.4108382986|"Lombardia"
Spatial DBMS: PostGIS
35SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGISbounding-boxoperators
Smallestrectangularboxwithedgesparalleltotheaxesofthecoordinateplanethatiscompletelyenclosingageometryobject.
² Arectangularboxiscompletelyspecifiedbythecoordinatesofthetwooppositecorners.
Spatial DBMS: PostGIS
36SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGISbounding-boxoperators
Spatial DBMS: PostGIS
37SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGISbounding-boxoperators
Codefromhttps://postgis.net/docs/geometry_overlaps.html
SELECTtbl1.column1,tbl2.column1,tbl1.column2&&tbl2.column2ASoverlapsFROM(VALUES
(1,'LINESTRING(00,33)'::geometry),(2,'LINESTRING(01,05)'::geometry))AStbl1,
(VALUES(3,'LINESTRING(12,46)'::geometry))AStbl2;
column1|column1|overlaps---------+---------+----------
1|3|t2|3|f
(2rows)
Spatial DBMS: PostGIS
38SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGISgeometryrelationshipsoperators
booleanST_Intersects(geometrygeomA,geometrygeomB);booleanST_Intersects(geographygeogA,geographygeogB);geometryST_Intersection(geometrygeomA,geometrygeomB);geographyST_Intersection(geographygeogA,geographygeogB);booleanST_Within(geometryA,geometryB);booleanST_Contains(geometryA,geometryB);booleanST_Overlaps(geometryA,geometryB);booleanST_Touches(geometryg1,geometryg2);booleanST_Equals(geometryA,geometryB);
Spatial DBMS: PostGIS
39SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGISgeometryrelationshipsoperators
SELECTST_Intersects('POINT(00)'::geometry,'LINESTRING(20,02)'::geometry);st_intersects---------------f(1row)SELECTST_Intersects('POINT(00)'::geometry,'LINESTRING(00,02)'::geometry);st_intersects---------------t(1row)
Codefromhttps://postgis.net/docs/ST_Intersects.html
Spatial DBMS: PostGIS
40SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGIScomponentsinthistutorial² SpatialDataTypes² Creatingnewgeometry/geographicdata² Geometryrelationshipsandgeo-queries² Importingandexportingspatialdata² POSTGISviewingtools² Spatialindexing
Spatial DBMS: PostGIS
41SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² POSTGISisabletoimportreal-worlddatathroughcommand-linetools(built-ininPOSTGISorfromexternalpackages).
Osm2pgsqlàcommand-linebasedprogramconvertingOpenStreetMapdatatoapostGIS-enabledPostgreSQLdatabase.
osm2pgsql--usernamepostgres--databasegis--port5432--hstorename.osm
² Key-valuestorewithinPostgres² Eachcolumnhasacolumnnamedtagsusingthehstoreengine
https://wiki.openstreetmap.org/wiki/Osm2pgsql
Spatial DBMS: PostGIS
42SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² POSTGISisabletoimportreal-worlddatathroughcommand-linetools(built-ininPOSTGISorfromexternalpackages).
Osm2pgsqlàcommand-linebasedprogramconvertingOpenStreetMapdatatoapostGIS-enabledPostgreSQLdatabase.
selectcount(*)FROMplanet_osm_pointwhere((tags->'man_made')='tower');count-------447
https://wiki.openstreetmap.org/wiki/Osm2pgsql
Spatial DBMS: PostGIS
43SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² POSTGISisabletooutputgeometriesandgeographiesinseveralstandardformats.
https://wiki.openstreetmap.org/wiki/Osm2pgsql
textST_AsKML(geometrygeom,integermaxdecimaldigits=15);textST_AsKML(geographygeog,integermaxdecimaldigits=15);textST_AsGeoJSON(geometrygeom,integermaxdecimaldigits=15,integeroptions=0);textST_AsGeoJSON(geographygeog,integermaxdecimaldigits=15,integeroptions=0);
textST_AsKML(geometrygeom,integermaxdecimaldigits=15);textST_AsKML(geographygeog,integermaxdecimaldigits=15);textST_AsGeoJSON(geometrygeom,integermaxdecimaldigits=15,integeroptions=0);textST_AsGeoJSON(geographygeog,integermaxdecimaldigits=15,integeroptions=0);
SELECTST_AsGeoJSON('LINESTRING(123,456)');st_asgeojson----------------------------------------------------------------------------------{"type":"LineString","coordinates":[[1,2,3],[4,5,6]]}
Spatial DBMS: PostGIS
44SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGIScomponentsinthistutorial² SpatialDataTypes² Creatingnewgeometry/geographicdata² Geometryrelationshipsandgeo-queries² Importingandexportingspatialdata² POSTGISviewingtools² Spatialindexing
Spatial DBMS: PostGIS
45SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² POSTGIScanbecoupledwithexternaltoolsallowinguserstoviewandanalyzespatialdatacontainedintheDB(e.g.outputofqueries).² QGIS² ArcGIS² OpenJUMP² Udig² GVSIG
Spatial DBMS: PostGIS
46SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² QGIS(https://www.qgis.org/it/site/)FreeandOpen-sourceGeographicInformationSystems
Spatial DBMS: PostGIS
47SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
POSTGIScomponentsinthistutorial² SpatialDataTypes² Creatingnewgeometry/geographicdata² Geometryrelationshipsandgeo-queries² Importingandexportingspatialdata² POSTGISviewingtools² Spatialindexing
Spatial DBMS: PostGIS
48SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
² Indexingspeedsupsearchingbyorganizingthedataintoasearchtreewhichcanbequickly.
² Withoutindexing,anysearchforafeaturewouldrequirea“sequentialscan”ofeveryrecordinthedatabase.
https://webdocs.cs.ualberta.ca/~holte/T26/b-trees.html
B-treeinRelationalDatabases
CREATEINDEXindex_nameONtable_name(column1_name,
column2_name);
Spatial DBMS: PostGIS
49SPATIALDATABASE:MODELINGANDIMPLEMENTATIONWITHPOSTGIS
MARCODIFELICE
R-treedatastructure
² Objectsarerepresentedthroughtheirminimumboundingrectangle.
² Aparentnodefullycontainstheboundingboxesofitschildnodes.
² Leafnodesdescribeasingleobject.
ENHANCEDSEARCHOPERATIONS² InputàSearchrectangle² Usetheboundingboxestodecidewhetheror
nottosearchinsideasubtree.
Spatial DBMS: PostGIS