SlideShare a Scribd company logo
1 of 33
Download to read offline
Databases and Web Mapping the Open Source Way
OSGIS 2010: Centre for Geospatial Sciences, Nottingham
June 2010



Jo Cook
OA Digital

j.cook@oadigital.net
01524 880212
Beyond Google Maps and Mashups
Practicalities


● Download:
www.archaeogeek.com/downloads/osgis2010.zip
●Save to /home/user and extract

●The folder /home/user/osgis2010 contain:

 shape_files (folder)
 demo.map
 mapserver.html
 baselayers.html
 osgis_2010_notes.pdf (same as handout)
Introduction
Introduction




               3




               2


               1
Databases



                          +
            www.postgresql.org
            postgis.refractions.net
 ●   Server-based database (not like access)
 ●   Enterprise-level, with support for
      transactions and multiple users
Ways to connect
How to connect to a database


●   HOST: localhost, 192.168.3.40, myserver.com
●   DATABASE: ??? (your choice)
●   USERNAME: user
●   PASSWORD: user
●   PORT: 5432 (default)
Getting spatial data into PostgreSQL

●   OGR2OGR (command line)
●   SHP2PGSQL (command line)
●   SPIT plugin for Quantum GIS
●   Essential Parameters:
     host, username, password, dbname,
     port (as before)
    name and location of shapefile, name of
     table in database, coordinate system of
     data
Installing Quantum GIS plugins
Loading data with SPIT

Create new database with pgadmin3
 and connect to it with SPIT in QGIS
SPIT (continued)




                   Change to lower-case!
Database house-keeping

●   Each table should have a primary key
●   Each spatial table should be recorded in
     the geometry_columns table
●   Each spatial table should have a spatial
     index
    CREATE INDEX yourtable_idx ON
     yourtable USING
     GIST(geometry_column);
Querying data
●   SQL: Structured Query Language
    SELECT some comma de-limited
     columns FROM your_table WHERE
     some condition is met;
●   Use PSQL from command line, PgAdmin3,
     or PostgreSQL Manager/SQL Editor
●   There is no escape from typing out your
     query!
Spatial Querying

