SlideShare une entreprise Scribd logo
1  sur  15
Integrating Map Data with PostGIS




     UK PostgreSQL Conference 2008

            Mark Cave-Ayland
            Sirius Corporation
What is PostGIS?


●   What is PostGIS?
    –   A collection of SQL types, operators and
        functions to “spatially enable” PostgreSQL
    –   Also includes a spatial R-Tree indexing
        scheme
         ●   Implemented using GiST
    –   This allows us to extend PostgreSQL to ask
        questions like:
         ●   How many features lie within 100m?
         ●   What is the total length of a given road?
         ●   What is the total area of water in my city?
How can we use PostGIS?


●   PostGIS can primarily be used in two
    different ways
    –   GIS object data store
         ●   ESRI Shapefiles
         ●   OS MasterMap
    –   Spatial object processing
         ●   Calculate binary predicates such as Crosses(),
             Touches(), and Intersects()
         ●   Calculate the geometric results of Intersection()
             and Union()
PostGIS dependencies


●   PostGIS makes use of two popular
    existing libraries
    –   PROJ.4
         ●   Provides co-ordinate system and on-the-fly
             reprojection support
    –   GEOS
         ●   Provides spatial predicates and geometric
             processing functions
●   But all functions can be accessed using
    SQL
Installation


●   Installation
    –   Very easy with RHEL 5
         ●   http://yum.pgsqlrpms.org/
    –   This installs the libraries required
         ●   All that remains is to load the new functions into
             the database
    –   PostGIS provides 2 files:
         ●   lwpostgis.sql
              –   Main operators and types (ST prefixed)
         ●   spatial_ref_sys.sql
              –   A list of international spatial reference systems
Creating a spatial database


●   Creating a spatial database
    –   PostGIS requires PL/PGSQL
    postgres@cleopatra:~$ createdb postgis
    CREATE DATABASE
    postgres@cleopatra:~$ createlang plpgsql postgis
    postgres@cleopatra:~$ psql ­d postgis /usr/share/postgresql/lwpostgis.sql
    postgres@cleopatra:~$ psql ­d postgis /usr/share/postgresql/spatial_ref_sys.sql




●   Check that everything is working
    postgis=# SELECT postgis_full_version();
                                    postgis_full_version
    ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
     POSTGIS="1.3.2" GEOS="3.0.0­CAPI­1.4.1" PROJ="Rel. 4.6.0, 21 Dec 2007" USE_STATS
    (1 row)




●   Now we can start adding geometries
PostGIS Geometries


●   PostGIS supports OGC-compliant
    geometries
    –   From the Open Geospatial Consortium
         ●   http://www.opengeospatial.org/
         ●   Geometries are defined as part of the “OpenGIS
             Simple Features Implementation Specification for
             SQL”
         ●   The specification can be downloaded for free
    –   PostGIS has been officially certified as OGC
        SFS 1.1 compliant
Basic Geometry Types


●   Basic OGC geometry types
    –   POINT
    –   POLYGON
    –   LINESTRING
●   Geometry array types
    –   MULTIPOINT
    –   MULTIPOLYGON
    –   MULTILINESTRING
    –   GEOMETRYCOLLECTION
Basic Geometry Examples


●   Basic geometry examples
    postgis=# SELECT ST_AsText(ST_GeomFromText('POINT(4 51)'));
      st_astext
    ­­­­­­­­­­­­­
     POINT(4 51)
    (1 row)

    postgis=# SELECT ST_AsText(ST_GeomFromText('LINESTRING(0 0, 1 1, 2 2, 3 3)'));
              st_astext
    ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
     LINESTRING(0 0,1 1,2 2,3 3)
    (1 row)

    postgis=# SELECT ST_AsText(ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'));
               st_astext
    ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
     POLYGON((0 0,0 1,1 1,1 0,0 0))
    (1 row)

    postgis=# SELECT ST_AsText(ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 ­1))'));
    ERROR:  geometry contains non­closed rings
    CONTEXT:  SQL function "st_geomfromtext" statement 1

    postgis=# SELECT ST_AsText(ST_GeomFromText('LINESTRING(0,0 1,1 2,2 3,3)'));
    ERROR:  parse error ­ invalid geometry
    CONTEXT:  SQL function "st_geomfromtext" statement 1
More complex queries


●   These examples use the free datasets
    from http://mappinghacks.com
