SlideShare a Scribd company logo
Peter Horsbøll Møller
Senior Systems Engineer
Pitney Bowes Software
The Power of Spatial SQL in MapInfo Professional
Peter Horsbøll Møller
Senior Systems Engineer
June 15, 2012
Every connection is a new opportunity™
Workshop agenda
• In this workshop we will play around with the spatial SQL
capabilties of MapInfo Professional
• We will look at joining tables based on the spatial objects
• We will calculate size of parts of the spatial objects
• We will extract and insert parts into new tables
3
SQL Select
• Columns, expressions
• Tables
• Conditions
4
Joining via the spatial object
• Select the two tables
– Object will come from
first table
• Specify spatial
condition:
– Contains
– Within
– Intersects
– Partly Within
– Contains Part
– Entirely Within
– Contains Entire
5
Contains / Within
• Comparing the
Centroid!
• Order does matter
• Good with points
• A Contains C
• A Contains D
• B Contain A
• C Contains D
• C Within A
• D Within A
• B Within A
• D Within C
6
Intersects / Partly Within / Contains Part
• Comparing the entire
object!
• Order doesn’t matter
• A Contains Part B
• A Contains Part C
• A Contains Part D
• B Contain Part A
• B Contains Part C
• C Contains Part A
• C Contains Part B
• C Contains Part D
• D Contains Part A
• D Contains Part C
7
Contains Entire / Entirely Within
• Comparing the entire
object!
• Order does matter
• A Contains Entire D
• C Contains Entire D
• D Entirely Within A
• D Entirely Within C
8
Spatial operators
• Within/Contains
– Very fast
– Inprecise when working with other objects than points
• Intersects/Partly Within/Contains Part
– Slower then Within/Contains
– Should be used when comparing lines/polylines and regions
• Entirely Within/Contains Entire
– Slower then Within/Contains
– To be used if one object should be ”entirely within” the other
9
Specifying columns
• Pick the columns from
the ”Columns” list
• Create expressions
using the ”Functions”
list or type in some
functions manually
• Use aliases (”some
new name”) for
expressions
10
Exercise
• Join the two tables Cadastre and Urban_Area
• Join them using the Intersects operator
• Select these columns
– CADASTRE.AREA_NAME
– CADASTRE.LOT_NO
– URBAN_AREAS.NAME
• Add these functions and aliases:
– CartesianArea(CADASTRE.OBJ, "sq m") "Area_Cadastre”
– CartesianArea(URBAN_AREAS.OBJ, "sq m") "Area_UrbanArea"
11
Adding a overlap tolerance
• Overlap(obj1, obj2):
– Creates an object where
the two objects have a
common ”area”
• MapInfo Pro will create
this object and calculate
the area of it
• If this area is larger then
10 sq m, the intersection
will be used
12
Calculating area overlap
There are a number of ways to calculate the size of the
overlapping area:
• CartesianArea(Overlap(obj, obj), units)
– Uses the defined units
– Should be used for projected data (non Longitude/Latitude data)
• SpericalArea(Overlap(obj, obj), units)
– Uses the defined units
– Should be used for Longitude/Latitude data
• AreaOverlap(obj, obj)
– Uses the current units in MapInfo Professional
– Uses the SpericalArea calculation
13
Exercise
• Add a overlap tolerance by adding this to the condition:
– CartesianArea(Overlap(Cadastre.obj, Urban_Areas.obj), "sq m") >
10
• Try different tolerances
• How do you change the unit used?
14
Extracting spatial data
• By default MapInfo Professional takes the spatial object
from the first table in your query
• You can however add ”more” spatial objects to your
query thru the ”Column” field
• To see these extra columns you need to insert the result
into a new/another table
15
Adding an extra spatial column
• Add your extra spatial
object, can be an
expression
• Consider using an alias
• Note that the result still
will highlight the entire
area from the first table
16
Creating a new table
• You can consider
using the structure
from your first table
and just modify it to
match the columns in
your query
17
Inserting the query
• You need to do this thru the MapBasic window
• Show the MapBasic Window from the Options menu
• Write this:
Insert Into OverlapResult (AREA_NAME, LOT_NO, NAME, OBJ)
Select AREA_NAME, LOT_NO, NAME, OverlapObj From Query1
• Where
– OverlapResult is your new table
– OverlapObj is your spatial column alias
– Query1 is the name of yoru query
• And hit enter
• Make sure your new table hasn’t been added to the map as
that will slow it down – a lot!
18
Final result
19
Exercise
• Add a spatial column to your result
• Create a new table
• Insert the result into this new table using this:
Insert Into OverlapResult (AREA_NAME, LOT_NO, NAME, OBJ)
Select AREA_NAME, LOT_NO, NAME, OverlapObj From Query3
20
Regions and lines/polylines
• Works just like regions
and regions
• Note that Overlap uses
the style from the first
object
21
Exercise
• Find the roads that intersects the urban areas
• Use these columns from the roads:
– ROADNAME
– ROUTE_NO
– ID
• And this column from the urban areas
– NAME
• Extract only the part of the road within the urban area
• Create a new table
• Insert the result into this new table
Insert Into UrbanRoads (ROADNAME,ROUTE_NO,ID,NAME, OBJ)
Select ROADNAME,ROUTE_NO,ID,NAME, LineOverlap From Query1
22
Adding multiple spatial columns
• The SQL statement can include several spatial columns
23
Select Cadastre.LOT_NO
, Cadastre.AREA_NAME
, Cadastre.obj "CObj"
, Urban_Areas.obj "UObj"
, Overlap(Cadastre.obj
, Urban_Areas.obj) "JOBJ"
From Cadastre, Urban_Areas
Where Cadastre.Obj Intersects
Urban_Areas.Obj
into Selection
Extracting multiple spatial objects
• You need MapBasic to get to these ”many” spatial
columns
• They could be inserted into the cosmetic layer in this
way:
Fetch First From Selection
Dim oTemp As Object
oTemp = selection.UObj
Insert Into WindowInfo(FrontWindow(), 10) (OBJ) Values (oTemp)
24
Exercise
• Select multiple spatial columns
• Insert a few of the selected spatial data into the cosmetic
layer of a map window
25
Some other spatial function
• Overlap()
• Erase()
• Combine()
• IntersectNodes()
• ExtractNodes()
• MBR()
• Centroid()
• CreatePoint()
• CreateLine()
• Buffer() (Cart/Sper)
• Offset() (Cart/Sper)
• OffsetXY() (Cart/Sper)
• Rotate()
• RotateAtPoint()
26
Thank You
Peter Horsbøll Møller
peter.moller@pb.com