●   Find out which county a point is in and
      show it on the map:
    CREATE VIEW whichcounty AS SELECT
      “PROV3NAME” FROM
      united_kingdom_counties WHERE
      st_within(geomfromtext('point(-1.4
      52.6)', 4326), the_geom);
Map Servers
Types of Map Server

●   Minnesota Map Server (aka Mapserver)
    cgi program on a web server.
      Configuration via text files
●   Geoserver
    java-based program. Configuration via
      web interface
The Map File
MAP
      NAME "sample"
      STATUS ON
      SIZE 600 400
      EXTENT -180 -90 180 90
      UNITS DD
      SHAPEPATH "../data"
      IMAGECOLOR 255 255 255
      WEB
          IMAGEPATH "/ms4w/tmp/ms_tmp/"
          IMAGEURL "/ms_tmp/"
      END
      LAYER
          NAME 'global-raster'
          TYPE RASTER
          STATUS DEFAULT
          DATA bluemarble.gif
      END
END
Checking and Viewing a map file


●   SHP2IMG at the command line
    shp2img -m
     /home/user/osgis2010/demo.map
     -o /home/user/demo.png
●   With a browser
    http://localhost.com/cgi-
     bin/mapserv?
     map=/home/user/osgis2010/demo.map
     &mode=map
Adding new layers to a mapfile

LAYER
  NAME "your layer"
  STATUS DEFAULT
  TYPE POLYGON
  DATA "yourshapefile.shp" (relative to the
“data” parameter in your mapfile)
  CLASS
        NAME "your name for this symbology"
        OUTLINECOLOR 60 60 60
        COLOR 255 255 0
        SYMBOL 0
     END
END
Displaying single layers



●   Set the Layer status to “ON” rather than
     “DEFAULT”
●   Specify the layers as part of the URL:
     http://localhost/cgi-
     bin/mapserv?
     map=/home/user/osgis2010/demo.
     map&layer=layer1
Connecting to PostgreSQL from Mapserver

LAYER
  NAME "UK Counties"
  STATUS DEFAULT
  TYPE POLYGON
  CONNECTIONTYPE POSTGIS
  CONNECTION "host=localhost port=5432
dbname=osgis2010 user=user password=user"
  DATA "the_geom from united_kingdom_counties"
  CLASS
  …
  END
END
Web Servers and Web Pages
Structure of a web page

<html>

  <head>
     <title> My Home Page
</title>
  </head>

   <body>
     HELLO WORLD!
   </body>

</html>
Scripting


●   SERVER-SIDE:
    php, asp
         <?php
                 phpinfo();
         ?>
●   CLIENT-SIDE:
    javascript
Solving Problems using Firefox
Solving Problems using the mailing lists

              RTFM j00 n00b!!!
• Get latest version of software
• Read the manual/help documentation
• Search the mailing list archives
• Strip as much detail out of your code as
possible
• Provide as much information as you can
about your setup and the steps you have
already taken
And finally...Web Mapping
OpenLayers page structure
<html>
   <head>
       <script
src="http://www.openlayers.org/api/OpenLayers.js"></script>
       <script type="text/javascript">
          var map, mylayer;
            function init() {
          map = new OpenLayers.Map('map');
          mylayer = new OpenLayers.Layer.MapServer( "World Map",
              "http://localhost/cgi-bin/mapserv.exe",
              {map: 'C:/world_mapfile.map'});
          map.addLayer(mylayer);
          map.zoomToMaxExtent();
          }
       </script>
   </head>
   <body onload="init()">
       <div id="map" style="width: 600px; height: 300px"></div>
   </body>
</html>
Adding Controls



                     Scale Bars, Permalink
                     and Mouse Position




Layer Switcher and
Overview Map
Base Mapping
●   Can use base data from Google, Microsoft,
     Yahoo, Openstreetmap etc
●   Specify base layer (not always necessary)
     {'isBaseLayer': true}
●   Overlay needs to be transparent
     {'transparent':true, 'format':
     png}
●   Change addlayers directive
     map.addLayers([layer1,layer2]);
Beyond OpenLayers

•MapGuide Open Source
http://mapguide.osgeo.org
•Mapfish http://mapfish.org/
•Mapchat http://mapchat.ca/
•Featureserver http://featureserver.org/
And Finally...


       Open Source Web Mapping is Great Fun!!!




This work is licenced under the Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License. To
view a copy of this licence, visit http://creativecommons.org/licenses/by-sa/2.0/uk/ or send a letter to Creative
Commons, 171 Second Street, Suite 300, San Francisco, California
94105, USA.

                                                                                          Jo Cook
                                                                                          OA Digital
                                                                                          http://oadigital.net
                                                                                          j.cook@oadigital.net
                                                                                          +44 (0)1524 880212

More Related Content

Similar to Worskhop OSGIS2010

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
 
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map WidgetsESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map WidgetsAllan Glen
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece CoLab Athens
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsSergi Almar i Graupera
 
map3d_mapguide_postgis
map3d_mapguide_postgismap3d_mapguide_postgis
map3d_mapguide_postgisPrasad PANDIT
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebJames Rakich
 
Spark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboolaSpark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboolatsliwowicz
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceOSCON Byrum
 
Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL SchemaSean Chittenden
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformWSO2
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendMySQLConference
 
Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)Radek Simko
 
Web enabling your survey business ppt version
Web enabling your survey business ppt versionWeb enabling your survey business ppt version
Web enabling your survey business ppt versionrudy_stricklan
 
Geo script opengeo spring 2013
Geo script opengeo spring 2013Geo script opengeo spring 2013
Geo script opengeo spring 2013Ilya Rosenfeld
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCAndroid Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCJim Tochterman
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGapAlex S
 
Leicester 2010 notes
Leicester 2010 notesLeicester 2010 notes
Leicester 2010 notesJoanne Cook
 

Similar to Worskhop OSGIS2010 (20)

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
 
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map WidgetsESRI Dev Meetup: Building Distributed JavaScript Map Widgets
ESRI Dev Meetup: Building Distributed JavaScript Map Widgets
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSockets
 
