Author Archive

3d visualisation and DEM creation in QGIS with the GRASS plugin

A note from Sam in the Linfiniti team:

The last two weeks of FOSS GIS training courses (posted about here and here) have been impressive.  High-five to the trainers, Tim and Gavin, for their hard work!  Having only being at Linfiniti for a short time, I was assisting with the courses but also learning some things about the software myself.  This is just one of the nice things I learnt from the QGIS course.

Using the GRASS plugin in QGIS opens you to a whole host of new tools.  The plugin makes GRASS more accessible, and simplifies the complexity of GRASS datasets, so that more users will be able to benefit from the GRASS functionality available.

You can convert vector contour lines to a raster DEM, and then visualise the DEM in 3D. The steps below are written for newbies (like I was!), so skip the detail if you an experienced user ;)

1. Setting up your mapset and adding your data

When the GRASS plugin is enabled in QGIS, you will get a GRASS toolbar added. Open your contour shapefile in QGIS as you usually would, then click New mapset on the GRASS plugin toolbar. For those new to GRASS mapsets, here are some guidelines:

  • specify the directory (you can make a ‘grass’ folder in your home directory – it is important you have full read/write access)
  • create a new location – think of this as a project folder based on a certain location (geographical extent)
  • assign the projection of your dataset (your projection will be fixed for the location and mapset)
  • under the default GRASS region section, click the ‘Set current QGIS extent’ button
  • enter the mapset name (this will be your username – each user can have a mapset in the location, the ‘project folder’)

Once you’ve setup, you will see a red outline around the data in your QGIS view, this is your mapset extents.

Click the GRASS tools icon on the toolbar, and find the option to import your vector or raster.  Here’s the vector import:

Once you click the function, select the layer to add (the list will show those layers open in QGIS), type a name and click run.

You will also need to add the newly created grass layer to your QGIS view – this will make it accessible for subsequent grass functions.  Add the layer by clicking ‘view output’ after running the function, or in the browser tab in the GRASS tools dialog – click refresh, find the file and click the add icon.

2. Creating a DEM from contours

Now for the interesting bits.  Make sure your vector contour from your grass mapset is open.  Under the Module list in the GRASS tools dialog, find and run these functions in this order:

  • v.to.rast.attr -> converts your vector to raster based on an attribute (use the height attribute from the contours).  Open your result once its run.
  • r.surf.contour -> creates a surface from the rasterized contours.  Tip: edit your mapset region (last icon on the grass toolbar) to adjust the output area to your dataset- this will save time!  Open your result once its run.

3. Visualisation in 3D using nviz

In the modules list, find nviz. This can be used to visualise any DEM data, and you can add overlays.  Using a nice colour map as explained in Tim’s post will produce a catching effect.  Running the module, and adjusting the settings (z-exaggeration, lighting, perspective etc) will give you a dynamic 3D view of your data.  Nviz is also apparently capable of 3D fly-throughs for those interested in exploring a bit more.

Voila, and there you go!  And this was all created from the comfort of your QGIS environment, thanks to the awesome plugins that have been added! :)

Hope this helps, and if you’ve got any questions, feel free to leave a comment!

-Sam

FOSS GIS presentation at Cape Tech

Things have been busy – I just back from training course in Tanzania, and last week I was giving a lecture and practical at the Cape Peninsula University of Technology. Lecturer Kevin Musungu from the Civil Engineering and Surveying Department at Cape Technikon asked us to give a presentation on open source GIS after meeting Tim at the QGIS workshop earlier this year. We were happy to introduce them to open source GIS and QGIS as they had currently had no exposure to this side and relied heavily on propriety GIS software. The Head of Department also came to sit in the lecture and had some good questions regarding open source as an alternative.

The class were third-year BTech surveying students that were doing a course in GIS. Some of them are already involved in the working environment, such as the SA governmental Department of Rural Development and Land Affairs. Another visiting attendee was planning to put GIS into a practical, live project to assist his community.

The lecture started off with an introduction to the FOSS movement, with some background on how it started. We then went onto open source GIS, along with a few case studies of open source GIS. This included the Department of Land Affair’s Introduction to GIS resources, mention of the OpenModeller project and AFIS project. Then I went onto QGIS, introducing the software and some of the features, along with a demo.

Talking about free & open source GIS

Talking about free & open source GIS