More Related Content

PPTX
공간정보아카데미 - 오픈소스GIS 분석가과정 - QGIS 공간분석일반
PPTX
Using MapBasic to modify your user interface
PPTX
Introduction to Spring & Spring BootFramework
PDF
오픈소스 GIS 실습 (2)
PPTX
공간정보아카데미 - Day1 오픈소스개발 일반
PPT
Curating learning resources w links final
PPTX
JShell: An Interactive Shell for the Java Platform
PDF
Excel 2010 Unit A PPT
공간정보아카데미 - 오픈소스GIS 분석가과정 - QGIS 공간분석일반
Using MapBasic to modify your user interface
Introduction to Spring & Spring BootFramework
오픈소스 GIS 실습 (2)
공간정보아카데미 - Day1 오픈소스개발 일반
Curating learning resources w links final
JShell: An Interactive Shell for the Java Platform
Excel 2010 Unit A PPT

What's hot (20)

PPT
Charts in EXCEL
PDF
Visual Studio를 이용한 어셈블리어 학습 part 1
PPT
Excel formulas tf-jul1605
PPTX
Ms excel AND EXCEL CHARTS
PPTX
Linked list
PDF
지리정보체계(GIS) - [1] GIS 데이터 유형, 구조 알기
PDF
JavaScript Engine
PPTX
공간정보연구원 PostGIS 강의교재
PPTX
LX 공간정보아카데미 PostGIS 강의자료
PDF
[QGIS] 수치지도를 이용한 DEM 생성과 지형분석
PPTX
Lecture 6 disjoint set
PDF
FUSE (Filesystem in Userspace) on OpenSolaris
PPTX
Chapter 1
DOCX
Visual basic concepts
PDF
[FOSS4G Korea 2021]Workshop-QGIS-TIPS-20211028
PPT
GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현
PPTX
Debugging
PPTX
Animation in the web
PPTX
Introduction to database & sql
PDF
6 QGIS layout
Charts in EXCEL
Visual Studio를 이용한 어셈블리어 학습 part 1
Excel formulas tf-jul1605
Ms excel AND EXCEL CHARTS
Linked list
지리정보체계(GIS) - [1] GIS 데이터 유형, 구조 알기
JavaScript Engine
공간정보연구원 PostGIS 강의교재
LX 공간정보아카데미 PostGIS 강의자료
[QGIS] 수치지도를 이용한 DEM 생성과 지형분석
Lecture 6 disjoint set
FUSE (Filesystem in Userspace) on OpenSolaris
Chapter 1
Visual basic concepts
[FOSS4G Korea 2021]Workshop-QGIS-TIPS-20211028
GeoTools와 GeoServer를 이용한 KOPSS Open API의 구현
Debugging
Animation in the web
Introduction to database & sql
6 QGIS layout
Ad