map3d_mapguide_postgis
map3d_mapguide_postgismap3d_mapguide_postgis
map3d_mapguide_postgis
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
 
Seti 09
Seti 09Seti 09
Seti 09
 
Spark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboolaSpark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboola
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open Source
 
Scripting GeoServer
Scripting GeoServerScripting GeoServer
Scripting GeoServer
 
Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL Schema
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
 
Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)
 
Web enabling your survey business ppt version
Web enabling your survey business ppt versionWeb enabling your survey business ppt version
Web enabling your survey business ppt version
 
Geo script opengeo spring 2013
Geo script opengeo spring 2013Geo script opengeo spring 2013
Geo script opengeo spring 2013
 
Web mapswithleaflet
Web mapswithleafletWeb mapswithleaflet
Web mapswithleaflet
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCAndroid Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
 
Leicester 2010 notes
Leicester 2010 notesLeicester 2010 notes
Leicester 2010 notes
 

More from Joanne Cook

Consuming open and linked data with open source tools
Consuming open and linked data with open source toolsConsuming open and linked data with open source tools
Consuming open and linked data with open source toolsJoanne Cook
 
Intro to the Open Source Geospatial Foundation
Intro to the Open Source Geospatial FoundationIntro to the Open Source Geospatial Foundation
Intro to the Open Source Geospatial FoundationJoanne Cook
 
Intro to Quantum GIS Desktop GIS
Intro to Quantum GIS Desktop GISIntro to Quantum GIS Desktop GIS
Intro to Quantum GIS Desktop GISJoanne Cook
 
Introduction to OSGeo:UK
Introduction to OSGeo:UKIntroduction to OSGeo:UK
Introduction to OSGeo:UKJoanne Cook
 
The Business Case for Open Source GIS
The Business Case for Open Source GISThe Business Case for Open Source GIS
The Business Case for Open Source GISJoanne Cook
 
Open Source and Open Data
Open Source and Open DataOpen Source and Open Data
Open Source and Open DataJoanne Cook
 
Consuming and Publishing Ordnance Survey Open Data with Open Source Software
Consuming and Publishing Ordnance Survey Open Data with Open Source SoftwareConsuming and Publishing Ordnance Survey Open Data with Open Source Software
Consuming and Publishing Ordnance Survey Open Data with Open Source SoftwareJoanne Cook
 
AGI 2010: It's all one big opportunity
AGI 2010: It's all one big opportunityAGI 2010: It's all one big opportunity
AGI 2010: It's all one big opportunityJoanne Cook
 
Lancaster University GIS Course 2010
Lancaster University GIS Course 2010Lancaster University GIS Course 2010
Lancaster University GIS Course 2010Joanne Cook
 
How archaeologists use GIS
How archaeologists use GISHow archaeologists use GIS
How archaeologists use GISJoanne Cook
 
The Impact of Open Source
The Impact of Open SourceThe Impact of Open Source
The Impact of Open SourceJoanne Cook
 
Open Source GIS for Local Government
Open Source GIS for Local GovernmentOpen Source GIS for Local Government
Open Source GIS for Local GovernmentJoanne Cook
 
Foss4g Portable Gis
Foss4g Portable GisFoss4g Portable Gis
Foss4g Portable GisJoanne Cook
 
Agi Techsig 2009
Agi Techsig 2009Agi Techsig 2009
Agi Techsig 2009Joanne Cook
 

More from Joanne Cook (20)

Consuming open and linked data with open source tools
Consuming open and linked data with open source toolsConsuming open and linked data with open source tools
Consuming open and linked data with open source tools
 
Intro to the Open Source Geospatial Foundation
Intro to the Open Source Geospatial FoundationIntro to the Open Source Geospatial Foundation
Intro to the Open Source Geospatial Foundation
 
Intro to Quantum GIS Desktop GIS
Intro to Quantum GIS Desktop GISIntro to Quantum GIS Desktop GIS
Intro to Quantum GIS Desktop GIS
 
Introduction to OSGeo:UK
Introduction to OSGeo:UKIntroduction to OSGeo:UK
Introduction to OSGeo:UK
 
