Posts tagged ‘openstreetmap’

Updates to Online Users Map

Online Users Map with OpenStreetMap

I’ve finally had a bit of time to work on the online users map block I wrote a while ago – the recent release of Moodle 2 being a bit of a spur. Two main changes I’ve made:

Firstly, I added the option to use either Google Maps or OpenStreetMap, with the default being OpenStreetMap, but you can easily change it in the block settings.

Secondly, I managed to get the block up and running in Moodle 2 (see it in action). It needed a few changes over the previous version to get it to work. I’m still having a few issues with getting the block to update the cron field in the mdl_blocks table – so currently you need to update the blocks table manually to enable the cron function, which automatically updates the user locations.

Any feedback welcome 🙂

Playing with heatmaps

My 'hello world' heatmap

Over that past few days I’ve been playing around with creating heatmaps to overlay onto OpenStreetMap – the image on the left is where I’ve got to so far. My interest in this is for creating heatmaps from data collected during my colleagues health sciences research in Ethiopia.

There are already several programs and services available to create heatmaps, for example gheat and OpenHeatMap. But none of these quite suited me, gheat because I didn’t want to create a full tile server – just an image to overlay on a particular area of the map and OpenHeatMap because I wanted to have access to the code to tweak how I wanted.

I then found heatmap.py which (using a similar algorithm to gheat) did almost exactly what I wanted. There were only a couple of changes that I needed to make:

1) Update to account for the Mercator projection – I wanted my overlay to be on a view of the whole world (zoom level 2 in OpenStreetMap). When I first ran the program the areas over northern Europe (and others) were almost but not quite inline with the marker overlays, but this was due to the projection. I just edited the input script to convert my lat/lng coordinates into Mercator coordinates. I also hooked up the heatmap.py script to read the lat/lng coordinated from a MySQL database.

2) Allow the script to have weights against each point. The current script looks at the number of points in a particular area (or on top of each other) to generate the ‘heat’. I also wanted to allow for points to have a weight – as mentioned here. I’ve not yet implemented the weighting, but I’m not anticipating this to be too tricky. GHeat (as far as I can tell) doesn’t allow for weights on points, but OpenHeatMap does (please let me know if I’m wrong about this).

All has been much easier than I’d expected, I’ve learnt a little more about python and once I’ve got the weighting working how I’d like, then I’ll share the code back.

Running my own OpenStreetMap server

UK map generated on my OSM server

UK map generated on my OSM server

After using OpenStreetMap in a fairly limited way for the past year or so, essentially just to upload data/tracks from wandering around Ethiopia, I thought I’d have a closer look, especially as a possible replacement for Google Maps which I was using a lot whilst at the OU.

Firstly I looked at how I could use OSM and the OpenLayers API as an alternative for the map in my Online Users Map – which certainly looks feasible. So I’m now thinking about making this an option in the block settings, as shouldn’t be too much work to provide the option.

I also set up my own open street map server (instructions for installing on Ubuntu Lucid Lynx). Although quite a long process everything worked well first time with no errors. I didn’t download the entire 8Gb+ OSM dataset to generate my tiles, rather I just selected a much smaller area of detailed data (using extracts from GeoFabrik and CloudMade). This avoided the potential ’30 hours or longer’ process of importing the world into my database – the whole dataset for Ethiopia took less than 30 seconds to import.

The only part where I ran into a problem was at the very end when I wanted to generate all the tiles. When I ran ./generate_tiles.py I kept getting an error telling me that osm-local.xml didn’t exist. Fortunately this was quite an easy fix, I just needed to edit ~/bin/mapnik/generate_tiles.py to point to ~/bin/mapnik/osm.xml instead, then all ran fine (generating 55Mb+ of png images).

I could then create an alias in my Apache to point to my generated tiles and create a slippy map using OpenLayer and the tiles generated on my desktop.

I still have a lot to learn about all this, especially with what can be done with Mapnik for generating tiles (and the python script necessary to achieve it) and using OpenLayers as a replacement for Google Maps API – but all going well so far 🙂

Ashenda Festival

Turns out that the signing and dancing I mentioned yesterday is the Ashenda festival. It also goes on for several days, so I’m still getting stopped in the street and asked for money!

In an attempt to avoid getting stopped quite so often I thought it’d be better to go out on my bike. This mainly worked, though there we a few times when I was almost knocked off by groups of kids trying to stop me to give them money! Fortunately I was going quite slowly and didn’t actually get knocked off. Out on the bike I was able to do some more mapping for OpenStreetMap, adding some roads that I don’t usually walk along. After uploading these updates for OpenStreetMap I took a look at Mekelle on Google Maps. Last time I looked, several months ago now, there was virtually nothing marked, but now there’s almost a complete map. I’m interested to know where they got this data from, given that most of the printed maps I’ve seen of this region aren’t great and certainly don’t include many of the new residential areas on the outskirts of town.