Viewers also liked (8)

PDF
3D-printing with GRASS GIS – a work in progress in report FOSS4G 2014
PPT
Advanced SQL Selects
PPTX
MAPINFO PROJECT
PPTX
Introduction to mapinfo
PPT
Taking Advantage of a Spatial Database with MapInfo Professional
PPTX
MapInfo Professional 12.0 and SQL Server 2008
PPTX
MapInfo Pro og SQL Server - Uden opgaver
PDF
Mapinfo
3D-printing with GRASS GIS – a work in progress in report FOSS4G 2014
Advanced SQL Selects
MAPINFO PROJECT
Introduction to mapinfo
Taking Advantage of a Spatial Database with MapInfo Professional
MapInfo Professional 12.0 and SQL Server 2008
MapInfo Pro og SQL Server - Uden opgaver
Mapinfo
Ad

Similar to The power of spatial SQL in MapInfo Professional (20)

PDF
Doing more with SQL
PPTX
Review presentation for Orientation 2014
PDF
A Whirlwind Tour of Spatial Joins
PPT
Building a Spatial Database in PostgreSQL
PDF
(eBook PDF) Introduction to Geographic Information Systems 8th
PPTX
Seminar on gis analysis functions
PPT
Where2.0Now - Finding the heat in Thematic Maps
PDF
QGIS training class 1
PPT
GIS_Whirlwind_Tour.ppt
PPT
GIS_Whirlwind_Tour.ppt
PPT
GIS_Whirlwind_Tour.ppt
PPT
GIS_Whirlwind_Tour.ppt
PPT
Building a Spatial Database in PostgreSQL
PPTX
GIS Ppt 5.pptx: SPACIAL DATA ANALSYSISIS
PPTX
Spatial Data Analysis .pptx by Ms. Kritiza Sharma
PPTX
Introduction to mapinfo
PPT
Arcgis training day_1
PDF
Building A Spatial Database In Postgresql (Ppt).pdf
PDF
ArcGIS 10.1 for Desktop Functionality Matrix poster
PPTX
TYBSC IT PGIS Unit II Chapter I Data Management and Processing Systems
Doing more with SQL
Review presentation for Orientation 2014
A Whirlwind Tour of Spatial Joins
Building a Spatial Database in PostgreSQL
(eBook PDF) Introduction to Geographic Information Systems 8th
Seminar on gis analysis functions
Where2.0Now - Finding the heat in Thematic Maps
QGIS training class 1
GIS_Whirlwind_Tour.ppt
GIS_Whirlwind_Tour.ppt
GIS_Whirlwind_Tour.ppt
GIS_Whirlwind_Tour.ppt
Building a Spatial Database in PostgreSQL
GIS Ppt 5.pptx: SPACIAL DATA ANALSYSISIS
Spatial Data Analysis .pptx by Ms. Kritiza Sharma
Introduction to mapinfo
Arcgis training day_1
Building A Spatial Database In Postgresql (Ppt).pdf
ArcGIS 10.1 for Desktop Functionality Matrix poster
TYBSC IT PGIS Unit II Chapter I Data Management and Processing Systems

More from Peter Horsbøll Møller (20)