The Business Case for Open Source GIS
The Business Case for Open Source GISThe Business Case for Open Source GIS
The Business Case for Open Source GIS
 
Open Source and Open Data
Open Source and Open DataOpen Source and Open Data
Open Source and Open Data
 
Consuming and Publishing Ordnance Survey Open Data with Open Source Software
Consuming and Publishing Ordnance Survey Open Data with Open Source SoftwareConsuming and Publishing Ordnance Survey Open Data with Open Source Software
Consuming and Publishing Ordnance Survey Open Data with Open Source Software
 
AGI 2010 Notes
AGI 2010 NotesAGI 2010 Notes
AGI 2010 Notes
 
AGI 2010: It's all one big opportunity
AGI 2010: It's all one big opportunityAGI 2010: It's all one big opportunity
AGI 2010: It's all one big opportunity
 
Lancaster University GIS Course 2010
Lancaster University GIS Course 2010Lancaster University GIS Course 2010
Lancaster University GIS Course 2010
 
How archaeologists use GIS
How archaeologists use GISHow archaeologists use GIS
How archaeologists use GIS
 
The Impact of Open Source
The Impact of Open SourceThe Impact of Open Source
The Impact of Open Source
 
Open Source GIS for Local Government
Open Source GIS for Local GovernmentOpen Source GIS for Local Government
Open Source GIS for Local Government
 
Bcs Talk Notes
Bcs Talk NotesBcs Talk Notes
Bcs Talk Notes
 
Gateway Seminar
Gateway SeminarGateway Seminar
Gateway Seminar
 
Foss4g Portable Gis
Foss4g Portable GisFoss4g Portable Gis
Foss4g Portable Gis
 
Bcs Talk Notes
Bcs Talk NotesBcs Talk Notes
Bcs Talk Notes
 
Agi 2008
Agi 2008Agi 2008
Agi 2008
 
Agi North
Agi NorthAgi North
Agi North
 
Agi Techsig 2009
Agi Techsig 2009Agi Techsig 2009
Agi Techsig 2009
 