●   Imported into PostGIS from ESRI
    Shapefiles
    –   World Borders
         ●   Country outlines stored as 2D POLYGONs
    –   Cities
         ●   POINTs representing major cities throughout the
             world
More complex queries

●   Example 1
      ●    Given a table of countries, find the names of all of
           the countries that border Chad
          postgis=# SELECT t1.cntry_name FROM world_borders t1, world_borders t2 WHERE 
          ST_Touches(t1.the_geom, t2.the_geom) AND t2.cntry_name = 'Chad';
                  cntry_name        
          ­­­­­­­­­­­­­­­­­­­­­­­­­­
           Libya
           Niger
           Sudan
           Cameroon
           Central African Republic
           Nigeria
          (6 rows)
More complex queries

●   Example 2
      ●    Given a table of cities and a table of countries,
           find the total number of cities within each country
           and return the list in alphabetical order
          postgis=# SELECT world_borders.cntry_name, COUNT(world_borders.cntry_name) 
           FROM cities, world_borders WHERE ST_Within(cities.the_geom, world_borders.the_geom)
           GROUP BY world_borders.cntry_name
           ORDER BY world_borders.cntry_name;

           cntry_name  | count
          ­­­­­­­­­­­­­+­­­­­­­
           Afghanistan |     3
           Albania     |     1
           Algeria     |     5
           Angola      |     3
           Argentina   |     9
           Armenia     |     1
           Australia   |    14
           Austria     |     5
           Azerbaijan  |     1
           Bangladesh  |     3

          ... etc ...
Tools that can use PostGIS


●   There are many GIS tools that can access
    data within PostGIS
    –   Open source
         ●   JUMP
         ●   QGIS
         ●   GeoServer
         ●   MapServer
    –   Some proprietary support also exists
         ●   CadCorp SIS
         ●   Safe Software FME
         ●   ESRI
Tools that can use PostGIS


●   Similarly any applications that can
    connect to PostgreSQL can access spatial
    data
    –   Java, PHP, Perl etc.
●   This allows data to loaded into online
    mapping applications such as Google
    Maps
●   Wrapper classes are available for most
    languages
Demonstration & Questions


●   Demonstration & Questions




●   For more information:
    –   http://postgis.refractions.net
●   Or specific enquiries:
    –   http://www.siriusit.co.uk

Contenu connexe

En vedette

Salas de informatica
Salas de informaticaSalas de informatica
Salas de informaticaLELIOMOJICA
 
Skincare Online Qual Case Study
Skincare Online Qual Case StudySkincare Online Qual Case Study
Skincare Online Qual Case StudyMrQual
 
Enabling model based decision support[1]
Enabling model based decision support[1]Enabling model based decision support[1]
Enabling model based decision support[1]Karl Glorstad
 
演示文稿1
演示文稿1演示文稿1
演示文稿1bryan630
 
An Introduction to Online Qualitative Research Methods
An Introduction to Online Qualitative Research MethodsAn Introduction to Online Qualitative Research Methods
An Introduction to Online Qualitative Research MethodsMrQual
 
Skincare transcript mr qual excerpt
Skincare transcript mr qual excerptSkincare transcript mr qual excerpt
Skincare transcript mr qual excerptMrQual
 
Be a local insider
Be a local insider Be a local insider
Be a local insider Geopieces
 
Change Lessons Learned - Implementing a Kanban System for Enterprise Agility
Change Lessons Learned - Implementing a Kanban System for Enterprise AgilityChange Lessons Learned - Implementing a Kanban System for Enterprise Agility
Change Lessons Learned - Implementing a Kanban System for Enterprise AgilityShoaib Shaukat
 
HIPPA Compliance
HIPPA ComplianceHIPPA Compliance
HIPPA Compliancedixibee
 
Business Agility and Organisational Learning
Business Agility and Organisational LearningBusiness Agility and Organisational Learning
Business Agility and Organisational LearningShoaib Shaukat
 
8 permendiknasno-41tahun2007standarproses
8 permendiknasno-41tahun2007standarproses8 permendiknasno-41tahun2007standarproses
8 permendiknasno-41tahun2007standarprosescatalova
 

En vedette (13)

Salas de informatica
Salas de informaticaSalas de informatica
Salas de informatica
 
Skincare Online Qual Case Study
Skincare Online Qual Case StudySkincare Online Qual Case Study
Skincare Online Qual Case Study
 
Bank mini
Bank miniBank mini
Bank mini
 