PDF
Using Precisely Locate API Services in MapInfo Pro
PDF
MapInfo Pro v12.5 to v2021.1 Overview
PDF
MapInfo Pro Tips & Tricks med Geograf
PDF
Introduction to MapBasic
PDF
Precisely MapInfo Pro v2019 and Roadmap
PDF
Be Location Intelligent with MapInfo Pro v2019
PPTX
MapInfo Pro v2019: Improving the Way You Query
PPTX
Eksklusivsmagning - 10 års jubilæum, Oksenvad Whiskylaug
PPTX
Llinking Spectrum dataflows to MapInfo Pro
PPTX
Clynelish - Oksenvad Whiskylaug
PPTX
Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
PPT
MapInfo Discover 3D: From 2D to 3D
PPTX
Whiskysmagning: Samaroli
PPTX
Using Spectrum on Demand from MapInfo Pro
PPTX
Hvad sker der hos Pitney Bowes
PPTX
MapInfo Discover 2015.2 64 bit
PPTX
MapInfo Pro 64 bit og MapInfo Pro Advanced 64 bit
PPTX
MapInfo Pro Raster og de danske højdedata
PPTX
64 bits of MapInfo Pro - Danish version
PPTX
Blend, Single Grain og Single Malt Whisky
Using Precisely Locate API Services in MapInfo Pro
MapInfo Pro v12.5 to v2021.1 Overview
MapInfo Pro Tips & Tricks med Geograf
Introduction to MapBasic
Precisely MapInfo Pro v2019 and Roadmap
Be Location Intelligent with MapInfo Pro v2019
MapInfo Pro v2019: Improving the Way You Query
Eksklusivsmagning - 10 års jubilæum, Oksenvad Whiskylaug
Llinking Spectrum dataflows to MapInfo Pro
Clynelish - Oksenvad Whiskylaug
Getting Started with the Ribbon library - MUGUKI User Group Meeting 2016
MapInfo Discover 3D: From 2D to 3D
Whiskysmagning: Samaroli
Using Spectrum on Demand from MapInfo Pro
Hvad sker der hos Pitney Bowes
MapInfo Discover 2015.2 64 bit
MapInfo Pro 64 bit og MapInfo Pro Advanced 64 bit
MapInfo Pro Raster og de danske højdedata
64 bits of MapInfo Pro - Danish version
Blend, Single Grain og Single Malt Whisky

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
August Patch Tuesday
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
project resource management chapter-09.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Mushroom cultivation and it's methods.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
1 - Historical Antecedents, Social Consideration.pdf
Programs and apps: productivity, graphics, security and other tools
MIND Revenue Release Quarter 2 2025 Press Release
August Patch Tuesday
Enhancing emotion recognition model for a student engagement use case through...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Assigned Numbers - 2025 - Bluetooth® Document
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
TLE Review Electricity (Electricity).pptx
OMC Textile Division Presentation 2021.pptx
project resource management chapter-09.pdf
Hindi spoken digit analysis for native and non-native speakers
Mushroom cultivation and it's methods.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
DP Operators-handbook-extract for the Mautical Institute
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
A comparative study of natural language inference in Swahili using monolingua...
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
A Presentation on Artificial Intelligence
1 - Historical Antecedents, Social Consideration.pdf

