SlideShare a Scribd company logo
1 of 30
Download to read offline
© 2015 EnterpriseDB Corporation. All rights reserved. 1
Getting started with PostGIS
Adam Wright – Database Consultant
© 2015 EnterpriseDB Corporation. All rights reserved. 2
•  Introduction to EDB
•  A little bit about Postgres
•  About PostGIS
•  Geospatial basics
•  Now, let us get started
•  Maintenance
Agenda
© 2015 EnterpriseDB Corporation. All rights reserved. 3
POSTGRES
innovation
ENTERPRISE
reliability
24/7
support
Services
& training
Enterprise-class
features, tools &
compatibility
Indemnification
Product
road-map
Control
Thousands
of developers
Fast
development
cycles
Low cost
No vendor
lock-in
Advanced
features
Enabling commercial
adoption of Postgres
© 2015 EnterpriseDB Corporation. All rights reserved. 4
Postgres: A Proven Track Record
•  Most mature open source DBMS technology
•  Enterprise-class features (built like Oracle, DB2,
SQL Server)
•  Strong, independent community driving rapid
innovation
4
Fully ACID Compliant
MVCC
Point in Time Recovery (PITR)‫‏‬
Data and Index Partitioning
Bitmap Indexes
ANSI Constraints
Triggers & Stored Functions
Views & Data Types
Nested Transactions
Online Backup
Online Reorganization
Foreign Keys
Streaming Replication
Multi-Core Support
JSON Support
Hstore
Table Partition
Materialized Views
Grouping Sets and CUBE (9.5)
UPSERT (9.5)
Row Level Security (9.5)
© 2015 EnterpriseDB Corporation. All rights reserved. 5
Scalable
© 2015 EnterpriseDB Corporation. All rights reserved. 6
•  Refractions Research released first version in 2001
under the GNU license
•  Follows the Simple Features for SQL specification
from the Open Geospatial Consortium (OGC)
•  Spatial operators and spatial functions
•  Spatial data types
•  Spatial indexing
•  Spatial reprojection
•  Import / Export Esri shapefiles
•  Commands for importing raster data
•  SQL to render and import data from multiple
formats
About PostGIS
6
© 2015 EnterpriseDB Corporation. All rights reserved. 7
PostGIS Data Types
Geometry
Geography
Raster Topology
© 2015 EnterpriseDB Corporation. All rights reserved. 8
PostGIS Data subtypes
Point
Linestring
Polygon
Multipoint
Multilinestring
Multipolygon
© 2015 EnterpriseDB Corporation. All rights reserved. 9
Spatial Definitions Examples (1 of 5)
Boundary
© 2015 EnterpriseDB Corporation. All rights reserved. 10
Spatial Definitions Examples (2 of 5)
© 2015 EnterpriseDB Corporation. All rights reserved. 11
Spatial Definitions Examples (3 of 5)
Contains
© 2015 EnterpriseDB Corporation. All rights reserved. 12
Spatial Definitions Examples (4 of 5)
Equals
© 2015 EnterpriseDB Corporation. All rights reserved. 13
Spatial Definitions Examples (5 of 5)
© 2015 EnterpriseDB Corporation. All rights reserved. 14
•  Repository
•  Binary
Step 1: Install PostGIS - two methods
14
RedHat
‘yum install postgis2_94’
Debian
‘apt-get install postgres-9.4-postgis’
© 2015 EnterpriseDB Corporation. All rights reserved. 15
•  For a New Database
CREATE DATABASE geodb
WITH template = template_postgis;
•  For an Existing Database
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_toplogy;
•  Verify
SELECT postgis_version();
Step 2: Enable PostGIS
© 2015 EnterpriseDB Corporation. All rights reserved. 16
•  Load shapefiles
shp2pgsql –c –s 4629 –I /
tmp/
boston_massachusetts_osm_l
ine.shp boston_osm_line |
pgsql –d geodb
•  Inserting a point in SQL
INSERT into
cities(name,state,geom)
Values(‘Boston’,’MA’,
ST_GeomFromText(‘POINT(-71
.0589 42.3601)’,4326));
Step 3: Load Data
16
© 2015 EnterpriseDB Corporation. All rights reserved. 17
Load data from standard to geospatial
17
INSERT into events_geo(eventname,geom,date)
SELECT eventname, st_setsrid(st_makepoint(lon,lat),4326)
as geom,date FROM events;
Events Table
eventname – character varying
lat - double precision
lon - double precision
Date - timestamp with time zone
Events_geo Table
eventname - character
varying geom – geometry (Point,4326)
Date – timestamp with time zone
INSERT
© 2015 EnterpriseDB Corporation. All rights reserved. 18
Visual Inspection of data
18
© 2015 EnterpriseDB Corporation. All rights reserved. 19
Visual Inspection of data
19
© 2015 EnterpriseDB Corporation. All rights reserved. 20
•  Output geometry data types to other data types
SELECT st_astext(geom), st_asgeojson(geom),
stasgml(geom) FROM atm_locations LIMIT 1;
-[ RECORD 1 ]+----------------------------------
st_astext | POINT(-81.7842060002066 30.2915309995561)
st_asgeojson | {"type":"Point","coordinates":
[-81.7842060002066,30.2915309995561]}
st_asgml | <gml:Point srsName="EPSG:
4629"><gml:coordinates>-81.784206000206609,30.2915309995
5613</gml:coordinates></gml:Point>
Geometry Input and Output Functions
20
© 2015 EnterpriseDB Corporation. All rights reserved. 21
•  Create geometry type from text
Insert into cities (name,state,geom)
Values (‘Bedford’,’MA’,
ST_GeomFromText(‘POINT(-71.248063 42.510547)’,4326));
Geometry Input and Output Functions
21
© 2015 EnterpriseDB Corporation. All rights reserved. 22
•  Write a function to tell whether a given lat/lon pair is
within a Point-Radius ring
IF ST_Dwithin(check_pt, point_pt, outerRadius)
AND NOT ST_Dwithin(chevk_pt, point_pt,
innerRadius)
THEN return 1;
ELSE
Return 0;
END IF;
•  Create a route from a collection of waypoints captured
in sequence
CREATE TABLE PATHS as SELECT routeid, seq, geom
FROM waypoints ORDER BY seq) a GROUP BY routeid;
Power of GIS & SQL
© 2015 EnterpriseDB Corporation. All rights reserved. 23
•  Simple distance query
between two points
SELECT ST_Distance
(ST_GeomFromText
('POINT(34 9)’,4629),
ST_GeomFromText
('POINT(70 12)’,4629));
Power of GIS & SQL
34, 9
70, 12
© 2015 EnterpriseDB Corporation. All rights reserved. 24
•  Write a function to tell whether a given lat/lon pair is
within a Point-Radius ring
IF ST_Dwithin(check_pt, point_pt, outerRadius) AND
NOT ST_Dwithin(chevk_pt, point_pt, innerRadius)
THEN return 1;
ELSE
Return 0;
END IF;
•  Create a route from a collection of waypoints captured in
sequence
CREATE TABLE PATHS as SELECT routeid, st_make(gem)
as geom FROM (SELECT routeid, seq, geom FROM
waypoints ORDER BY seq)a GROUP BY routeid;
Power of GIS & SQL
© 2015 EnterpriseDB Corporation. All rights reserved. 25
•  Answer powerful questions with a simple query
−  Input function
Insert into cities (name,state,geom)
Values (‘Bedford’,’MA’,
ST_GeomFromText(‘POINT(-71.248063 42.510547)’,
4326));
Power of GIS & SQL
© 2015 EnterpriseDB Corporation. All rights reserved. 26
Power of GIS & SQL
© 2015 EnterpriseDB Corporation. All rights reserved. 27
Power of GIS & SQL
© 2015 EnterpriseDB Corporation. All rights reserved. 28
Maintenance of a PostGIS database
•  After bulk inserts and updates – VACUUM ANALYZE
•  Loading large dataset: Build indexes after
•  Use EXPLAIN
•  Add Indexes on PostGIS columns
•  Backup/Recovery and SR considerations
© 2015 EnterpriseDB Corporation. All rights reserved. 29
•  Power of Postgres
−  Binary replication, Table Partitions, Text search function and operators, PL/SQL, PL/Python,
PLV8, PL/R, Indexes
−  Grouping sets, cube and rollup (now in EDB Postgres Plus, coming in Postgres 9.5)
−  Foreign table inheritance (new in 9.5)
•  ogr2ogr
•  Web Maps
−  Open Layers
−  Map Server
−  GeoServer
Notes:
© 2015 EnterpriseDB Corporation. All rights reserved. 30

More Related Content

What's hot

Supervised Classification
Supervised ClassificationSupervised Classification
Supervised Classification
Chad Yowler
 
WEB GIS AND WEB MAP.pptx
WEB GIS AND WEB MAP.pptxWEB GIS AND WEB MAP.pptx
WEB GIS AND WEB MAP.pptx
Asim Pt
 
DATABASE & WEBGIS - GIS BOOTCAMP
DATABASE & WEBGIS - GIS BOOTCAMPDATABASE & WEBGIS - GIS BOOTCAMP
DATABASE & WEBGIS - GIS BOOTCAMP
Kevin Ng'eno
 

What's hot (20)

Basic Gis
Basic GisBasic Gis
Basic Gis
 
Web GIS using Google Map and QGIS
Web GIS using Google Map and QGISWeb GIS using Google Map and QGIS
Web GIS using Google Map and QGIS
 
An introduction to geographic information systems (gis) m goulbourne 2007
An introduction to geographic information systems (gis)   m goulbourne 2007An introduction to geographic information systems (gis)   m goulbourne 2007
An introduction to geographic information systems (gis) m goulbourne 2007
 
Object Based Image Analysis
Object Based Image Analysis Object Based Image Analysis
Object Based Image Analysis
 
Introduction to Open Source GIS
Introduction to Open Source GISIntroduction to Open Source GIS
Introduction to Open Source GIS
 
Supervised Classification
Supervised ClassificationSupervised Classification
Supervised Classification
 
Gis
GisGis
Gis
 
WEB GIS AND WEB MAP.pptx
WEB GIS AND WEB MAP.pptxWEB GIS AND WEB MAP.pptx
WEB GIS AND WEB MAP.pptx
 
Spatial analysis and Analysis Tools
Spatial analysis and Analysis ToolsSpatial analysis and Analysis Tools
Spatial analysis and Analysis Tools
 
Gis
Gis Gis
Gis
 
Spatial Databases
Spatial DatabasesSpatial Databases
Spatial Databases
 
Introduction to GIS
Introduction to GISIntroduction to GIS
Introduction to GIS
 
A Journey to the World of GIS
A Journey to the World of GISA Journey to the World of GIS
A Journey to the World of GIS
 
Spatial data analysis
Spatial data analysisSpatial data analysis
Spatial data analysis
 
DATABASE & WEBGIS - GIS BOOTCAMP
DATABASE & WEBGIS - GIS BOOTCAMPDATABASE & WEBGIS - GIS BOOTCAMP
DATABASE & WEBGIS - GIS BOOTCAMP
 
Cartographic map design
Cartographic map designCartographic map design
Cartographic map design
 
Digital Soil Mapping steps
Digital Soil Mapping stepsDigital Soil Mapping steps
Digital Soil Mapping steps
 
When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...When to Use MongoDB...and When You Should Not...
When to Use MongoDB...and When You Should Not...
 
Introduction to GIS
Introduction to GISIntroduction to GIS
Introduction to GIS
 
Map algebra
Map algebraMap algebra
Map algebra
 

Viewers also liked

Top 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres DeploymentTop 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres Deployment
EDB
 
PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_Tutorial
Vibhor Kumar
 

Viewers also liked (17)

EnterpriseDB Postgres Survey Results - 2013
EnterpriseDB Postgres Survey Results - 2013EnterpriseDB Postgres Survey Results - 2013
EnterpriseDB Postgres Survey Results - 2013
 
NoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured PostgresNoSQL on ACID - Meet Unstructured Postgres
NoSQL on ACID - Meet Unstructured Postgres
 
Top 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres DeploymentTop 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres Deployment
 
Come with an idea - go home with a web map: Tools for sharing maps and vector...
Come with an idea - go home with a web map: Tools for sharing maps and vector...Come with an idea - go home with a web map: Tools for sharing maps and vector...
Come with an idea - go home with a web map: Tools for sharing maps and vector...
 
Create Spatialite Database Using Quantum GIS
Create Spatialite Database Using Quantum GISCreate Spatialite Database Using Quantum GIS
Create Spatialite Database Using Quantum GIS
 
PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_Tutorial
 
Day 6 - PostGIS
Day 6 - PostGISDay 6 - PostGIS
Day 6 - PostGIS
 
Migrating from Oracle to Postgres
Migrating from Oracle to PostgresMigrating from Oracle to Postgres
Migrating from Oracle to Postgres
 
What is spatial sql
What is spatial sqlWhat is spatial sql
What is spatial sql
 
Building enterprise applications using open source
Building enterprise applications using open sourceBuilding enterprise applications using open source
Building enterprise applications using open source
 
Spatial query tutorial for nyc subway income level along subway
Spatial query tutorial  for nyc subway income level along subwaySpatial query tutorial  for nyc subway income level along subway
Spatial query tutorial for nyc subway income level along subway
 
Key Methodologies for Migrating from Oracle to Postgres
Key Methodologies for Migrating from Oracle to PostgresKey Methodologies for Migrating from Oracle to Postgres
Key Methodologies for Migrating from Oracle to Postgres
 
Partition and conquer large data in PostgreSQL 10
Partition and conquer large data in PostgreSQL 10Partition and conquer large data in PostgreSQL 10
Partition and conquer large data in PostgreSQL 10
 
Best Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupBest Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture Setup
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 

Similar to Getting Started with PostGIS

PaaS - google app engine
PaaS  - google app enginePaaS  - google app engine
PaaS - google app engine
J Singh
 
Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...
Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...
Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...
Lucas Jellema
 
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォームPivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Masayuki Matsushita
 

Similar to Getting Started with PostGIS (20)

Discover PostGIS: Add Spatial functions to PostgreSQL
Discover PostGIS: Add Spatial functions to PostgreSQLDiscover PostGIS: Add Spatial functions to PostgreSQL
Discover PostGIS: Add Spatial functions to PostgreSQL
 
Presto query optimizer: pursuit of performance
Presto query optimizer: pursuit of performancePresto query optimizer: pursuit of performance
Presto query optimizer: pursuit of performance
 
The Real Scoop on Migrating from Oracle Databases
The Real Scoop on Migrating from Oracle DatabasesThe Real Scoop on Migrating from Oracle Databases
The Real Scoop on Migrating from Oracle Databases
 
EDB: Power to Postgres
EDB: Power to PostgresEDB: Power to Postgres
EDB: Power to Postgres
 
PaaS - google app engine
PaaS  - google app enginePaaS  - google app engine
PaaS - google app engine
 
The Central View of your Data with Postgres
The Central View of your Data with PostgresThe Central View of your Data with Postgres
The Central View of your Data with Postgres
 
Postgres NoSQL - Delivering Apps Faster
Postgres NoSQL - Delivering Apps FasterPostgres NoSQL - Delivering Apps Faster
Postgres NoSQL - Delivering Apps Faster
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13
 
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
Doing More with Postgres - Yesterday's Vision Becomes Today's RealityDoing More with Postgres - Yesterday's Vision Becomes Today's Reality
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
 
MySQL performance monitoring using Statsd and Graphite
MySQL performance monitoring using Statsd and GraphiteMySQL performance monitoring using Statsd and Graphite
MySQL performance monitoring using Statsd and Graphite
 
Supersized PostgreSQL: Postgres-XL for Scale-Out OLTP and Big Data Analytics
Supersized PostgreSQL: Postgres-XL for Scale-Out OLTP and Big Data AnalyticsSupersized PostgreSQL: Postgres-XL for Scale-Out OLTP and Big Data Analytics
Supersized PostgreSQL: Postgres-XL for Scale-Out OLTP and Big Data Analytics
 
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
Around the world with extensions | PostgreSQL Conference Europe 2018 | Craig ...
 
Agile Oracle to PostgreSQL migrations (PGConf.EU 2013)
Agile Oracle to PostgreSQL migrations (PGConf.EU 2013)Agile Oracle to PostgreSQL migrations (PGConf.EU 2013)
Agile Oracle to PostgreSQL migrations (PGConf.EU 2013)
 
Analyzing Real-World Data with Apache Drill
Analyzing Real-World Data with Apache DrillAnalyzing Real-World Data with Apache Drill
Analyzing Real-World Data with Apache Drill
 
Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...
Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...
Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...
 
SQL on Hadoop
SQL on HadoopSQL on Hadoop
SQL on Hadoop
 
SQL on Hadoop - 12th Swiss Big Data User Group Meeting, 3rd of July, 2014, ET...
SQL on Hadoop - 12th Swiss Big Data User Group Meeting, 3rd of July, 2014, ET...SQL on Hadoop - 12th Swiss Big Data User Group Meeting, 3rd of July, 2014, ET...
SQL on Hadoop - 12th Swiss Big Data User Group Meeting, 3rd of July, 2014, ET...
 
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォームPivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
Pivotal Greenplum 次世代マルチクラウド・データ分析プラットフォーム
 
How to use postgresql.conf to configure and tune the PostgreSQL server
How to use postgresql.conf to configure and tune the PostgreSQL serverHow to use postgresql.conf to configure and tune the PostgreSQL server
How to use postgresql.conf to configure and tune the PostgreSQL server
 

More from EDB

EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021
EDB
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
EDB
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAIN
EDB
 

More from EDB (20)

Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSCloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenDie 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube
 
EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021
 
Benchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQLBenchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQL
 
Las Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLLas Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQL
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
 
Data Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLData Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQL
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with Postgres
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAIN
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQL
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQL
 
Psql is awesome!
Psql is awesome!Psql is awesome!
Psql is awesome!
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJ
 
Comment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesComment sauvegarder correctement vos données
Comment sauvegarder correctement vos données
 
Cloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - ItalianoCloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - Italiano
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQL
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJCloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJ
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 

Getting Started with PostGIS

  • 1. © 2015 EnterpriseDB Corporation. All rights reserved. 1 Getting started with PostGIS Adam Wright – Database Consultant
  • 2. © 2015 EnterpriseDB Corporation. All rights reserved. 2 •  Introduction to EDB •  A little bit about Postgres •  About PostGIS •  Geospatial basics •  Now, let us get started •  Maintenance Agenda
  • 3. © 2015 EnterpriseDB Corporation. All rights reserved. 3 POSTGRES innovation ENTERPRISE reliability 24/7 support Services & training Enterprise-class features, tools & compatibility Indemnification Product road-map Control Thousands of developers Fast development cycles Low cost No vendor lock-in Advanced features Enabling commercial adoption of Postgres
  • 4. © 2015 EnterpriseDB Corporation. All rights reserved. 4 Postgres: A Proven Track Record •  Most mature open source DBMS technology •  Enterprise-class features (built like Oracle, DB2, SQL Server) •  Strong, independent community driving rapid innovation 4 Fully ACID Compliant MVCC Point in Time Recovery (PITR)‫‏‬ Data and Index Partitioning Bitmap Indexes ANSI Constraints Triggers & Stored Functions Views & Data Types Nested Transactions Online Backup Online Reorganization Foreign Keys Streaming Replication Multi-Core Support JSON Support Hstore Table Partition Materialized Views Grouping Sets and CUBE (9.5) UPSERT (9.5) Row Level Security (9.5)
  • 5. © 2015 EnterpriseDB Corporation. All rights reserved. 5 Scalable
  • 6. © 2015 EnterpriseDB Corporation. All rights reserved. 6 •  Refractions Research released first version in 2001 under the GNU license •  Follows the Simple Features for SQL specification from the Open Geospatial Consortium (OGC) •  Spatial operators and spatial functions •  Spatial data types •  Spatial indexing •  Spatial reprojection •  Import / Export Esri shapefiles •  Commands for importing raster data •  SQL to render and import data from multiple formats About PostGIS 6
  • 7. © 2015 EnterpriseDB Corporation. All rights reserved. 7 PostGIS Data Types Geometry Geography Raster Topology
  • 8. © 2015 EnterpriseDB Corporation. All rights reserved. 8 PostGIS Data subtypes Point Linestring Polygon Multipoint Multilinestring Multipolygon
  • 9. © 2015 EnterpriseDB Corporation. All rights reserved. 9 Spatial Definitions Examples (1 of 5) Boundary
  • 10. © 2015 EnterpriseDB Corporation. All rights reserved. 10 Spatial Definitions Examples (2 of 5)
  • 11. © 2015 EnterpriseDB Corporation. All rights reserved. 11 Spatial Definitions Examples (3 of 5) Contains
  • 12. © 2015 EnterpriseDB Corporation. All rights reserved. 12 Spatial Definitions Examples (4 of 5) Equals
  • 13. © 2015 EnterpriseDB Corporation. All rights reserved. 13 Spatial Definitions Examples (5 of 5)
  • 14. © 2015 EnterpriseDB Corporation. All rights reserved. 14 •  Repository •  Binary Step 1: Install PostGIS - two methods 14 RedHat ‘yum install postgis2_94’ Debian ‘apt-get install postgres-9.4-postgis’
  • 15. © 2015 EnterpriseDB Corporation. All rights reserved. 15 •  For a New Database CREATE DATABASE geodb WITH template = template_postgis; •  For an Existing Database CREATE EXTENSION postgis; CREATE EXTENSION postgis_toplogy; •  Verify SELECT postgis_version(); Step 2: Enable PostGIS
  • 16. © 2015 EnterpriseDB Corporation. All rights reserved. 16 •  Load shapefiles shp2pgsql –c –s 4629 –I / tmp/ boston_massachusetts_osm_l ine.shp boston_osm_line | pgsql –d geodb •  Inserting a point in SQL INSERT into cities(name,state,geom) Values(‘Boston’,’MA’, ST_GeomFromText(‘POINT(-71 .0589 42.3601)’,4326)); Step 3: Load Data 16
  • 17. © 2015 EnterpriseDB Corporation. All rights reserved. 17 Load data from standard to geospatial 17 INSERT into events_geo(eventname,geom,date) SELECT eventname, st_setsrid(st_makepoint(lon,lat),4326) as geom,date FROM events; Events Table eventname – character varying lat - double precision lon - double precision Date - timestamp with time zone Events_geo Table eventname - character varying geom – geometry (Point,4326) Date – timestamp with time zone INSERT
  • 18. © 2015 EnterpriseDB Corporation. All rights reserved. 18 Visual Inspection of data 18
  • 19. © 2015 EnterpriseDB Corporation. All rights reserved. 19 Visual Inspection of data 19
  • 20. © 2015 EnterpriseDB Corporation. All rights reserved. 20 •  Output geometry data types to other data types SELECT st_astext(geom), st_asgeojson(geom), stasgml(geom) FROM atm_locations LIMIT 1; -[ RECORD 1 ]+---------------------------------- st_astext | POINT(-81.7842060002066 30.2915309995561) st_asgeojson | {"type":"Point","coordinates": [-81.7842060002066,30.2915309995561]} st_asgml | <gml:Point srsName="EPSG: 4629"><gml:coordinates>-81.784206000206609,30.2915309995 5613</gml:coordinates></gml:Point> Geometry Input and Output Functions 20
  • 21. © 2015 EnterpriseDB Corporation. All rights reserved. 21 •  Create geometry type from text Insert into cities (name,state,geom) Values (‘Bedford’,’MA’, ST_GeomFromText(‘POINT(-71.248063 42.510547)’,4326)); Geometry Input and Output Functions 21
  • 22. © 2015 EnterpriseDB Corporation. All rights reserved. 22 •  Write a function to tell whether a given lat/lon pair is within a Point-Radius ring IF ST_Dwithin(check_pt, point_pt, outerRadius) AND NOT ST_Dwithin(chevk_pt, point_pt, innerRadius) THEN return 1; ELSE Return 0; END IF; •  Create a route from a collection of waypoints captured in sequence CREATE TABLE PATHS as SELECT routeid, seq, geom FROM waypoints ORDER BY seq) a GROUP BY routeid; Power of GIS & SQL
  • 23. © 2015 EnterpriseDB Corporation. All rights reserved. 23 •  Simple distance query between two points SELECT ST_Distance (ST_GeomFromText ('POINT(34 9)’,4629), ST_GeomFromText ('POINT(70 12)’,4629)); Power of GIS & SQL 34, 9 70, 12
  • 24. © 2015 EnterpriseDB Corporation. All rights reserved. 24 •  Write a function to tell whether a given lat/lon pair is within a Point-Radius ring IF ST_Dwithin(check_pt, point_pt, outerRadius) AND NOT ST_Dwithin(chevk_pt, point_pt, innerRadius) THEN return 1; ELSE Return 0; END IF; •  Create a route from a collection of waypoints captured in sequence CREATE TABLE PATHS as SELECT routeid, st_make(gem) as geom FROM (SELECT routeid, seq, geom FROM waypoints ORDER BY seq)a GROUP BY routeid; Power of GIS & SQL
  • 25. © 2015 EnterpriseDB Corporation. All rights reserved. 25 •  Answer powerful questions with a simple query −  Input function Insert into cities (name,state,geom) Values (‘Bedford’,’MA’, ST_GeomFromText(‘POINT(-71.248063 42.510547)’, 4326)); Power of GIS & SQL
  • 26. © 2015 EnterpriseDB Corporation. All rights reserved. 26 Power of GIS & SQL
  • 27. © 2015 EnterpriseDB Corporation. All rights reserved. 27 Power of GIS & SQL
  • 28. © 2015 EnterpriseDB Corporation. All rights reserved. 28 Maintenance of a PostGIS database •  After bulk inserts and updates – VACUUM ANALYZE •  Loading large dataset: Build indexes after •  Use EXPLAIN •  Add Indexes on PostGIS columns •  Backup/Recovery and SR considerations
  • 29. © 2015 EnterpriseDB Corporation. All rights reserved. 29 •  Power of Postgres −  Binary replication, Table Partitions, Text search function and operators, PL/SQL, PL/Python, PLV8, PL/R, Indexes −  Grouping sets, cube and rollup (now in EDB Postgres Plus, coming in Postgres 9.5) −  Foreign table inheritance (new in 9.5) •  ogr2ogr •  Web Maps −  Open Layers −  Map Server −  GeoServer Notes:
  • 30. © 2015 EnterpriseDB Corporation. All rights reserved. 30