Interesting Tech Projects
Posts tagged OpenStreetMap
50,000 Point GPS Track in Silverlight
Mar 1st
About six months ago I posted a video showing a GPS track with 7,000 points in a slippy map control called DeepEarth. If you watch the video you can see that the track lags behind the map a little and I think I was at the limit of what was usable.
Yesterday I wrote about my new C# based slippy map control for Silverlight and Moonlight that can display 50,000 map markers and I wanted to see what it’s performance was like for a GPS track. I created a random track with 50,000 points in it to simulate a track from a GPS unit. Here is the result. More >
50,000 Map Markers in Silverlight
Feb 28th
There are a range of pan and zoom map controls (sometimes called slippy maps) available for C#/.NET and Silverlight/Moonlight. All the ones I’ve seen have something in common – they are bloated. The authors attempt to address the needs of as many users as possible and the result is large downloads and far too many features. The forums and mailing lists are full of people asking how to achieve basic functionality because they are lost in the vast realm of classes.
Of course, it is possible to remove what you don’t need but that requires understanding the code and after all that effort you are left with code that might not have the right license for your needs. The solution? Time to cringe – reinventing the wheel.
Fortunately it’s not much of a wheel, assuming your requirements are simple as mine are. C# and good development tools (Visual Studio and MonoDevelop) makes it easy to quickly develop a lightweight and flexible slippy map that can be used in Windows, Mac OS X and Linux (using Moonlight). More >
Poster Map of East Yorkshire
Jan 19th
Using data from the OpenStreetMap project (taken a couple of days ago) along with some utilities such as Maperitive and custom software, I have generated a 39 inch x 31 inch poster of the East Riding of Yorkshire. This map includes hillshading and contour lines and individual streets can be seen.
Some assembly is required. Print it out on A4 paper, cut out the sheets and then glue them together. Download it here.
Here is a sample:
So You Want to be a Cartographer?
Jan 16th
Love maps? Want to make your own? Now it’s easy thanks to a set of free software.
Previously I wrote about the OpenStreetMap project, which allows anyone to edit a map of the world. People can add points, lines and areas and “tag” them to show what they are. Once the data is uploaded a new version of the map is generated for everyone to see.
For example I could create a point on the map and tag it with “railway=station” to indicate that it is a train station. I could draw a line and tag it with “highway=residential” to mark the line as a residential road. I could also draw an enclosed area and tag it with “landuse=forest” to show that the area is a forest. There are many different tags that can be used to represent all kinds of things that appear on maps.
This article is in the form of a tutorial to get you quickly started creating your own maps. I will introduce the software involved and show how to use it step by step. The result of the tutorial is a map of the North Yorkshire Moors Railway, which is a steam train service on a historic train line in England and is featured in the Harry Potter films.
Optimizing DeepEarth For GIS Mapping
Sep 5th
DeepEarth is an interesting Silverlight project. It allows interactive tile-based maps to run in a browser with overlays of custom data, however it suffers from some performance problems.
Large GPS Track Logs
I had the need to display GPS tracks in DeepEarth. GPS tracks can contain thousands of points. DeepEarth has three update modes called ElementUpdate, PanOnlyUpdate and TransformUpdate for showing features such as tracks:
- ElementUpdate recalculates the point positions on every map movement. This produces an accurate track display but gets slower as the number of points increases.
- PanOnlyUpdate recalculates point positions during panning and hides features while zooming. Not too useful for me and didn’t seem to show anything anyway.
- TransformUpdate draws the tracks to the map once then scales and pans the vector graphic in synchronization with the map. This makes it very fast. Sadly the scaling code is flawed. Lines disappear as you zoom in and sections of the tracks become distorted, almost looking like calligraphy.
I wasted many evenings trying to get the scaling in TransformUpdate mode working before giving up. I then turned my attention back to the ElementUpdate mode to see where the bottleneck is. More >
Getting US Government Shapefiles Into OpenStreetMap
Jul 10th
I recently embarked on the process of adding the shapefiles for Region 3 of the US Forest Service into OpenStreetMap (OSM). This post describes the method I used. First a bit of background.
OSM is a free street level map of the world. Just like Wikipedia is a encylopaedia that anyone can edit, OSM is a map that anyone can edit. The data is licensed under Creative Commons by attribution, which is a very liberal license.
In the US currently most of the data came from a mass import of the US Government’s TIGER data. This data has numerous problems, such as streets being in the wrong places and regions like forests are missing completely.
Fortunately some regions of the US Forest Service make good quality shapefiles available of the forest boundaries and I live in one of those regions – the Southwestern Region. It’s just a matter of converting the shapefiles into the correct format, adding some descriptions and uploading them to the OSM server.
There are several challenges with getting the data into OSM. Firstly the shapefiles are in the Lambert Conformal Conic projection, which is not what OSM uses. Secondly OSM doesn’t use Shape Files, it uses it’s own XML data format. Thirdly the data has to be “tagged” in the correct way for the forests to be rendered correctly. This becomes more complex if there are holes in the forest.
The first stage is to find the shapefiles and what projection they are in. In my case the US Forest Service provided the projection information with the data files. I then reprojected the data and converted to a OSM file format using the following steps:
- Open the shapefile in MapWindow GIS
- Use the GIS Tools menu to reproject the data to WGS84
- Save
- Open the reprojected data in GPS TrackMaker
- Save as GPX file
- Use GPSBabel to convert from GPX to OSM
gpsbabel -i gpx -f smallpiece.gpx -o osm -F smallpiece.osm
Currently the best editor to use for OSM is JOSM. This is a Java application that allows data to be added, edited, deleted and tagged. Don’t use the default memory allocation, instead allocate more using:
java -jar -Xmx256M josm-latest.jar
There are some essential plugins that are required. Install utilsplugin, validator and waydownloader. Here are the steps I used to edit and tag the data. There may be mistakes, so use at your own risk.
- Open in JOSM
- Simplify using Shift-Y
- Select all nodes in a single ring (closed loop) and choose Combine Way
- Select all outer ways
- Add way tags (see below)
- Select all inner ways and delete all tags
- Select all ways with no holes
- Create a relation
- Add the selected ways to the relation
- To the left of the way in the dialog window set the role to “outer” for all ways. Click on each way to see which it is on the map
- Add the tags for the relation (see below), setting the type to “boundary”
- Select each way with holes in turn, along with the holes
- Create a relation
- Add the selected ways to the relation
- To the left of the way in the dialog window set the role to “outer” for outside rings. Set the role to “inner” for inside rings.
- Add the tags for the relation (see below), setting the type to “multipolygon”
- Split large ways into smaller ways of 2,000 nodes or less
- Validate and fix errors. Ignore warnings about unclosed ways.
The tags I use for ways are:
- uuid: username_yyyymmddn
- attribution: US Forest Service
- boundary: national_park
- landuse: forest
- leisure: nature_reserve
- name: Coronado National Forest (example)
- wood: mixed
The tags I use for relations are:
- uuid: username_yyyynnddn
- name: Coronado National Forest (example)
- landuse: forest
- type: multipolygon (when there are holes)
- type: boundary (where there are no holes)
- boundary: national_park
Do not add tags to inner ways or the nodes. GPSBabel automatically adds tags, so delete those.
The uuid’s are a unique identifer that I can use to search for this particular set of data later, if needed. It is constructed from my OSM user name, the date and the upload number for the day. For example:
FooBar_200907104
would be the fourth upload for July 10th 2009 by the user FooBar. I use this scheme because I can work out the uuid’s from just an upload date and it is very unlikely that someone else would use the exact same uuids.