The power of spatial SQL in MapInfo Professional

  • 1. Peter Horsbøll Møller Senior Systems Engineer Pitney Bowes Software
  • 2. The Power of Spatial SQL in MapInfo Professional Peter Horsbøll Møller Senior Systems Engineer June 15, 2012 Every connection is a new opportunity™
  • 3. Workshop agenda • In this workshop we will play around with the spatial SQL capabilties of MapInfo Professional • We will look at joining tables based on the spatial objects • We will calculate size of parts of the spatial objects • We will extract and insert parts into new tables 3
  • 4. SQL Select • Columns, expressions • Tables • Conditions 4
  • 5. Joining via the spatial object • Select the two tables – Object will come from first table • Specify spatial condition: – Contains – Within – Intersects – Partly Within – Contains Part – Entirely Within – Contains Entire 5
  • 6. Contains / Within • Comparing the Centroid! • Order does matter • Good with points • A Contains C • A Contains D • B Contain A • C Contains D • C Within A • D Within A • B Within A • D Within C 6
  • 7. Intersects / Partly Within / Contains Part • Comparing the entire object! • Order doesn’t matter • A Contains Part B • A Contains Part C • A Contains Part D • B Contain Part A • B Contains Part C • C Contains Part A • C Contains Part B • C Contains Part D • D Contains Part A • D Contains Part C 7
  • 8. Contains Entire / Entirely Within • Comparing the entire object! • Order does matter • A Contains Entire D • C Contains Entire D • D Entirely Within A • D Entirely Within C 8
  • 9. Spatial operators • Within/Contains – Very fast – Inprecise when working with other objects than points • Intersects/Partly Within/Contains Part – Slower then Within/Contains – Should be used when comparing lines/polylines and regions • Entirely Within/Contains Entire – Slower then Within/Contains – To be used if one object should be ”entirely within” the other 9
  • 10. Specifying columns • Pick the columns from the ”Columns” list • Create expressions using the ”Functions” list or type in some functions manually • Use aliases (”some new name”) for expressions 10
  • 11. Exercise • Join the two tables Cadastre and Urban_Area • Join them using the Intersects operator • Select these columns – CADASTRE.AREA_NAME – CADASTRE.LOT_NO – URBAN_AREAS.NAME • Add these functions and aliases: – CartesianArea(CADASTRE.OBJ, "sq m") "Area_Cadastre” – CartesianArea(URBAN_AREAS.OBJ, "sq m") "Area_UrbanArea" 11
  • 12. Adding a overlap tolerance • Overlap(obj1, obj2): – Creates an object where the two objects have a common ”area” • MapInfo Pro will create this object and calculate the area of it • If this area is larger then 10 sq m, the intersection will be used 12
  • 13. Calculating area overlap There are a number of ways to calculate the size of the overlapping area: • CartesianArea(Overlap(obj, obj), units) – Uses the defined units – Should be used for projected data (non Longitude/Latitude data) • SpericalArea(Overlap(obj, obj), units) – Uses the defined units – Should be used for Longitude/Latitude data • AreaOverlap(obj, obj) – Uses the current units in MapInfo Professional – Uses the SpericalArea calculation 13
  • 14. Exercise • Add a overlap tolerance by adding this to the condition: – CartesianArea(Overlap(Cadastre.obj, Urban_Areas.obj), "sq m") > 10 • Try different tolerances • How do you change the unit used? 14
  • 15. Extracting spatial data • By default MapInfo Professional takes the spatial object from the first table in your query • You can however add ”more” spatial objects to your query thru the ”Column” field • To see these extra columns you need to insert the result into a new/another table 15
  • 16. Adding an extra spatial column • Add your extra spatial object, can be an expression • Consider using an alias • Note that the result still will highlight the entire area from the first table 16
  • 17. Creating a new table • You can consider using the structure from your first table and just modify it to match the columns in your query 17
  • 18. Inserting the query • You need to do this thru the MapBasic window • Show the MapBasic Window from the Options menu • Write this: Insert Into OverlapResult (AREA_NAME, LOT_NO, NAME, OBJ) Select AREA_NAME, LOT_NO, NAME, OverlapObj From Query1 • Where – OverlapResult is your new table – OverlapObj is your spatial column alias – Query1 is the name of yoru query • And hit enter • Make sure your new table hasn’t been added to the map as that will slow it down – a lot! 18
  • 20. Exercise • Add a spatial column to your result • Create a new table • Insert the result into this new table using this: Insert Into OverlapResult (AREA_NAME, LOT_NO, NAME, OBJ) Select AREA_NAME, LOT_NO, NAME, OverlapObj From Query3 20
  • 21. Regions and lines/polylines • Works just like regions and regions • Note that Overlap uses the style from the first object 21
  • 22. Exercise • Find the roads that intersects the urban areas • Use these columns from the roads: – ROADNAME – ROUTE_NO – ID • And this column from the urban areas – NAME • Extract only the part of the road within the urban area • Create a new table • Insert the result into this new table Insert Into UrbanRoads (ROADNAME,ROUTE_NO,ID,NAME, OBJ) Select ROADNAME,ROUTE_NO,ID,NAME, LineOverlap From Query1 22
  • 23. Adding multiple spatial columns • The SQL statement can include several spatial columns 23 Select Cadastre.LOT_NO , Cadastre.AREA_NAME , Cadastre.obj "CObj" , Urban_Areas.obj "UObj" , Overlap(Cadastre.obj , Urban_Areas.obj) "JOBJ" From Cadastre, Urban_Areas Where Cadastre.Obj Intersects Urban_Areas.Obj into Selection
  • 24. Extracting multiple spatial objects • You need MapBasic to get to these ”many” spatial columns • They could be inserted into the cosmetic layer in this way: Fetch First From Selection Dim oTemp As Object oTemp = selection.UObj Insert Into WindowInfo(FrontWindow(), 10) (OBJ) Values (oTemp) 24
  • 25. Exercise • Select multiple spatial columns • Insert a few of the selected spatial data into the cosmetic layer of a map window 25
  • 26. Some other spatial function • Overlap() • Erase() • Combine() • IntersectNodes() • ExtractNodes() • MBR() • Centroid() • CreatePoint() • CreateLine() • Buffer() (Cart/Sper) • Offset() (Cart/Sper) • OffsetXY() (Cart/Sper) • Rotate() • RotateAtPoint() 26
  • 27. Thank You Peter Horsbøll Møller peter.moller@pb.com