Difference between revisions of "AfricaEvents29November2008"

From OSGeo
Jump to navigation Jump to search
Line 178: Line 178:
  
 
== Shapefiles shmapefiles....real (wo)men store their data in PostGIS ==
 
== Shapefiles shmapefiles....real (wo)men store their data in PostGIS ==
 +
 +
 +
=== First we show you ===
  
 
* '''Create''' a new PostgreSQL database. To do this, open the terminal application (icon to the right of FireFox icon on the top menu bar). Now at the prompt type the following command:
 
* '''Create''' a new PostgreSQL database. To do this, open the terminal application (icon to the right of FireFox icon on the top menu bar). Now at the prompt type the following command:
Line 207: Line 210:
 
  shp2pgsql -I -s 4326 Dams.shp dams | psql workshop
 
  shp2pgsql -I -s 4326 Dams.shp dams | psql workshop
 
* Erk! What does that all mean? Lets break it down:
 
* Erk! What does that all mean? Lets break it down:
  /home/workshop/gisdata/za/brits/SAExplorer - go to our data directory
+
  cd /home/workshop/gisdata/za/brits/SAExplorer - go to our data directory
 
  shp2pgsql - an application that loads shapefiles into a PostGIS database
 
  shp2pgsql - an application that loads shapefiles into a PostGIS database
 
  -I - an option to shp2pgsql telling it to create a spatial index
 
  -I - an option to shp2pgsql telling it to create a spatial index
Line 214: Line 217:
 
  dams - the table name that the data should be loaded into
 
  dams - the table name that the data should be loaded into
 
  | psql workshop - send the results of the shp2pgsql into the psql application, workshop database
 
  | psql workshop - send the results of the shp2pgsql into the psql application, workshop database
 +
 +
 +
 +
''' XXXX Need notes here on how to open & connect with PGAdminIII XXXXX '''
  
 
* Lets take a peek inside our database now and see what we have  - back to pgadmin and refresh the database
 
* Lets take a peek inside our database now and see what we have  - back to pgadmin and refresh the database
Line 240: Line 247:
  
 
== Using PostGIS data from QGIS ==
 
== Using PostGIS data from QGIS ==
 +
 +
 +
=== First we show you ===
  
 
Once your data is in PostGIS, its easy to share across your organisation. Because it's in a database you get row level locking (instead of file locking in a shapefile), so many users can be editing and viewing data at the same time. There are many clients that let you visualise your PostGIS data..lets take a look at how we do it in QGIS.
 
Once your data is in PostGIS, its easy to share across your organisation. Because it's in a database you get row level locking (instead of file locking in a shapefile), so many users can be editing and viewing data at the same time. There are many clients that let you visualise your PostGIS data..lets take a look at how we do it in QGIS.

Revision as of 05:18, 27 November 2008

What?

Our first OSGEO local chapter meet up! We will chew the cud, show you some cool stuff and start to get people familiar with the brilliant FOSS GeoSpatial products out there!

We'll go through installing some software and getting it to a point where you can have fun with it.

How Much?

There will be a door charge of R50 to cover costs & refreshments. That and an open mind are all you need to bring. If you're staying for the QGIS session in the afternoon you can bring your laptop (Windows, Linux or Mac!)

Where?

St Davids Marist Inanda College
36 Rivonia Rd
Inanda
Sandton

Map and Directions

NB: We'll be in the Prep School computer lab.

When?

  • November 29th
  • Presentation and workshop segment: 9am to 12pm
  • QGIS Bug Party! 12h30 onwards

Who

Your friendly presenters for the day will be:

  • Tim Sutton (tim at linfiniti.com) - QGIS hacker and FOSS GIS junkie extraordinaire. Tim eats Weetbix for breakfast because it sounds like Linux. He once rewrote Nkosi Sikelela in C++ because he was feeling patriotic.
  • Graeme McFerren - (graeme.mcferren at gmail.com) - GIS researcher and FOSS4G user. Mmm, aspire to be like Tim then.
  • Gavin Fleming (gavinjfleming at gmail dot com) - I enjoy my daily FOSS4G fix and telling people how great it was. I'm a 'geoinformation scientist' at Mintek and love to see cutting edge and useful geospatial applications emerging.
  • Brendon Wolff-Piggott - (brendon at integratedgeodata.co.za) - Water resources consultant and FOSS GIS enthusiast. I wish there were more hours in the day to keep up with FOSS4G!

RSVP

Let gavinjfleming at gmail dot com know if you're coming as numbers are limited.


QGIS Bug Party