Later that week, we followed up with a practical using QGIS and showing how it could achieve the same results that they did their practical test in ArcGIS. Added to that the students were all given discs to take home (thank you to Kevin for organising this) and will be able to use QGIS at home.

I explained to them the different ways on how to get help: through the user manuals, wiki’s, forums, IRC and mailing lists. Feedback from the class was good One of the students commented on the user friendliness of the interface and another was interested in doing an internship on open source GIS technology.

Students using QGIS:

Addition to the Linfiniti team

Just an update to let you know that I have recently joined Linfiniti. I was lucky enough to be an intern earlier in the year, and am happy to be part of the team again, and helping in bringing Open Source GIS to Africa and other parts of the world :)

A quick introduction – my name’s Samantha Lee Pan (sam for short).  I have an undergrad in environmental & geographical science (with a second major in oceanography!)  I’ve done my honours in GIS.  I am also looking at doing a masters degree in the environmental field.

There is still a lot that I am learning here at Linfiniti and been very busy with a host of different projects. But I’m sure you will be hearing more from me, as I find useful bits of info or updates on the FOSS scene – and make time to post them here!

keep well

-sam

Learning about Free Open Source Software (FOSS) through my Linfiniti internship

When I started off this internship, I had little practical experience of Open Source software. I had heard about it, and knew that it was an interesting, expanding field for a collective good, but hadn’t an opportunity to delve in deeper through my education career.

This internship has given me that opportunity and exposed me to a whole range of Open Source tools, especially those related to GIS. The programme was run so that touched on a variety of sections, explaining basic concepts and applying this information to practical projects. The sections could later be built on, beyond the internship. The training also included work from live projects running at Linfinti Consulting, which was a rewarding experience because it involved interaction with clients and handing over a product at the end of the day.

The days usually began with a session from Tim or Anne explaining what we would be covering that day. They explained all the necessary theory in a down-to-earth, and understandable way, ensuring that we understood. And after that we would get busy with our clicking, typing, learning and building. They would patiently assist us when we got stuck, and help us get to the root of the issue when there were bigger problems.

Tim and Anne were both excellent, knowledgable and practical teachers with tremendous enthusiasm for Open Source GIS, which has left me inspired.

Some of the new tools and concepts I was exposed to:

  • Concepts of FOSS and the FOSS GIS stack
  • Linux operating system – some bash, basic tools and software on Linux
  • PostGIS – (first time I’ve used a geodatabase through open source :) and seen its practicality!)
  • Qgis – user interface, new symbology and cartography, plugins (very useful!)
  • Programming - coding in Python to create our own Qgis plugins, coding standards, SVN
  • Open source community support – through IRC, mailing lists and forums
  • GRASS - introduction to the interface and commands, and practical application in flood simulation
  • Mapserver, Openlayers – exporting QGIS projects to mapfiles, editing symbology of the mapfiles, displaying through OpenLayers
  • HTML, CSS, Javascript (JQuery) – linking these up, and building a webpage
  • Joomla CMS

Tim also expained how all these sections were connected and added to one another, and we got to see this through our own practical work.

I really enjoyed and learnt a lot, and would like to thank Tim, Anne, Marcelle and Robert for the valuable time I spent here. It’s a sad goodbye to the team and office, but I am hoping that the new skills that I have learnt here will contribute positively to the future.

Looking foward to FOSS GIS growing in Africa! \o/

- sam

Dissolving features by an attribute

Hi, I’m Sam. I’ve been learning a lot here at Linfiniti (thanks to the brilliant team!) Just like to add a quick note on one of the tasks I learnt this week.

I was working on a shapefile of the suburbs in Cape Town. A client required the suburbs to be grouped by region. After the tedious part of manually grouping the suburbs (using a created field, REGION), the unioning (dissolving) of the suburbs proved to be quick and painless through PostgreSQL, using this SQL command that implements the geomunion function:

create table ct_regions as select geomunion(the_geom), "REGION" \
 from "ct_suburbs" group by "REGION";

“ct_suburbs” is the original shapefile that was loaded into the PostGIS database using the Quantum GIS ‘SPIT’ plugin. “REGION” is the class (attribute) that I wish to union by.  And ct_regions will be the output shapefile. See the result here:

Before dissolving (ct_suburbs shows suburbs)

Cape Town suburbs before dissolving

After dissolving by suburbs (ct_regions shows collections of suburbs that have been merged)

Cape Town suburbs after dissolving

Hopefully this will be of some use when it comes to your own mapping!