Posted by & filed under QGIS.

Recently, XKCD strayed into our territory with this page about map projections:

Map Projections

To be honest, I’ve always like Gall-Peters myself, if only as a way to illustrate how map projections distort the appearance of continents. It’s quite effective at conveying this concept, because it distorts things in the opposite direction of the universally familiar Mercator. If you’re using it as a legitimate map projection, though, I honestly don’t know what to say to you.

Posted by & filed under QGIS.

Here is a nice article about teaching a semester course with FOSSGIS that William Kinghorn put me on to:

However, most students are shocked to discover how many capable FOSS GIS software packages exist and are excited that they can just download and install them, even on a Mac. They ask questions like, “Why isn’t everyone using QGIS?” Frequently students end the semester wanting more.

See the article here:  http://www.directionsmag.com/articles/experiences-teaching-free-and-open-source-gis-at-the-community-college/212522

 

Posted by & filed under QGIS.

At the recent get-together, I made a bunch of short clips with most of the attendees. These are presented below (or on my youtube channel). My apologies if you need to tilt your head 90′ left for some of them, YouTube’s online video editor is still a work in progress it seems… Just play the first video and the rest will follow automatically.

Read more »

Posted by & filed under QGIS.

I am writing this sitting on the plane making the ~25 hour return trip from Zurich to Swellendam (via Dubai) and as has become tradition, I thought I am making this summary of the activities at our bi-annual QGIS developer meeting. The developer meetings themselves have become a huge propellant to the project – bringing together developers and users from all areas of the project and providing a forum for us to plan and discuss things at a level of detail that simply isn’t possible via email, IRC and so on. The meeting also acts as a catalyst where a few moments spent between two people can provide the needed knowledge transfer to enable new contributions of code, bug fixes, documentation or whatever else is needed to cross a barrier that would otherwise prevent a person from helping the project.

 

We have now held developer meetings in Hannover, Vienna, Pisa, Wroclaw, Lisbon and Zurich and due to the kind contributions of our project sponsors have increasingly been able to cover the costs of attendees. This year all the meals were paid for by sponsors / donations, as well as the travel and accommodation for some developers. A number of Zurich residents also opened the doors of  their homes to provide accommodation for attendees. In addition each attendee contributed time out of their personal and professional lives that if we were to pay for this time in professional fees would amount to a massive investment.

This year the QGIS project has had two silver sponsors and the increasing levels of sponsorship are really a fantastic enabler for us to move the project forward significantly. I am looking forward to the day when funding levels have reached the level that a number of us can be employed by the project to work on improving it in a general way rather than meeting the specific needs of a single client.  For more information on how to sponsor or donate to the project, please see http://qgis.org/en/sponsorship.html.

Our host for the meeting was the Institute of Cartography, ETH Zurich. We would especially like to thank the following people who facilitated the meeting:

  • Ionut Iosifescu for helping to organize the meeting and arranging for permission for ETH to host it.
  • Prof. Lorenz Hurni,  department head at the institute for generously agreeing to host the meeting.
  • Corina Pachlatko – the secretary for organization and providing food/coffee!
  • The State of Vorarlberg (our latest silver sponsor) for their donation which covered the costs for attendee travel and accommodation and really helped to jump start proceedings.
  • Peter Oberholzer  from the City of Uster for covering food expenses.
  • Marco Hugentobler, Pirmin Kalberer and Mathias Walker from Sourcepole for helping to organise the meeting.
  • The City of Uster paid for the food/bread/supermarket bills.
  • Andreas Neumann who helped to organise the event and donated his time and money to make it happen.

There are many more who worked hard behind the scenes to make the event happen, and we extend our thanks to you all! The food provided was really tasty including these delicious salty ‘pretzel’ things:

Delicious food and snacks kept the attendees going at full tilt!

Delicious food and snacks kept the attendees going at full tilt!

 

Read more »

Posted by & filed under QGIS.

Today is the start of our 7th? QGIS developer meeting. This time it is being hosted at the Institute of Cartography, ETH Zurich. Yesterday I gave a presentation about some of the people behind the project and tried to demonstrate the societal benefits that are being realised by a project such as QGIS. For those interested, it is available here.

QGIS Presentation

QGIS Presentation

Today the hackfest is kicking off with with various talks including an in depth discussion on PostGIS topology and potential support for it within QGIS.

 

Posted by & filed under Postgres & PostGIS.

Just a quickie because I always forget this and need to look it up again. If you have a query in postgresql and you want to include a sequential identifier in the output, you can use the very handy ROW_NUMBER() function. Note, you need Postgresql 8.4+ I believe. Here is a quick example:

create view vw_farms
as
select ROW_NUMBER() over (order by parcel.farm_name) as id,
parcel.farm_name,
parcel.geometry
from parcel
where parcel.farm_name != '' limit 10 ;