Recently uploaded

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Worskhop OSGIS2010

  • 1. Databases and Web Mapping the Open Source Way OSGIS 2010: Centre for Geospatial Sciences, Nottingham June 2010 Jo Cook OA Digital j.cook@oadigital.net 01524 880212
  • 2. Beyond Google Maps and Mashups
  • 3. Practicalities ● Download: www.archaeogeek.com/downloads/osgis2010.zip ●Save to /home/user and extract ●The folder /home/user/osgis2010 contain: shape_files (folder) demo.map mapserver.html baselayers.html osgis_2010_notes.pdf (same as handout)
  • 5. Introduction 3 2 1
  • 6. Databases + www.postgresql.org postgis.refractions.net ● Server-based database (not like access) ● Enterprise-level, with support for transactions and multiple users
  • 8. How to connect to a database ● HOST: localhost, 192.168.3.40, myserver.com ● DATABASE: ??? (your choice) ● USERNAME: user ● PASSWORD: user ● PORT: 5432 (default)
  • 9. Getting spatial data into PostgreSQL ● OGR2OGR (command line) ● SHP2PGSQL (command line) ● SPIT plugin for Quantum GIS ● Essential Parameters: host, username, password, dbname, port (as before) name and location of shapefile, name of table in database, coordinate system of data
  • 11. Loading data with SPIT Create new database with pgadmin3 and connect to it with SPIT in QGIS
  • 12. SPIT (continued) Change to lower-case!
  • 13. Database house-keeping ● Each table should have a primary key ● Each spatial table should be recorded in the geometry_columns table ● Each spatial table should have a spatial index CREATE INDEX yourtable_idx ON yourtable USING GIST(geometry_column);
  • 14. Querying data ● SQL: Structured Query Language SELECT some comma de-limited columns FROM your_table WHERE some condition is met; ● Use PSQL from command line, PgAdmin3, or PostgreSQL Manager/SQL Editor ● There is no escape from typing out your query!
  • 15. Spatial Querying ● Find out which county a point is in and show it on the map: CREATE VIEW whichcounty AS SELECT “PROV3NAME” FROM united_kingdom_counties WHERE st_within(geomfromtext('point(-1.4 52.6)', 4326), the_geom);
  • 17. Types of Map Server ● Minnesota Map Server (aka Mapserver) cgi program on a web server. Configuration via text files ● Geoserver java-based program. Configuration via web interface
  • 18. The Map File MAP NAME "sample" STATUS ON SIZE 600 400 EXTENT -180 -90 180 90 UNITS DD SHAPEPATH "../data" IMAGECOLOR 255 255 255 WEB IMAGEPATH "/ms4w/tmp/ms_tmp/" IMAGEURL "/ms_tmp/" END LAYER NAME 'global-raster' TYPE RASTER STATUS DEFAULT DATA bluemarble.gif END END
  • 19. Checking and Viewing a map file ● SHP2IMG at the command line shp2img -m /home/user/osgis2010/demo.map -o /home/user/demo.png ● With a browser http://localhost.com/cgi- bin/mapserv? map=/home/user/osgis2010/demo.map &mode=map
  • 20. Adding new layers to a mapfile LAYER NAME "your layer" STATUS DEFAULT TYPE POLYGON DATA "yourshapefile.shp" (relative to the “data” parameter in your mapfile) CLASS NAME "your name for this symbology" OUTLINECOLOR 60 60 60 COLOR 255 255 0 SYMBOL 0 END END
  • 21. Displaying single layers ● Set the Layer status to “ON” rather than “DEFAULT” ● Specify the layers as part of the URL: http://localhost/cgi- bin/mapserv? map=/home/user/osgis2010/demo. map&layer=layer1
  • 22. Connecting to PostgreSQL from Mapserver LAYER NAME "UK Counties" STATUS DEFAULT TYPE POLYGON CONNECTIONTYPE POSTGIS CONNECTION "host=localhost port=5432 dbname=osgis2010 user=user password=user" DATA "the_geom from united_kingdom_counties" CLASS … END END
  • 23. Web Servers and Web Pages
  • 24. Structure of a web page <html> <head> <title> My Home Page </title> </head> <body> HELLO WORLD! </body> </html>
  • 25. Scripting ● SERVER-SIDE: php, asp <?php phpinfo(); ?> ● CLIENT-SIDE: javascript
  • 27. Solving Problems using the mailing lists RTFM j00 n00b!!! • Get latest version of software • Read the manual/help documentation • Search the mailing list archives • Strip as much detail out of your code as possible • Provide as much information as you can about your setup and the steps you have already taken
  • 29. OpenLayers page structure <html> <head> <script src="http://www.openlayers.org/api/OpenLayers.js"></script> <script type="text/javascript"> var map, mylayer; function init() { map = new OpenLayers.Map('map'); mylayer = new OpenLayers.Layer.MapServer( "World Map", "http://localhost/cgi-bin/mapserv.exe", {map: 'C:/world_mapfile.map'}); map.addLayer(mylayer); map.zoomToMaxExtent(); } </script> </head> <body onload="init()"> <div id="map" style="width: 600px; height: 300px"></div> </body> </html>
  • 30. Adding Controls Scale Bars, Permalink and Mouse Position Layer Switcher and Overview Map
  • 31. Base Mapping ● Can use base data from Google, Microsoft, Yahoo, Openstreetmap etc ● Specify base layer (not always necessary) {'isBaseLayer': true} ● Overlay needs to be transparent {'transparent':true, 'format': png} ● Change addlayers directive map.addLayers([layer1,layer2]);
  • 32. Beyond OpenLayers •MapGuide Open Source http://mapguide.osgeo.org •Mapfish http://mapfish.org/ •Mapchat http://mapchat.ca/ •Featureserver http://featureserver.org/
  • 33. And Finally... Open Source Web Mapping is Great Fun!!! This work is licenced under the Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License. To view a copy of this licence, visit http://creativecommons.org/licenses/by-sa/2.0/uk/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. Jo Cook OA Digital http://oadigital.net j.cook@oadigital.net +44 (0)1524 880212