Enabling model based decision support[1]
Enabling model based decision support[1]Enabling model based decision support[1]
Enabling model based decision support[1]
 
Dear all
Dear allDear all
Dear all
 
演示文稿1
演示文稿1演示文稿1
演示文稿1
 
An Introduction to Online Qualitative Research Methods
An Introduction to Online Qualitative Research MethodsAn Introduction to Online Qualitative Research Methods
An Introduction to Online Qualitative Research Methods
 
Skincare transcript mr qual excerpt
Skincare transcript mr qual excerptSkincare transcript mr qual excerpt
Skincare transcript mr qual excerpt
 
Be a local insider
Be a local insider Be a local insider
Be a local insider
 
Change Lessons Learned - Implementing a Kanban System for Enterprise Agility
Change Lessons Learned - Implementing a Kanban System for Enterprise AgilityChange Lessons Learned - Implementing a Kanban System for Enterprise Agility
Change Lessons Learned - Implementing a Kanban System for Enterprise Agility
 
HIPPA Compliance
HIPPA ComplianceHIPPA Compliance
HIPPA Compliance
 
Business Agility and Organisational Learning
Business Agility and Organisational LearningBusiness Agility and Organisational Learning
Business Agility and Organisational Learning
 
8 permendiknasno-41tahun2007standarproses
8 permendiknasno-41tahun2007standarproses8 permendiknasno-41tahun2007standarproses
8 permendiknasno-41tahun2007standarproses
 

Similaire à Post gispguk

Integrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsIntegrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsCommand Prompt., Inc
 
공간정보연구원 PostGIS 강의교재
공간정보연구원 PostGIS 강의교재공간정보연구원 PostGIS 강의교재
공간정보연구원 PostGIS 강의교재JungHwan Yun
 
Pg intro part1-theory_slides
Pg intro part1-theory_slidesPg intro part1-theory_slides
Pg intro part1-theory_slideslasmasi
 
Building Location Aware Apps - Get Started with PostGIS, PART I
Building Location Aware Apps - Get Started with PostGIS, PART IBuilding Location Aware Apps - Get Started with PostGIS, PART I
Building Location Aware Apps - Get Started with PostGIS, PART Ilasmasi
 
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterFOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterJorge Arevalo
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech ProjectsJody Garnett
 
Postgres Vision 2018: PostGIS and Spatial Extensions
Postgres Vision 2018: PostGIS and Spatial ExtensionsPostgres Vision 2018: PostGIS and Spatial Extensions
Postgres Vision 2018: PostGIS and Spatial ExtensionsEDB
 
Building Location Aware Apps - Get Started with PostGIS, PART II
Building Location Aware Apps - Get Started with PostGIS, PART IIBuilding Location Aware Apps - Get Started with PostGIS, PART II
Building Location Aware Apps - Get Started with PostGIS, PART IIlasmasi
 
2017 RM-URISA Track: Spatial SQL - The Best Kept Secret in the Geospatial World
2017 RM-URISA Track:  Spatial SQL - The Best Kept Secret in the Geospatial World2017 RM-URISA Track:  Spatial SQL - The Best Kept Secret in the Geospatial World
2017 RM-URISA Track: Spatial SQL - The Best Kept Secret in the Geospatial WorldGIS in the Rockies
 
Introduction To PostGIS
Introduction To PostGISIntroduction To PostGIS
Introduction To PostGISmleslie
 
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...Citus Data
 
오픈소스 GIS 교육 - PostGIS
오픈소스 GIS 교육 - PostGIS오픈소스 GIS 교육 - PostGIS
오픈소스 GIS 교육 - PostGISJungHwan Yun
 
Using python to analyze spatial data
Using python to analyze spatial dataUsing python to analyze spatial data
Using python to analyze spatial dataKudos S.A.S
 
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...HaNJiN Lee
 
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINAGetting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINAJISC GECO
 
LX 공간정보아카데미 PostGIS 강의자료
LX 공간정보아카데미 PostGIS 강의자료LX 공간정보아카데미 PostGIS 강의자료
LX 공간정보아카데미 PostGIS 강의자료JungHwan Yun
 

Similaire à Post gispguk (20)

Integrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsIntegrating PostGIS in Web Applications
Integrating PostGIS in Web Applications
 
공간정보연구원 PostGIS 강의교재
공간정보연구원 PostGIS 강의교재공간정보연구원 PostGIS 강의교재
공간정보연구원 PostGIS 강의교재
 