Which returns something like this:

 id |     farm_name
----+-------------------
  1 | ADDERLEY 66
  2 | ADDERLEY 66
  3 | ADDERLEY 66
  4 | ADDERLEY 66
  5 | ADDERLEY 66
  6 | AFDAKS RIVIER 575
  7 | AFDAKS RIVIER 575
  8 | AFDAKS RIVIER 575
  9 | AFDAKS RIVIER 575
 10 | AFDAKS RIVIER 575
(10 rows)

This function is documented in the Postgresql docs here.

One more thing – if you would like to use the above technique to bring a view into QGIS which does not otherwise meet QGIS’ requirement that the view have a column derived from a primary key or a column with a unique constraint on it, you can cast the row number to int4 like this:

create view vw_farms
as
select int4(ROW_NUMBER() over (order by parcel.farm_name)) as id,
parcel.farm_name,
parcel.geometry
from parcel
where parcel.farm_name != '' limit 10 ;

The last step then is to explicitly tell QGIS to use this column as the primary key. Do this in the PostgGIS add layer dialog, by selecting the view and then selecting the id field from the combo box available in the primary key column as illustrated in the image below.

Specify the primary key column manually

Specify the primary key column manually

 

 

Posted by & filed under Web Development.

The jQuery JavaScript library allows you to select any element on a webpage and modify it. I will assume you already know how it works, or at least what it’s for. Now, say you have a table containing the following:

<tr id="123" class="employee">
  <td class="name">John Smit</td>
  <td><img src="..." class="image" /></td>
</tr>
<tr id="983" class="employee">
  <td class="name">Juan Smith</td>
  <td><img src="..." class="image" /></td>
</tr>
<tr id="219" class="superhero">
  <td class="name">Mr. Incredible</td>
  <td><img src="..." class="image" /></td>
</tr>


Selecting only the employee elements (assuming that the class “employee” is not used elsewhere) can be done via ‘$(“.employee”)’. For example:

$(".employee").css("color", "red");


would set the names of both employees to red. Similarly, it’s easy enough to select a specific row and hide the person’s name:

$("#219.name").hide();


But what if you have a situation where a certain element is being passed to your function as an object? You have the variable ‘myRow’, for example; and it’s an unknown (to you) element on your page. And now you want to hide only the image within that row. You don’t know the id you’ve been given, you just have the object. Even if you get the object’s id out via myRow.attr(“id”), how can you pass it to your jQuery selector? And how can you select and hide the image? Using something like

$("#219.image").hide();


would not work, because (even assuming you get the ID in there somehow) the “image” element is two levels down. The row with id 219 does not have a child of the “image” class. It has a classless child which in turn has a child of the “image” class. So the selector “#219.image” will return nothing. This seems like quite the unsolvable problem. (EDIT: see the comments for a way to do this without jQuery as suggested by Barry Rowlingson.)

It turns out that jQuery already has a neat, pre-packaged solution for this conundrum. It’s the .find() function, and in our example, it could be used like this:

myRow.find(".image").hide();


Very simple, and very useful! Pass it an element on your page, and you can select any child of a given class.

Posted by & filed under Postgres & PostGIS.

Here is a little batch script I wrote to backup my postgresql databases all in one go. I use similar scripts on my servers but this on is a bit different in that it has an outer loop to backup the three different instances of postgres I have running on my system, each in turn (I am running 8.4, 9.0 and 9.1).

#!/bin/bash
MYDATE=$(date +%d-%m-%Y)
for PORT in 5432 5433 5434
do 
  echo "Backups on port $PORT"
  export PGPORT=$PORT
  LIST=$(psql -l | awk '{ print $1 }' | grep '^[a-z]' | grep -v template | grep -v postgres)
  for ITEM in $LIST
  do 
    NAME=${ITEM}-${MYDATE}.dmp
    echo "Backing up $ITEM to $NAME"
    pg_dump -Fc -f $NAME ${ITEM}
  done
done

The ‘LIST’ variable uses a little awk and grep to pull out just the database names from each running instance.  To restore any of the dumps, you can do:

createdb foo; pg_restore foo.dmp | psql foo

 

 

Posted by & filed under QGIS.

Just a quick note on something I noticed earlier this week. Since we’ve been using a combination of Django and JavaScript for our websites, we’re passing a lot of values around between the two, including booleans. Unexpectedly, something stopped working as soon as I started sending Python booleans to a Django template. The template was supposed to create valid JSON, but the JavaScript on the other end didn’t seem to know whether the original (Python) boolean was true or false.

The answer turned out to be quite simple: whereas Python uses an initial upper-case letter for its booleans, JavaScript does not. So don’t just pass Python booleans on to a Django template if JavaScript is getting that value next. Instead, evaluate the boolean variable beforehand and pass the strings “true”/”false” on to your template accordingly.