SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie Worskhop OSGIS2010

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
 

Ähnlich wie Worskhop OSGIS2010 (20)

Getting started with PostGIS geographic database
Getting started with PostGIS geographic databaseGetting started with PostGIS geographic database
Getting started with PostGIS geographic database
 
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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 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