SlideShare a Scribd company logo
PostGIS and Spatial SQL
PostGIS and Spatial SQL
PostGIS and Spatial SQL
PostGIS and Spatial SQL
PostGIS and Spatial SQL
What is “FOSS4G”
FREE OPEN SOURCE SOFTWARE “4” Geospatial/GIS
PostGIS and Spatial SQL
Why use FOSS4G Technology
• Build on Open Standards so data and code are shareable and interoperable
• Increases Flexibility to respond to needs
• Rapid Innovation pushes Geospatial Technology forward
• Core Product can be customized to your need
• Lower Cost of Software Ownership
• Control When Patches are Introduced
PostGIS and Spatial SQL
What is Spatial SQL
• Just like normal SQL but with Spatial Functions
• Geometry/Geography stored as a Binary Large Object (BLOB)
• Spatial Data is just another column in a database
• Attribution is maintained like other data within the database
Drivers
• Increase in Desire for Location Data (Social Media)
• Increased Use of Mobile
• Big Data/Large Amounts of Unstructured Data
• Increased understanding of Geography and its role in general data
analysis
Databases that Support Spatial SQL
• Oracle
• MySQL
• SQL Server (starting in 2008)
• Spatial Lite
• PostGRES
Functionality
Costs&Fees
PostGIS verse a “Geodatabase”
(Personal, File, ArcSDE)
• Spatial SQL allows to query and analyze Spatial Data, a Geodatabase is
just for data management – Still relies on GUI to preform analysis
• Spatial SQL is build on Open Geospatial Consortium (OGC),
Geodatabases are not
• Spatial SQL can support a variety of applications, Geodatabases only
supports desktop GIS software and proprietary Web Servers
Shapefile verses PostGIS
• Shapefiles cannot support more than 70m rows
• Limitations for field names
• Disk Space Hogs
• Difficult to share data
• Limitations to Date Field name
• Do not support nulls
• Files that exist in folders are difficult to manage (backups,size)
• Only support Spatial Tools, not BI or non Spatial software
Spatial Data Management with PostGIS
• Writing SQL to query data opposed to generating new files
• Increasing performance and response speeds through Indexing
• PostGIS takes advantage of multiprocessing hardware
• Users can access PostGIS through the network or Internet, without a
specialized web viewer or desktop software
• PostGIS maintains data integrity and replication
• PostGIS can handle multiple users accessing the same data
• Can store Spatial Data as Text (geojson, WKT) or as Binary (BLOB or
WKB)
PostGIS Spatial Capabilities
• Supports all Geometry Types
• Point
• Multipoint
• Line
• Linestring
• Polygon
• MultiPolygon
• Collections
• Projections
• Supports all known map projections
• Allows reprojection within query
• Spatial Relationships
• Measure
• Serialize/Deserialize
• Intersect
• Buffer
• Point n Polygon
• Overlap/Touch/Cross
PostGIS Spatial Capabilities
• Can import/export any Spatial Data Type
• Spatial Indexing
• Allows user to reduce query time
Geometry Vs. Geography
• Geography is always in WGS84
• Geography has limited Spatial Functions
• Geography views the world as 2D
• Geography is faster for generating visualizations
• Geometry allows for full analysis
• Geometry allows for 3D Analysis
Geography Geometry
Metrics (Unscientific)
• 400K buffers generated
• PostGIS: Shorter than a ½ mile walk with “the dog”
• Proprietary Desktop GIS: 4 hours
• 1.5 Billion Point in Polygon Analyses
• PostGIS: Shorter than a commercial free episode of “The Walking Dead”
• Proprietary Desktop GIS: Kept spinning, turned off after 24 hours
• 1.5 Billion Measurements
• PostGIS: a bit longer than a commercial free episode of “The Walking Dead”
• Proprietary Desktop GIS – Error 99999 after 3 hours of the process
PostGIS and Spatial SQL
PostGIS and Spatial SQL
Your Current Set up
• “Lone Wolf” Analyst/Developer Style
• PostGRES 9.5
• PostGIS 2.3.x
• QGIS 2.14 – for Map Making and Visualization
Getting Comfortable With pgAdmin 4
Finding the Database
SQL Warm up
SELECT
*
FROM
liquor_licenses
The WHERE Clause
SELECT
*
FROM
liquor_licenses
WHERE
license_ty='Tavern'
Adding some Function
SELECT
COUNT(establish)
FROM
liquor_licenses
WHERE
license_ty='Brew Pub’
Group By
SELECT
AVG(char_length(establish)),
license_ty
FROM
liquor_licenses
GROUP BY
license_ty
Standard Deviation (last non GEO one I promise)
SELECT
AVG(char_length(establish)),
STDDEV(char_length(establish)),
license_ty
FROM
liquor_licenses
GROUP BY
license_ty
The GEOM
SELECT
ST_AsText(geom)
FROM
liquor_licenses
ST_Length
SELECT
ST_LENGTH (geom) ,
strname
FROM
street_centerlines
PostGIS and Spatial SQL
¯_(ツ)_/¯ ST_Transform
SELECT
ST_LENGTH(ST_TRANSFORM(geom,2876),
strname
FROM
street_centerlines
ST_AREA
SELECT
objectid,
ST_AREA(ST_TRANSFORM(geom,2876))
FROM
buildings
ST_BUFFER
ALTER TABLE
liquor_licenses
ADD Column
buffer
geometry(Polygon,4326)
ST_BUFFER
UPDATE
liquor_licenses
SET
Buffer=
ST_TRANSFORM
(ST_BUFFER(ST_TRANSFORM(geom,2876),30),4326)
Exporting as Different Data Types
SELECT ST_AsGeoJSON(geom) FROM floodplain_city
SELECT ST_AsGML(geom) FROM floodplain_city
ST_NPoints
SELECT
ST_NPoints(geom)
FROM
street_centerlines
ST_Intersect
SELECT
a.strname,a.gid,a.geom,
a.leftadd1,a.leftadd2,a.rgtadd1,a.rgtadd2
FROM
street_centerlines a, floodplain_city b
WHERE
ST_Crosses(a.geom,b.geom)
PostGIS and Spatial SQL
ST_Within
SELECT a.establish, a.license_ty,a.gid,a.geom
FROM liquor_licenses a, zoning b
WHERE st_within(a.geom, b.geom)
AND
zone_name='LOW DENSITY MIXED-USE NEIGHBORHOOD DISTRICT'
ST_Within - part 2
SELECT
COUNT(a.establish),
a.license_ty, b.zone_name ,a.gid,a.geom
FROM
liquor_licenses a, zoning b
WHERE
ST_WITHIN(a.geom,b.geom)
GROUP BY
b.zone_name, a.license_ty
PostGIS and Spatial SQL

More Related Content

What's hot (20)

PDF
PostGIS 시작하기
Byeong-Hyeok Yu
 
PDF
Discover PostGIS: Add Spatial functions to PostgreSQL
EDB
 
PDF
What is GIS
Esri
 
PPTX
Open Source GIS 기초교육 4일차 - GeoServer 기초 2014년 7월판
BJ Jang
 
PDF
[공간정보시스템 개론] L02 공간정보와 지리정보
Kwang Woo NAM
 
PPTX
공간정보연구원 PostGIS 강의교재
JungHwan Yun
 
PPTX
QGIS 활용
Sungjin Kang
 
PDF
Introduction to GIS & Cartography.pdf
LareebMoeen1
 
PPTX
공간정보거점대학 PostGIS 고급과정
JungHwan Yun
 
PDF
지리정보체계(GIS) - [1] GIS 데이터 유형, 구조 알기
Byeong-Hyeok Yu
 
PPTX
GIS User to Web-GIS Developer Journey
Tek Kshetri
 
PDF
[공간정보시스템 개론] L09 공간 데이터 모델
Kwang Woo NAM
 
PPTX
3D WebGIS using Opensource software
Parthesh Bulbule
 
PPTX
오픈소스GIS 개론 과정 - OpenLayers 기초
HaNJiN Lee
 
PDF
오픈소스 GIS의 이해와 활용(육군사관학교 특강)
SANGHEE SHIN
 
PDF
Introduction to arc gis
Mohamed Hamed
 
PDF
Introduction to Open Source GIS
SANGHEE SHIN
 
PDF
QGIS Open Source Desktop GIS
GIS Colorado
 
PPT
Open Source GIS
Joe Larson
 
PDF
Unmanned Aerial Systems for Precision Mapping
UAS Colorado
 
PostGIS 시작하기
Byeong-Hyeok Yu
 
Discover PostGIS: Add Spatial functions to PostgreSQL
EDB
 
What is GIS
Esri
 
Open Source GIS 기초교육 4일차 - GeoServer 기초 2014년 7월판
BJ Jang
 
[공간정보시스템 개론] L02 공간정보와 지리정보
Kwang Woo NAM
 
공간정보연구원 PostGIS 강의교재
JungHwan Yun
 
QGIS 활용
Sungjin Kang
 
Introduction to GIS & Cartography.pdf
LareebMoeen1
 
공간정보거점대학 PostGIS 고급과정
JungHwan Yun
 
지리정보체계(GIS) - [1] GIS 데이터 유형, 구조 알기
Byeong-Hyeok Yu
 
GIS User to Web-GIS Developer Journey
Tek Kshetri
 
[공간정보시스템 개론] L09 공간 데이터 모델
Kwang Woo NAM
 
3D WebGIS using Opensource software
Parthesh Bulbule
 
오픈소스GIS 개론 과정 - OpenLayers 기초
HaNJiN Lee
 
오픈소스 GIS의 이해와 활용(육군사관학교 특강)
SANGHEE SHIN
 
Introduction to arc gis
Mohamed Hamed
 
Introduction to Open Source GIS
SANGHEE SHIN
 
QGIS Open Source Desktop GIS
GIS Colorado
 
Open Source GIS
Joe Larson
 
Unmanned Aerial Systems for Precision Mapping
UAS Colorado
 

Viewers also liked (20)

PPTX
Staph
Todd Barr
 
PPTX
Geo am prezzie
Todd Barr
 
PPTX
Why is postgis awesome?
Kasper Van Lombeek
 
PDF
State of GeoServer 2.10
Jody Garnett
 
PDF
10 su building-energy-use-intensity
Kumar Ramaiah
 
PPTX
Connecting on LinkedIn
Cindy Miles, M.B.A.
 
PDF
TCC Henrique de V. Junqueira
Henrique Junqueira
 
PDF
Writing drills
tamanmidah
 
PDF
Repubblicanesimo, repubblicanismo, republicanismo, républicanisme, republican...
UNIVERSITY OF COIMBRA
 
PPTX
Presentación dia de andalucia pedro
Pedro Ramirez Serrano
 
PPT
Iot og personvern 2017
Øystein Jakobsen
 
ODP
Com clonar i com exportar i importar una màquina virtual
Edu Alias
 
PDF
Labo XX Antwerp - Densification strategies for the 20th century belt (BUUR)
Kevin Penalva-Halpin
 
PDF
Continuous Deployment with Amazon Web Services
Julien SIMON
 
PDF
Postmarxismo, post marxismo, post marxismo
UNIVERSITY OF COIMBRA
 
PPTX
Filafat ilmu kepolisian
rara wibowo
 
PPTX
Património Cultural Português - Panteões de Portugal e Edifícios da Soberania...
Artur Filipe dos Santos
 
PPTX
170301 いまさら聞けないブロックチェーン①
勇太 荒瀬
 
PDF
Koleksi soalan 1 markah
tamanmidah
 
Staph
Todd Barr
 
Geo am prezzie
Todd Barr
 
Why is postgis awesome?
Kasper Van Lombeek
 
State of GeoServer 2.10
Jody Garnett
 
10 su building-energy-use-intensity
Kumar Ramaiah
 
Connecting on LinkedIn
Cindy Miles, M.B.A.
 
TCC Henrique de V. Junqueira
Henrique Junqueira
 
Writing drills
tamanmidah
 
Repubblicanesimo, repubblicanismo, republicanismo, républicanisme, republican...
UNIVERSITY OF COIMBRA
 
Presentación dia de andalucia pedro
Pedro Ramirez Serrano
 
Iot og personvern 2017
Øystein Jakobsen
 
Com clonar i com exportar i importar una màquina virtual
Edu Alias
 
Labo XX Antwerp - Densification strategies for the 20th century belt (BUUR)
Kevin Penalva-Halpin
 
Continuous Deployment with Amazon Web Services
Julien SIMON
 
Postmarxismo, post marxismo, post marxismo
UNIVERSITY OF COIMBRA
 
Filafat ilmu kepolisian
rara wibowo
 
Património Cultural Português - Panteões de Portugal e Edifícios da Soberania...
Artur Filipe dos Santos
 
170301 いまさら聞けないブロックチェーン①
勇太 荒瀬
 
Koleksi soalan 1 markah
tamanmidah
 
Ad

Similar to PostGIS and Spatial SQL (20)

PPTX
FOSS4G 2017 Spatial Sql for Rookies
Todd Barr
 
PDF
Building A Spatial Database In Postgresql (Ppt).pdf
ssuser0ab1a4
 
PPT
Building a Spatial Database in PostgreSQL
Sohail Akbar Goheer
 
PPT
Building a Spatial Database in PostgreSQL
Kudos S.A.S
 
PDF
2017 RM-URISA Track: Spatial SQL - The Best Kept Secret in the Geospatial World
GIS in the Rockies
 
PDF
Lancaster University GIS Course 2010
Joanne Cook
 
PDF
Postgis for Enterprise
GeoLivre Conference
 
PPT
GIS_Whirlwind_Tour.ppt
vikramvsu
 
PPT
GIS_Whirlwind_Tour.ppt
Fatima891926
 
PPT
GIS_Whirlwind_Tour.ppt
GodwinKingNyamador
 
PPT
GIS_Whirlwind_Tour.ppt
safayetmim1
 
PDF
Building Location Aware Apps - Get Started with PostGIS, PART I
lasmasi
 
PDF
Pg intro part1-theory_slides
lasmasi
 
PDF
Integrating PostGIS in Web Applications
Command Prompt., Inc
 
PPTX
What is spatial sql
shawty_ds
 
PPT
Open Source Databases And Gis
Kudos S.A.S
 
PPTX
DATABASE & WEBGIS - GIS BOOTCAMP
Kevin Ng'eno
 
PPTX
Databases Basics and Spacial Matrix - Discussig Geographic Potentials of Data...
Jerin John
 
PDF
Intro To Geospatial
danrickman
 
PPTX
Intro GIS.pptx
SamiDan2
 
FOSS4G 2017 Spatial Sql for Rookies
Todd Barr
 
Building A Spatial Database In Postgresql (Ppt).pdf
ssuser0ab1a4
 
Building a Spatial Database in PostgreSQL
Sohail Akbar Goheer
 
Building a Spatial Database in PostgreSQL
Kudos S.A.S
 
2017 RM-URISA Track: Spatial SQL - The Best Kept Secret in the Geospatial World
GIS in the Rockies
 
Lancaster University GIS Course 2010
Joanne Cook
 
Postgis for Enterprise
GeoLivre Conference
 
GIS_Whirlwind_Tour.ppt
vikramvsu
 
GIS_Whirlwind_Tour.ppt
Fatima891926
 
GIS_Whirlwind_Tour.ppt
GodwinKingNyamador
 
GIS_Whirlwind_Tour.ppt
safayetmim1
 
Building Location Aware Apps - Get Started with PostGIS, PART I
lasmasi
 
Pg intro part1-theory_slides
lasmasi
 
Integrating PostGIS in Web Applications
Command Prompt., Inc
 
What is spatial sql
shawty_ds
 
Open Source Databases And Gis
Kudos S.A.S
 
DATABASE & WEBGIS - GIS BOOTCAMP
Kevin Ng'eno
 
Databases Basics and Spacial Matrix - Discussig Geographic Potentials of Data...
Jerin John
 
Intro To Geospatial
danrickman
 
Intro GIS.pptx
SamiDan2
 
Ad

More from Todd Barr (11)

PPTX
Authentic_Leadership.pptx
Todd Barr
 
PPTX
The Core of Geospatial
Todd Barr
 
PDF
Imposterism
Todd Barr
 
PDF
The geography of geospatial
Todd Barr
 
PPTX
R spatial presentation
Todd Barr
 
PPTX
Tb geo dev_presentation_nov_5
Todd Barr
 
PPTX
Workshops
Todd Barr
 
PPTX
De vsummit sessions
Todd Barr
 
PPTX
Ambient Geographic Information and biosurveilance todd barr
Todd Barr
 
PDF
GEOPLATFORM IDIQ Released Early to Contractor
Todd Barr
 
PPTX
Jiee Geospatial Intergration Esri Uc
Todd Barr
 
Authentic_Leadership.pptx
Todd Barr
 
The Core of Geospatial
Todd Barr
 
Imposterism
Todd Barr
 
The geography of geospatial
Todd Barr
 
R spatial presentation
Todd Barr
 
Tb geo dev_presentation_nov_5
Todd Barr
 
Workshops
Todd Barr
 
De vsummit sessions
Todd Barr
 
Ambient Geographic Information and biosurveilance todd barr
Todd Barr
 
GEOPLATFORM IDIQ Released Early to Contractor
Todd Barr
 
Jiee Geospatial Intergration Esri Uc
Todd Barr
 

Recently uploaded (20)

PDF
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
PDF
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PDF
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
PPTX
What Is Data Integration and Transformation?
subhashenia
 
PDF
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PDF
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
PDF
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
PPTX
04_Tamás Marton_Intuitech .pptx_AI_Barometer_2025
FinTech Belgium
 
PDF
InformaticsPractices-MS - Google Docs.pdf
seshuashwin0829
 
PDF
Business implication of Artificial Intelligence.pdf
VishalChugh12
 
PDF
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
PDF
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
PDF
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
PDF
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
What Is Data Integration and Transformation?
subhashenia
 
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
04_Tamás Marton_Intuitech .pptx_AI_Barometer_2025
FinTech Belgium
 
InformaticsPractices-MS - Google Docs.pdf
seshuashwin0829
 
Business implication of Artificial Intelligence.pdf
VishalChugh12
 
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 

PostGIS and Spatial SQL