SlideShare a Scribd company logo
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, EDINA
JISC 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 Widgets
Allan 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 WebSockets
Sergi 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 Web
James Rakich
 
Seti 09
Seti 09Seti 09
Seti 09
bzanchet
 
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
tsliwowicz
 
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
OSCON Byrum
 
Scripting GeoServer
Scripting GeoServerScripting GeoServer
Scripting GeoServer
Jared Erickson
 
Codified PostgreSQL Schema
Codified PostgreSQL SchemaCodified PostgreSQL Schema
Codified PostgreSQL Schema
Sean 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
 
Web mapswithleaflet
Web mapswithleafletWeb mapswithleaflet
Web mapswithleaflet
OUEDRAOGO Najibe Jean Jacques
 
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 DrupalGap
Alex 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 tools
Joanne 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 Foundation
Joanne Cook
 
Intro to Quantum GIS Desktop GIS
Intro to Quantum GIS Desktop GISIntro to Quantum GIS Desktop GIS
Intro to Quantum GIS Desktop GIS
Joanne 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 opportunity
Joanne 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 GIS
Joanne 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
 
Gateway Seminar
Gateway SeminarGateway Seminar
Gateway Seminar
Joanne Cook
 
Foss4g Portable Gis
Foss4g Portable GisFoss4g Portable Gis
Foss4g Portable Gis
Joanne Cook
 
Bcs Talk Notes
Bcs Talk NotesBcs Talk Notes
Bcs Talk Notes
Joanne Cook
 
Agi 2008
Agi 2008Agi 2008
Agi 2008
Joanne Cook
 
Agi North
Agi NorthAgi North
Agi North
Joanne Cook
 
Agi Techsig 2009
Agi Techsig 2009Agi Techsig 2009
Agi Techsig 2009
Joanne 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

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 

Recently uploaded (20)

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 

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