Yesterday I also went to the cinema for the first time I’ve been back, to watch Teza, an Ethiopian film about a doctor returning to his home village near Lake Tana during the 70’s and 80’s. Although depressing in parts, it was well worth watching – the film won best film at an African film festival earlier this year. I had expected it to mainly be in Amharic, hopefully with English subtitles, but it was actually almost all in English. For info, the word ‘teza’ roughly translates as drop or drip.

If anyone feels like posting something over to me then anything, postcards, packet cheese sauce, etc, it would be much appreciated… the address is:

PO Box 3060
Mekelle University
Mekelle
Tigray
Ethiopia

Cheers!

Settled back

IMG_0301I’ve now been back in Ethiopia only 2 weeks and I’ve got back into the way of life here very quickly. Work has been very busy making arrangements for the networking and furnishing of the two new computer labs, ensuring all the necessary equipment has been ordered. Most of the orders have now gone off, the final part is the order for the tables for the labs. This morning I went up to the agricultural college in Wukro to ask them to build the tables for us – the photo above is one of their main workshops, now just waiting for them to return with a quote.

I’ve been spending far too much time in line taxis (local minibuses) traveling between the three university campuses, my office is at one campus and the labs we’re building are at each of the others. So I’ve had little time in front of the computer. In a way this is fortunate as the power supply has been very poor, so I wouldn’t have got much done in my office anyway. We’re also due to be moving the Computer Science dept to the main campus later this week. The new building still has no network connection, so I’m not sure how that will work when the new students arrive in less than a month.

All the traveling around town has given me plenty of opportunity to use my GPS and contribute towards the OpenStreetMap of Mekelle (there was none before). Here is the map as it currently stands (I’ve yet to upload the changes following my trip up to Wukro):

osm-mekelle

View the ‘live’ version of the map with my most recent edits.

Last weekend I had a few people over to visit and I finally went to visit the second of the only two tourist attractions in Mekelle, Emperor Yohannes palace. Good to finally go, though not entirely sure it was worth the 10 month wait before visiting!

OpenStreetMaps without the gadgets

Maybe I didn’t need to buy myself GPS after all… (from tecznotes):

Walking Papers is a website and a service designed to close this final loop by providing OpenStreetMap print maps that can be marked up with a pen, scanned back into the computer, and traced using OSM’s regular web-based editor, Potlatch. It’s designed for the casual mapper who doesn’t want to fill their pockets with gadgets to record what’s around them, the social mapper who might be out and about taking notes and comparing them with friends, and the opportunistic mapper who might make notes during a commute or a walk if they had a notebook-sized slip of paper to write on. Finally, it’s designed for the luddite mapper who would like to help the OpenStreetMap project but needs help from a distributed community to convert their handwritten annotations into OpenStreetMap’s tagged data and local conventions.

My first edits to OpenStreetMap

josmSince I’ve been back in the UK, although I’ve been pretty much tied to the house, with Amazon now back available to me, I’m able to spend money again. One of the items I bought was a GPS. Originally I was going to be borrowing one from someone in Addis to be able to do some mapping of Mekelle, but since I’m in the UK it seemed to make sense to get hold of my own whilst I was here. I eventually opted for the very basic Garmin eTrex H, thinking that it does everything I would want and I’m unlikely to spend money buying maps to download onto it – the main reason for buying it was to contribute to the OpenStreetMap project.

Once it had arrived my first challenge was getting it hooked up to my Asus EeePC (running Ubuntu) and installing the right bits of software.

For up & downloading to the GPS I installed QLandkarte, which only started recognising my device once I’d also installed the gpsbabel package.

Next I needed a desktop program for editing OpenStreetMap – using the online Potlatch application wouldn’t be a great option for me once back in Ethiopia with no decent internet connection.

I started off by installing Merkaartor but quickly ran into problems. When I tried connecting to the OpenStreetMap (OSM) server to download a map to edit, I kept getting “403: Forbidden” messages. The problem was that the particular version of Merkaartor the Ubuntu package manager installs doesn’t work with OSM Protocol v0.6. I think there may be a version of Merkaartor which works with v0.6, but I’m not generally very keen on installing software outside the Ubuntu Add/Remove Applications

I then tried Java OpenStreetMap (JOSM), again installing from the Add/Remove Apps and I was getting similar problems in being unable to connect to the OSM server. Again the problem was the protocol version.

Merkaartor and JOSM appeared to be the only programs available for editing OSM on Ubuntu (please let me know if there are others), so I had to resign myself to manually installing one of them. I opted for JOSM as it was quite easy to run manually and once installed all seems to be working relatively well.

I do however had a few gripes about the user interface, especially on the small screen of the Asus EeePC. For example some of the dialog boxes are fiddly to expand to get the OK/Cancel buttons to appear. Also, the drop down list of “presets” (the different map features, places of interest, amenities etc which can be added) is too long to appear on the screen, but there’s no way of navigating down to the bottom of the list to see which options are available.

Apart from that, I feel like I’ve got the hang of OSM editing (a little at least) and I’ve managed to add a few new roads. Hopefully once I get back to Mekelle, I’ll be much more productive, especially since I’ll be starting on a blank canvas.