Your SlideShare is downloading. ×
0
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Databases and web mapping the Open Source way
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Databases and web mapping the Open Source way

1,955

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,955
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
52
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Databases and Web Mapping the Open Source Way Open Source GIS Masterclass, Lancaster University January 2010 Jo Cook OA Digital j.cook@oadigital.net 01524 880212    
  • 2. Introduction
  • 3. Introduction 3 2 1
  • 4. Databases + www.postgresql.org postgis.refractions.net ● Server­based database (not like access) ● Enterprise­level, with support for  transactions and multiple users
  • 5. How to connect to a database ● HOST: localhost, 192.168.3.40, myserver.com ● DATABASE ● USERNAME ● PASSWORD ● PORT: Usually 5432
  • 6. Ways to connect
  • 7. Getting spatial data into PostgreSQL ● OGR2OGR ● SHP2PGSQL Syntax: $shp2pgsql /location/of/file.shp tablename  ­s coordinate system ­W latin1 | psql ­d  database ­U username ­W ­h host ­p  port
  • 8. 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 or  PgAdmin3
  • 9. Spatial Querying ● Find out which county a point is in: SELECT name_2 FROM tblcounties WHERE  st_within(geomfromtext('point(­1.3 54.26)',  4326), the_geom); ● Find out which counties border  Lancashire: SELECT a.name_2 FROM tblcounties a,  tblcounties b WHERE b.name_2='Lancashire'  AND a.the_geom && b.the_geom;
  • 10. Map Servers
  • 11. 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
  • 12. 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
  • 13. Checking the map file ● SHP2IMG $shp2img ­m /location/of/mapfile.map ­o  /location/of/outputfile.png ● WITH THE BROWSER http://yourserver.com/cgi­bin/mapserv? map=/location/of/mapfile.map&mode=map
  • 14. Connecting to PostgreSQL from Mapserver LAYER   NAME "province"   STATUS ON   TYPE POLYGON   CONNECTIONTYPE POSTGIS   CONNECTION "host=localhost port=5432 dbname=canada user=postgres  password=postgres"   DATA "the_geom from province" END
  • 15. Web Servers and Web Pages
  • 16. Structure of a web page <html> <head> <title> My Home Page </title> </head> <body> HELLO WORLD! </body> </html>
  • 17. Scripting ● SERVER­SIDE: php, asp ● CLIENT­SIDE: javascript
  • 18. And finally...Web Mapping <html> <head> <script src="http://www.openlayers.org/api/OpenLayers.js"></script> <script type="text/javascript"> var map;  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>
  • 19. Base Mapping and Map Controls ● Can use base data from Google,  Microsoft, Yahoo, Openstreetmap etc,  but may need to reproject to EPSG  900913 (spherical mercator) ● Can add map controls such as layer  switchers, coordinates, reference maps  and so on
  • 20. Beyond OpenLayers •MapGuide Open Source http://mapguide.osgeo.org •Mapfish http://mapfish.org/ •Mapchat http://mapchat.ca/ •Featureserver http://featureserver.org/
  • 21. 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

×