As a preview release there are still various bugs that need resolving and various elements (e.g. translation) that may be incomplete. On Saturday the 29th in Johannesburg, South Africa, members from the Africa OSGEO chapter will be holding a QGIS Bug Hunt Party. We would like to invite people from around the world to virtually participate. Each person attending will get a free copy of QGIS 1.0.0 Preview 2 absolutely free of charge! Sorry no shrink wrap copies available. Preview 2 is the second in a series of preview releases we are making before we release the Stable QGIS 1.0.0 with long term support. We are going to great lengths to polish up QGIS 1.0 for you (inside and out) and we really appreciate all the feedback we have received thus far. Its virtually impossible to ship any software completely bug free, but with your help we can add just a little more shine to the polish! We need your help to:

  • test on different machine configurations (bring your laptops!)
  • validate existing bugs on each platform
  • mark bugs that can no longer be replicated as ready for closure
  • create new tickets for bugs that have not been reported yet (please search first to avoid posting duplicates!)
  • mark bugs that are duplicates
  • provide additional diagnostics so that developers can replicate issues

The idea is not to try to *fix* the bugs, but rather to do a QA session on the bugs in the bug tracker. In the process you will learn how to interact with an Open Source project the Right Way i.e. filing good quality bug reports.

I will start off with a simple show and tell covering:

  • where to find the QGIS (and other OSGEO projects bug tracking sites)
  • creating an account so you can file non-anonymous bugs and feedback on any OSGEO project bug tracker
  • how the bug tracking system works - what the various input fields in the QGIS tracker mean

The approach will be to start by going through any bugs that have not been revised recently, adding additional status information. If you think the bug is fixed, add a comment:

Works for me now, recommend closure, <Your Name>

If you can replicate the bug, add a comment like:

Can replicate, OS: Ubuntu 8.10, QGIS Preview 2, <Your Name>

Use your initiative to deal with tickets that don't fit into the categories above, following a similar approach.


After that I will turn you loose on the queue and a shiny copy of QGIS preview 2 and let you have at it. Party is over when the last man falls asleep at the keyboard! Ok probably we will finish at between 4:30pm and 5pm if my wife has anything to do with it!


We look forward to seeing you at the QGIS Bug Party!!!


Programme in a nutshell

  • Be there in time for a 9am start
  • Morning session: Introducing QGIS, PostGIS, GeoServer, uDig
  • Afternoon session: QGIS Bug Party

Note: There will be frequent rest breaks and lots of time to ask questions!

1. Welcome, Introduction and Overview: Starting up (5 minutes)

What am I looking at here? What do I need to do to get started?

2. QGIS: Opening and viewing spatial data. Your first map. (15 minutes)

What can I look at? How do I set up a simple map? Toolbars and Plug-ins.

3. PostGIS: Why use PostGIS? Simple example of loading data. (15 minutes)

Why use a spatial database? What does one look like? How do I populate a spatial database and where does my data live?

4. QGIS: Looking at PostGIS data from QGIS. (15 minutes)

View a PostGIS database from QGIS. Setting up data definitions for PostGIS sources. Loading data into PostGIS with the Spit Loader (no, please don't touch the screen!)

5. PostGIS: More than a place to dump data... (15 minutes)

PostGIS is not just good for storing data, one can manipulate it too! GIS can be done inside the database, which is rather nice when you think about it.

6. uDig: Why uDig? GIS and the Web. (15 minutes)

Getting GIS data ready for presentation on the Web! Editing SLDs.

7. GeoServer: Tell everyone about it! (15 minutes)

Displaying GIS data on the web. Grouped WMS. Scale-dependent rendering.

8. And more QGIS.

Detail on symbology. Topological editing. QML, SPD and Openlayers. (15 minutes)

9. Show off session

Here we can do some whizz bang demo stuff that we don't have time to do in workshop format but that will give you some hints as to what else can be achieved.

10. General

Questions and answers. What you can do next. Resources. Possibly some in-depth examples based on frequent questions. What would you like to see at future workshops?

11. Your assessment of the workshop

Tell us what you thought!

Workshop Notes

Welcome, introductions and overview

Lets make a map - First steps with QGIS

First we show you

  • Open QGIS using the icon on the top Gnome Panel
  • From the Layer menu, select Add Vector Layer
 Layer -> Add Vector Layer
  • A dialog box will appear
  • Navigate to
 /home/workshop/gisdata/za/brits/SAExplorer/
  • Add the following layer :
 Provinces.shp
  • Experiment with the map navigation toolbar to zoom in / out, pan, select etc features.
  • Open the Layer properties dialog. There are several ways you can do this:
 1) Select the layer in the legend and then from the menu do Layer -> Properties
 or
 2) Right click on the layer in the legend and choose Properties from the context menu
 or
 3) Double click on the layer in the legend
  • Familiarise yourself with the various panels in the vector properties dialog.
  • Select the Symbology tab (second from the left)
  • From the Style Options panel, choose a pleasing fill colour for the provinces then
 Click OK

Now you try!

Add the following layers (also from the /home/workshop/gisdata/za/brits/SAExplorer/ directory)

 Transport_NationalRoads.shp
 Transport_Railways.shp
 RSATowns.shp
 Dams.shp