An Introduction to Postgresql
An Introduction to PostgresqlAn Introduction to Postgresql
An Introduction to Postgresql
 
Pg intro part1-theory_slides
Pg intro part1-theory_slidesPg intro part1-theory_slides
Pg intro part1-theory_slides
 
Building Location Aware Apps - Get Started with PostGIS, PART I
Building Location Aware Apps - Get Started with PostGIS, PART IBuilding Location Aware Apps - Get Started with PostGIS, PART I
Building Location Aware Apps - Get Started with PostGIS, PART I
 
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterFOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
Postgres Vision 2018: PostGIS and Spatial Extensions
Postgres Vision 2018: PostGIS and Spatial ExtensionsPostgres Vision 2018: PostGIS and Spatial Extensions
Postgres Vision 2018: PostGIS and Spatial Extensions
 
Building Location Aware Apps - Get Started with PostGIS, PART II
Building Location Aware Apps - Get Started with PostGIS, PART IIBuilding Location Aware Apps - Get Started with PostGIS, PART II
Building Location Aware Apps - Get Started with PostGIS, PART II
 
2017 RM-URISA Track: Spatial SQL - The Best Kept Secret in the Geospatial World
2017 RM-URISA Track:  Spatial SQL - The Best Kept Secret in the Geospatial World2017 RM-URISA Track:  Spatial SQL - The Best Kept Secret in the Geospatial World
2017 RM-URISA Track: Spatial SQL - The Best Kept Secret in the Geospatial World
 
Introduction To PostGIS
Introduction To PostGISIntroduction To PostGIS
Introduction To PostGIS
 
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
 
오픈소스 GIS 교육 - PostGIS
오픈소스 GIS 교육 - PostGIS오픈소스 GIS 교육 - PostGIS
오픈소스 GIS 교육 - PostGIS
 
