Spatial Analysis and Modeling Database Fundaments Analysis and Modeling ... arc, and intersect will...
Transcript of Spatial Analysis and Modeling Database Fundaments Analysis and Modeling ... arc, and intersect will...
-
SpatialAnalysisandModeling(GIST4302/5302)
Guofeng CaoDepartmentofGeosciences
TexasTechUniversity
DatabaseFundaments
Review:BitsandBytes
Datastoredinacomputersystemismeasuredinbits eachbit recordsoneoftwopossiblestates
0(off,false) 1(on,true)
Bits areamalgamatedintobytes(8bits) Eachbyte representsasinglecharacter Acharactermaybeencodedusing7bits withanextrabit usedasasignofpositiveornegative
Question:CanIusebytetorepresenttheelevationoftheEverestinmeters?
Megabytes(2^20bytes)
Database
Adatabase isacollectionofdataorganizedinsuchawaythatacomputercanefficientlystoreandretrievedata Arepositoryofdatathatislogicallyrelated
Adatabaseiscreatedandmaintainedusingageneralpurposepieceofsoftwarecalledadatabasemanagementsystem(DBMS)
-
CommonDatabaseApplications
Home/officedatabase Simpleapplications(e.g.,restaurantmenus)
Commercialdatabase Storetheinformationforbusinesses(e.g.customers,employees)
Engineeringdatabase Usedtostoreengineeringdesigns(e.g.CAD)
Imageandmultimediadatabase Storeimage,audio,videodata
Geodatabase/spatialdatabase Storeacombinationofspatialandnonspatialdata
TheRelationalModel Therelationalmodelisoneofthemostcommonlyusedarchitectureindatabase Arelationaldatabase isacollectionofrelations,oftenjustcalledtables
Eachrelationhasasetofattributes Thedataintherelationisstructuredasasetofrows,oftencalledtuples
Eachtupleconsistsofdataitemsforeachattribute Eachcell inatuplecontainsasinglevalue Arelationaldatabasemanagementsystem(RDBMS)isthesoftwarethatmanagesarelationaldatabase
AnExampleRelation
Relation Attribute
TupleDataitem
Relations Arelation isbasicallyatable Arelationschemeisthesetofattributenamesandthedomain
(datatype)foreachattributename Adatabasescheme isasetofrelationschemes Inarelation:
Eachtuplecontainsasmanyvaluesasthereareattributesintherelationscheme
Eachdataitemisdrawnfromthedomainforitsattribute Theorderoftuplesisnotsignificant Tuplesinarelationarealldistinctfromeachother
Thedegree ofarelationisitsnumberofcolumns Thecardinality ofarelationisthenumberoftuples
-
RelationScheme Acandidatekey isanattributeorminimalsetofattributesthatwilluniquelyidentifyeachtupleinarelation
Onecandidatekeyisusuallychoseasaprimarykey
OperationsonRelations
Fundamentalrelationaloperators: Union,intersection,difference,productandrestrict:usualsetoperations,butrequirebothoperandshavethesameschema
Selection:pickingcertainrows Projection:pickingcertaincolumns Join:compositionsofrelations
Together,theseoperationsandthewaytheyarecombinediscalledrelationalalgebra combined: Analgebrawhoseoperandsarerelationsorvariablesthatrepresentrelations
ProjectOperator Theproject operatorisunary
Itoutputsanewrelationthathasasubsetofattributes
Identicaltuplesintheoutputrelationarecoalesced
Relation Sells:bar beer priceChimys Bud 2.50Chimys Miller 2.75Crickets Bud 2.50Crickets Miller 3.00
Prices := PROJbeer,price(Sells):beer priceBud 2.50Miller 2.75Miller 3.00
SelectOperator
Theselectoperatorisunary Itoutputsanewrelationthathasasubsetoftuples Aconditionspecifiesthosetuplesthatarerequired
Relation Sells:bar beer priceChimys Bud 2.50Chimys Miller 2.75Crickets Bud 2.50Crickets Miller 3.00
ChimyMenu := SELECTbar=Chimys(Sells):bar beer priceChimys Bud 2.50Chimys Miller 2.75
-
JoinOperator
Thejoin operatorisbinary Itoutputsthecombinedrelationwheretuplesagreeonaspecified
attribute(naturaljoin)Sells(bar, beer, price ) Bars(bar, address)
Chimys Bud 2.50 Chimys 2417 Broadway St.Chimys Miller 2.75 Cricekts 2412 Broadway St.Crickets Bud 2.50Crickets Coors 3.00
BarInfo := Sells JOIN BarsNote Bars.name has become Bars.bar to make the naturaljoin work.
BarInfo(bar, beer, price, address )
Chimys Bud 2.50 2417 Broadway St.Chimys Milller 2.75 2417 Broadway St.Crickets Bud 2.50 2412 Broadway St.Crickets Coors 3.00 2412 Broadway St.
JoinOperator
Joinisthemosttimeconsumingofallrelationaloperatorstocompute Ingeneral,relationaloperatorsmaynotbearbitrarilyreordered(leftjoin,rightjoin)
Queryoptimizationaimstofindanefficientwayofprocessingqueries,forexamplereorderingtoproduceequivalentbutmoreefficientqueries
ComplexRelationalOperatorExample
HowtofindthelocationsthatsellBud?Sells(bar, beer, price ) Bars(bar, address)
Chimys Bud 2.50 Chimys 2417 Broadway St.Chimys Miller 2.75 Cricekts 2412 Broadway St.Crickets Bud 2.50Crickets Coors 3.00
Step 2 BarInfo(beer, address )
Bud 2417 Broadway St.Milller 2417 Broadway St.Bud 2412 Broadway St.Coors 2412 Broadway St.
Step 1 BarInfo(bar, beer, price, address )
Chimys Bud 2.50 2417 Broadway St.Chimys Milller 2.75 2417 Broadway St.Crickets Bud 2.50 2412 Broadway St.Crickets Coors 3.00 2412 Broadway St.
SQLinOneSlide StructuredQueryLanguage Thestandardforrelationaldatabasemanagementsystems(RDBMS)
Example:
Select * from Sells where bar=Chimys Select * from Sells where bar=Chimys orderby price
asc
Relation Sells:bar beer priceChimys Bud 2.50Chimys Miller 2.75Crickets Bud 2.50Crickets Miller 3.00
ChimyMenu := SELECTbar=Chimys(Sells):bar beer priceChimys Bud 2.50Chimys Miller 2.75
-
RelationalDatabasesandSpatialdata
Severalissuespreventunmodifieddatabasesbeingusefulforspatialdata Structureofspatialdatadoesnotnaturallyfitwithtables Performanceisimpairedbytheneedtoperformmultiplejoinswith
spatialdata Indexesarenonspatialinaconventionalrelationaldatabase
AnextensibleRDBMSofferssomesolutionstotheseproblemswith userdefineddatatypes userdefinedoperations userdefinedindexesandaccessmethods activedatabasefunctions(e.g.,triggers)
RepresentationofSpatialData
RepresentationofSpatialDataModels
Objectbasedmodel: treatsthespaceaspopulatedbydiscrete,identifiableentitieseachwithageospatialreference Buildingsorroadsfitintothisview GISSoftwares:ArcGIS
Fieldbasedmodel: treatsgeographicinformationascollectionsofspatialdistributions Distributionmaybeformalizedasamathematicalfunctionfromaspatial
frameworktoanattributedomain Patternsoftopographicaltitudes,rainfall,andtemperaturefitneatlyinto
thisview. GISSoftware:Grass
-
RelationalModels Tuplesrecordingannualweatherconditionsatdifferentlocations
The field-based and object-based approaches are attempts to impose structure and pattern on such data.
ObjectbasedApproach Clumpsarelationassingleorgroupsoftuples
Certaingroupsofmeasurementsofclimaticvariablescanbegroupedtogetherintoafinitesetoftypes
ObjectbasedExample
-
Fieldbasedapproach
Treatsinformationasacollectionoffields Eachfield definesthespatialvariationofanattributeasafunctionfromthesetoflocationstoanattributedomain
ObjectbasedApproach
Entity
Objectbasedmodelsdecomposeaninformationspaceintoobjectsorentities
Anentitymustbe: Identifiable Relevant(beofinterest) Describable(havecharacteristics)
Theframeofspatialreferenceisprovidedbytheentitiesthemselves
-
Example:Houseobject
Hasseveralattributes,suchasregistrationdate,address,ownerandboundary,whicharethemselvesobjects
Example:GISanalysis ForItalyscapitalcity,Rome,calculatethetotallengthoftheRiverTiberwhichlieswithin2.5kmoftheColosseum FirstweneedtomodeltherelevantpartsofRomeasobjects
Operationlength willactonarc,andintersect willapplytoformthepieceofthearc incommonwiththedisc
Example:GISanalysisAprocessofdiscretizationmustconverttheobjectstotypesthatarecomputationallytractable
Acirclemayberepresentedasadiscretepolygonalarea,arcsbychainsoflinesegments,andpointsmaybeembeddedinsomediscretespace
PrimitiveObjects
EuclideanSpace:coordinatized modelofspace Transformsspatialpropertiesintopropertiesoftuplesofrealnumbers
Coordinateframeconsistsofafixed,distinguishedpoint(origin)andapairoforthogonallines(axes),intersectingintheorigin
Pointobjects Lineobjects Polygonalobjects
-
Polygonalobjects Convexity
Visibilitybetweenpointsx,y,andz
Example:Triangulation
Everysimplepolygonhasatriangulation.Anytriangulationofasimplepolygonwithnverticesconsistsofexactlyn 2triangles
ArtGalleryProblem Howmanycamerasareneededtoguardagalleryandhowshouldtheybe
placed? UpperboundN/3
Related:ConvexHull
-
Related:Voronoi Diagram Voronoi DiagramonRoadNetwork
JohnSnow,PumpsandCholeraOutbreak
-
PrimitiveGISOperations inEuclideanspaces
Length,bearing,area Howmanywaysyoucanthinkoftocalculatetheareaofapolygon? Howtotestwhichsideofapointcorrespondingtoaline?
Distancebetweenobjects(points,lines,polygons) Distancecouldbeambiguous,e.g.,whatisthedifferencefromLubbocktoDallas(from
citycenterorcityboundary?). Centroid
Notnecessarilywithinintheboundaryofpolygon Pointinpolygon
Raycastingmethod Pointonline
area Buffer Intersection/overlay
Intopologicalspaces Spatialrelations(within,touch,cover,)
Areaofasimplepolygon
Notethattheareamaybepositiveornegative Infact,area(pqr)=area(qpr) Ifp istotheleftofqr thentheareaispositive,ifp istotherightofqr thentheareaisnegative
Pointinpolygon Determiningwhetherapointisinsideapolygonisoneof
themostfundamentaloperationsinaspatialdatabase Semilinemethod(raycasting):checksforoddoreven
numbersofintersectionsofasemilinewithpolygon Windingmethod:sumsbearingsfrompointtopolygon
vertices
-
PrimitiveGISoperations:Overlay
Union Intersect Erase Identity Update SpatialJoin SymmetricalDifference
Overlay
Union Computesageometricunionoftheinputfeatures.Allfeaturesandtheirattributeswillbewrittentotheoutputfeatureclass.
Overlay
Intersect Computesageometricintersectionoftheinputfeatures.Featuresorportionsoffeatureswhichoverlapinalllayersand/orfeatureclasseswillbewrittentotheoutputfeatureclass.
-
Overlay
Erase CreatesafeatureclassbyoverlayingtheInputFeatureswiththepolygonsoftheEraseFeatures.Onlythoseportionsoftheinputfeaturesfallingoutsidetheerasefeaturesoutsideboundariesarecopiedtotheoutputfeatureclass
Overlay
Identity Computesageometricintersectionoftheinputfeaturesandidentityfeatures.Theinputfeaturesorportionsthereofthatoverlapidentityfeatureswillgettheattributesofthoseidentityfeatures
Overlay
Update ComputesageometricintersectionoftheInputFeaturesandUpdateFeatures.Theattributesandgeometryoftheinputfeaturesareupdatedbytheupdatefeaturesintheoutputfeatureclass.
Overlay
Symmetricaldifference Featuresorportionsoffeaturesintheinputandupdatefeaturesthatdonotoverlapwillbewrittentotheoutputfeatureclass.
-
Overlay Spatialjoin
Joinsattributesfromonefeaturetoanotherbasedonthespatialrelationship.Thetargetfeaturesandthejoinedattributesfromthejoinfeaturesarewrittentotheoutputfeatureclass.
QuizInputFeature OverlayFeature
Whichofthefollowingistheresultofidentity,intersect,symmetricaldifference,unionandupdaterespectively?
A B C D E
Buffer
Primitiveoperators youmightalreadyrealizedthattheseprimitiveoperatorsareoftenusedcollaborativelywitheachother,andotheranalyticalmethods(e.g.,dissolve,surfaceanalysis,interpolation)thatwewillintroduceinthecominglectures.
-
Topologicalspatialoperations:spatialrelationship
Objecttypeswithanassumedunderlyingtopologyarepoint,arc,loop andarea
Operations: boundary,interior,closure andconnected aredefinedintheusualmanner
components returnsthesetofmaximalconnectedcomponentsofanarea
extremes actsoneachobjectoftypearcandreturnsthepairofpointsofthearcthatconstituteitsendpoints
iswithin providesarelationshipbetweenapointandasimpleloop,returningtrueifthepointisenclosedbytheloop
TopologicalspatialoperationsforareasXmeets Y ifX andYtouchexternallyinacommonportionoftheirboundaries
X overlaps Y ifX andYimpingeintoeachothersinteriors
Topologicalspatialoperationsforareas
X isinside Y ifX isasubsetofYandX,Y donotshareacommonportionofboundary
X covers Y ifY isasubsetofX andX,Y touchexternallyinacommonportionoftheirboundaries
Topologicalspatialoperations Thereareaninfinitenumberofpossibletopologicalrelationshipsthatareavailablebetweenobjectsoftypecell
-
http://resources.esri.com/help/9.3/ArcGISDesktop/com/Gp_ToolRef/Data_Management_toolbox/select_by_location_colon_graphical_examples.htm
ContainvsCONTAINS_CLEMENTINI: theresultsofCONTAINS_CLEMENTINIwillbeidenticaltoCONTAINSwiththeexceptionthatifthefeatureintheSelectingFeatureslayerisentirelyontheboundaryoftheInputFeatureLayer,withnopartofthecontainedfeatureproperlyinsidethefeatureintheInputFeatureLayer,theinputfeaturewillnotbeselected.
Spaghetti
Spaghettidatastructurerepresentsaplanarconfigurationofpoints,arcs,andareas
Geometryisrepresentedasasetoflistsofstraightlinesegments
Spaghetti example
Eachpolygonalareaisrepresentedbyitsboundaryloop
Eachloopisdiscretizedasaclosedpolyline Eachpolylineisrepresentedasalistofpoints
A:[1,2,3,4,21,22,23,26,27,28,20,19,18,17]B:[4,5,6,7,8,25,24,23,22,21]C:[8,9,10,11,12,13,29,28,27,26,23,24,25]D:[17,18,19,20,28,29,13,14,15,16]
-
Issues
ThereisNO explicitrepresentationofthetopologicalinterrelationshipsoftheconfiguration,suchasadjacency
Dataconsistenceissues Silverpolygons Dataredundancy
NAA:nodearcarea
Eachdirectedarchasexactlyonestartandoneendnode.
Eachnodemustbethestartnodeorendnode(maybeboth)ofatleastonedirectedarc.
Eachareaisboundedbyoneormoredirectedarcs. Directedarcsmayintersectonlyattheirendnodes. Eachdirectedarchasexactlyoneareaonitsrightandoneareaonitsleft.
Eachareamustbetheleftareaorrightarea(maybeboth)ofatleastonedirectedarc.
NAA:planardecompositionArc Begin End Left Right
a 1 2 A X
b 4 1 B X
c 3 4 C X
d 2 3 D X
e 5 1 A B
f 4 5 C B
g 6 2 D A
h 5 6 C A
i 3 6 D C
FieldbasedApproach
-
Spatialfields IfthespatialframeworkisaEuclideanplaneandtheattributedomainisasubsetofthesetofrealnumbers; TheEuclideanplaneplaystheroleofthehorizontalxyplane Thespatialfield valuesgivethezcoordinates,orheightsabove
theplane
Imagine placing a square grid over a region and measuring aspects of the climate at each node of the grid. Different fields would then associate locations with values from each of the measured attribute domains.
RegionalClimateVariations
Propertiesoftheattributedomain Theattributedomainmaycontainvalueswhichare
commonlyclassifiedintofourlevelsofmeasurement Nominalattribute:simplelabels;qualitative;cannotbe
ordered;andarithmeticoperatorsarenotpermissible Ordinalattribute:orderedlabels;qualitative;andcannotbe
subjectedtoarithmeticoperators,apartfromordering Intervalattributes:quantitiesonascalewithoutanyfixed
point;canbecomparedforsize,withthemagnitudeofthedifferencebeingmeaningful;theratiooftwointervalattributesvaluesisnotmeaningful
Ratioattributes:quantitiesonascalewithrespecttoafixedpoint;cansupportawiderangeofarithmeticaloperations,includingaddition,subtraction,multiplication,anddivision
Continuousanddifferentiablefields
Continuous field:smallchangesinlocationleadstosmallchangesinthecorrespondingattributevalue
Differentiable field:rateofchange(slope)isdefinedeverywhere
Spatialframeworkandattributedomainmustbecontinuousforboththesetypesoffields
Everydifferentiablefieldmustalsobecontinuous,butnoteverycontinuousfieldisdifferentiable
Onedimensionalexamples Fieldsmaybeplottedasagraphofattributevalueagainstspatialframework
Continuous and differentiable; the slope of the curve can be defined at every point
-
OnedimensionalexamplesThe field is continuous (the graph is connected) but not
everywhere differentiable. There is an ambiguity in the slope, with two choices at the articulation point between the two
straight line segments.
Continuous and not differentiable; the slope of the curve cannot be defined at one or more points
OnedimensionalexamplesThe graph is not connected and so the field in not continuous
and not differentiable.
Not continuous and not differentiable
Twodimensionalexamples
Theslopeisdependentontheparticularlocationandonthebearingatthatlocation
Isotropicfields Afieldwhosepropertiesareindependentofdirectioniscalledanisotropicfield
Considertraveltimeinaspatialframework ThetimefromXtoanypointYisdependentonlyuponthedistancebetweenXandYandindependentofthebearingofYfromX
-
Anisotropicfields Afieldwhosepropertiesaredependentondirectioniscalledananisotropicfield.
SupposethereisahighspeedlinkAB ForpointsnearB itwouldbebetter,iftravelingfromX, totraveltoA,takethelink,andcontinueonfromB tothedestination
Thedirectiontothedestinationisimportant
Spatialautocorrelation
SpatialautocorrelationisaquantitativeexpressionofToblersfirstlawofgeography(1970) Everythingisrelatedtoeverythingelse,butnearthingsaremore
relatedthandistantthing Spatialautocorrelationmeasuresthedegreeofclusteringofvaluesin
aspatialfield
Alsotermedasspatialdependency,spatialpattern,spatialcontext,spatialsimilarity,spatialdissimilarity
Autocorrelation
Ifthereisnoapparentrelationshipbetweenattributevalueandlocationthenthereiszerospatialautocorrelation
Iflikevaluestendtobelocatedawayfromeachother,thenthereisnegativespatialautocorrelation
If like values tend to cluster together, then the field exhibits high positive spatial autocorrelation
RepresentationsofSpatialFields
Points Contours Raster/Lattice Triangulation(DelaunayTrangulation)
-
Example
Contourlinesandraster
Example
Trangulations
SideNote:DelaunayTriangulationandVoronoi Diagram
DualGraph
Operationsonfields
Afieldoperationtakesasinputoneormorefieldsandreturnsaresultantfield
Thesystemofpossibleoperationsonfieldsinafieldbasedmodelisreferredtoasmapalgebra
Threemainclassesofoperations Local Focal Zonal
-
Neighborhoodfunction GivenaspatialframeworkF,aneighborhoodfunction
n isafunctionthatassociateswitheachlocationx asetoflocationsthatareneartox
Localoperations Localoperation:actsupononeormorespatialfieldstoproduceanewfield
Thevalueofthenewfieldatanylocationisdependentonthevaluesoftheinputfieldfunctionatthatlocation isanybinaryoperation
Focaloperations Focaloperation:the
attributevaluederivedatalocationxmaydependontheattributesoftheinputspatialfieldfunctionsatxandtheattributesofthesefunctionsintheneighborhoodn(x)ofx
Zonaloperations Zonaloperation:aggregatesvaluesofafieldoverasetofzones(arisingingeneralfromanotherfieldfunction)inthespatialframework
Foreachlocationx:FindtheZoneZi inwhichxiscontainedComputethevaluesofthefieldfunctionfappliedtoeachpointinZiDeriveasinglevalue(x)ofthenewfieldfromthevaluescomputedinstep2
-
Summary:Objectbasedvs Fieldbasedmodels
Objectbasedmodels: Greaterprecision Lessredundantinformation(smallerstoragefootprints)
Complexdatastructures Fieldbasedmodels:
Simplerdatastructures Moreredundantinformation(largerstoragefootprints)
Lessprecision Rasterisfaster,butvectoriscorrector
Endofthistopic