Zoom and pan around a little to explore your data Symbolise each layer with an appropriate colour to make the most awe inspring map.

Save your project using

File -> Save

And put it into

/home/workshop/gisdata/brits.qgs

What have I learned?

In ten minutes you now know how to add vector layers into QGIS, pan and zoom to navigate the map, set the colour of vectors using the Single Symbol option in the Layer Properties.

Shapefiles shmapefiles....real (wo)men store their data in PostGIS

First we show you

  • Create a new PostgreSQL database. To do this, open the terminal application (icon to the right of FireFox icon on the top menu bar). Now at the prompt type the following command:
 createdb workshop
  • Verify your database exists (once again type this into the console)
 psql -l
  • You should see something like this:
workshop@heron:~$ psql -l
       List of databases
  Name    |  Owner   | Encoding 
-----------+----------+----------
postgres  | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
workshop  | workshop | UTF8
(4 rows)
  • away from the console for a while - lets look at what a non-spatial, vanilla PostgreSQL database looks like. Open pgadmin 3 (the icon with a blue elephant face)

Specifically, let us look at Functions and Tables - don't look to deeply, this is just to show the differences after PostGIS is installed on the database (you will see later).

  • Install the PostGIS spatial data extensions (again from the console). Hint copy and paste these from the IRC channel or the wiki page!
createlang plpgsql workshop
psql workshop < /usr/share/postgresql-8.3-postgis/lwpostgis.sql
psql workshop < /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
  • Yegads! What did I just do? Firstly, you installed the plpgsql procedural language extensions into your PostgreSQL database. Then you ran two sql scripts which create the PostGIS spatial extensions to your database. You only need to do this once when you create a new spatial database, so don't worry about remembering those commands off by heart.
  • Lets upload a shapefile into the database....once more into the black hole (console window).
cd /home/workshop/gisdata/za/brits/SAExplorer
shp2pgsql -I -s 4326 Dams.shp dams | psql workshop
  • Erk! What does that all mean? Lets break it down:
cd /home/workshop/gisdata/za/brits/SAExplorer - go to our data directory
shp2pgsql - an application that loads shapefiles into a PostGIS database
-I - an option to shp2pgsql telling it to create a spatial index
-s - the coordinate reference system to use, expressed as an EPSG number. 4326 is the same as Lat/Long WGS84
Dams.shp - the filename of the shapefile to load
dams - the table name that the data should be loaded into
| psql workshop - send the results of the shp2pgsql into the psql application, workshop database


XXXX Need notes here on how to open & connect with PGAdminIII XXXXX

  • Lets take a peek inside our database now and see what we have - back to pgadmin and refresh the database

Three major thing to look at:

Hundreds of Functions for working with spatial data: geometry constructors, spatial predicates, geometry editors, geometry aggregators, geometry accessors, measurements, linear referencing and outputting  of spatial data. 
2 important meta-tables: geometry_columns (for describing the different spatial datasets) and spatial_ref_sys(a list of projections/coordinate systems and different representations thereof)


Now you try!

Load the following layers (also from the /home/workshop/gisdata/za/brits/SAExplorer/ directory)

Hydrology_DWAFRivers.shp -> call the table 'rivers'
Transport_Mainroads.shp -> call the table 'roads'
RSATowns.shp -> call the table 'towns'


What have I learned?

  • PostgreSQL is an enterprise ready relational database management system - and its Free and Open Source Software
  • You can create a new database using the createdb command.
  • PostGIS is a add on to PostgreSQL that lets you store spatial data and carry out spatial analysis within the database.
  • In order to set up PostGIS you need to run a couple of SQL scripts
  • shp2pgsql is a command line application that lets you load shapefiles into your spatial datastore

Using PostGIS data from QGIS

First we show you

Once your data is in PostGIS, its easy to share across your organisation. Because it's in a database you get row level locking (instead of file locking in a shapefile), so many users can be editing and viewing data at the same time. There are many clients that let you visualise your PostGIS data..lets take a look at how we do it in QGIS.

  • Open QGIS
  • Start a new project
 File -> New Project
  • Add a PostGIS layer
 Layer -> Add PostGIS Layer
  • From the connections list, choose workshop
 Click connect
  • In the table list, click on dams
 Click Add

Now you try!

  • Add the following layers from your database
rivers
roads
towns
  • set some nice colors for your layers - notice how the process is exactly the same as when setting colours for a shapefile.
  • save your project into
/home/workshop/gisdata/brits_pg.qgs


What have I learned?

  • You can visualise PostGIS spatial database tables inside QGIS
  • To add a PostGIS layer, use the Layer -> Add PostGIS Layer menu option.
  • Once a PostGIS layer, you can treat it just like any other (e.g. shapefile) layer
  • Your presenters are truly amazing....however would I have figured this stuff out for my self :-)