Using python to analyze spatial data
Using python to analyze spatial dataUsing python to analyze spatial data
Using python to analyze spatial data
 
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
PINOGIO : A simple way to create a web infographic map (피노지오 : 웹 인포그래픽 맵을 만드는...
 
Pycon2011
Pycon2011Pycon2011
Pycon2011
 
Spatial
SpatialSpatial
Spatial
 
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINAGetting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
Getting Started with PostGIS geographic database - Lasma Sietinsone, EDINA
 
Getting started with PostGIS geographic database
Getting started with PostGIS geographic databaseGetting started with PostGIS geographic database
Getting started with PostGIS geographic database
 
LX 공간정보아카데미 PostGIS 강의자료
LX 공간정보아카데미 PostGIS 강의자료LX 공간정보아카데미 PostGIS 강의자료
LX 공간정보아카데미 PostGIS 강의자료
 

Dernier

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Dernier (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

Post gispguk

  • 1. Integrating Map Data with PostGIS UK PostgreSQL Conference 2008 Mark Cave-Ayland Sirius Corporation
  • 2. What is PostGIS? ● What is PostGIS? – A collection of SQL types, operators and functions to “spatially enable” PostgreSQL – Also includes a spatial R-Tree indexing scheme ● Implemented using GiST – This allows us to extend PostgreSQL to ask questions like: ● How many features lie within 100m? ● What is the total length of a given road? ● What is the total area of water in my city?
  • 3. How can we use PostGIS? ● PostGIS can primarily be used in two different ways – GIS object data store ● ESRI Shapefiles ● OS MasterMap – Spatial object processing ● Calculate binary predicates such as Crosses(), Touches(), and Intersects() ● Calculate the geometric results of Intersection() and Union()
  • 4. PostGIS dependencies ● PostGIS makes use of two popular existing libraries – PROJ.4 ● Provides co-ordinate system and on-the-fly reprojection support – GEOS ● Provides spatial predicates and geometric processing functions ● But all functions can be accessed using SQL
  • 5. Installation ● Installation – Very easy with RHEL 5 ● http://yum.pgsqlrpms.org/ – This installs the libraries required ● All that remains is to load the new functions into the database – PostGIS provides 2 files: ● lwpostgis.sql – Main operators and types (ST prefixed) ● spatial_ref_sys.sql – A list of international spatial reference systems
  • 6. Creating a spatial database ● Creating a spatial database – PostGIS requires PL/PGSQL postgres@cleopatra:~$ createdb postgis CREATE DATABASE postgres@cleopatra:~$ createlang plpgsql postgis postgres@cleopatra:~$ psql ­d postgis /usr/share/postgresql/lwpostgis.sql postgres@cleopatra:~$ psql ­d postgis /usr/share/postgresql/spatial_ref_sys.sql ● Check that everything is working postgis=# SELECT postgis_full_version();                                 postgis_full_version ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  POSTGIS="1.3.2" GEOS="3.0.0­CAPI­1.4.1" PROJ="Rel. 4.6.0, 21 Dec 2007" USE_STATS (1 row) ● Now we can start adding geometries
  • 7. PostGIS Geometries ● PostGIS supports OGC-compliant geometries – From the Open Geospatial Consortium ● http://www.opengeospatial.org/ ● Geometries are defined as part of the “OpenGIS Simple Features Implementation Specification for SQL” ● The specification can be downloaded for free – PostGIS has been officially certified as OGC SFS 1.1 compliant
  • 8. Basic Geometry Types ● Basic OGC geometry types – POINT – POLYGON – LINESTRING ● Geometry array types – MULTIPOINT – MULTIPOLYGON – MULTILINESTRING – GEOMETRYCOLLECTION
  • 9. Basic Geometry Examples ● Basic geometry examples postgis=# SELECT ST_AsText(ST_GeomFromText('POINT(4 51)'));   st_astext ­­­­­­­­­­­­­  POINT(4 51) (1 row) postgis=# SELECT ST_AsText(ST_GeomFromText('LINESTRING(0 0, 1 1, 2 2, 3 3)'));           st_astext ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  LINESTRING(0 0,1 1,2 2,3 3) (1 row) postgis=# SELECT ST_AsText(ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'));            st_astext ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­  POLYGON((0 0,0 1,1 1,1 0,0 0)) (1 row) postgis=# SELECT ST_AsText(ST_GeomFromText('POLYGON((0 0, 0 1, 1 1, 1 0, 0 ­1))')); ERROR:  geometry contains non­closed rings CONTEXT:  SQL function "st_geomfromtext" statement 1 postgis=# SELECT ST_AsText(ST_GeomFromText('LINESTRING(0,0 1,1 2,2 3,3)')); ERROR:  parse error ­ invalid geometry CONTEXT:  SQL function "st_geomfromtext" statement 1
  • 10. More complex queries ● These examples use the free datasets from http://mappinghacks.com ● Imported into PostGIS from ESRI Shapefiles – World Borders ● Country outlines stored as 2D POLYGONs – Cities ● POINTs representing major cities throughout the world
  • 11. More complex queries ● Example 1 ● Given a table of countries, find the names of all of the countries that border Chad postgis=# SELECT t1.cntry_name FROM world_borders t1, world_borders t2 WHERE  ST_Touches(t1.the_geom, t2.the_geom) AND t2.cntry_name = 'Chad';         cntry_name         ­­­­­­­­­­­­­­­­­­­­­­­­­­  Libya  Niger  Sudan  Cameroon  Central African Republic  Nigeria (6 rows)
  • 12. More complex queries ● Example 2 ● Given a table of cities and a table of countries, find the total number of cities within each country and return the list in alphabetical order postgis=# SELECT world_borders.cntry_name, COUNT(world_borders.cntry_name)   FROM cities, world_borders WHERE ST_Within(cities.the_geom, world_borders.the_geom)  GROUP BY world_borders.cntry_name  ORDER BY world_borders.cntry_name;  cntry_name  | count ­­­­­­­­­­­­­+­­­­­­­  Afghanistan |     3  Albania     |     1  Algeria     |     5  Angola      |     3  Argentina   |     9  Armenia     |     1  Australia   |    14  Austria     |     5  Azerbaijan  |     1  Bangladesh  |     3 ... etc ...
  • 13. Tools that can use PostGIS ● There are many GIS tools that can access data within PostGIS – Open source ● JUMP ● QGIS ● GeoServer ● MapServer – Some proprietary support also exists ● CadCorp SIS ● Safe Software FME ● ESRI
  • 14. Tools that can use PostGIS ● Similarly any applications that can connect to PostgreSQL can access spatial data – Java, PHP, Perl etc. ● This allows data to loaded into online mapping applications such as Google Maps ● Wrapper classes are available for most languages
  • 15. Demonstration & Questions ● Demonstration & Questions ● For more information: – http://postgis.refractions.net ● Or specific enquiries: – http://www.siriusit.co.uk