Interesting Tech Projects
Posts tagged JOSM
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.
Open Street Map Quick Start (JOSM)
Aug 6th
This is a description of how to quickly get going with OpenStreetMap. It is primarily aimed at people who don’t have a GPS unit or don’t want to use one. It’s also aimed at people who want to quickly add something to their local area. It is not a replacement for the OSM wiki.
Get JOSM
First download the current version of JOSM, which is a Java based editor. You will also need to install Java 1.5. You can also read more about JOSM here and here.
Start JOSM. On the command line this is something like:
java -jar -Xmx512M josm-latest.jar
There are some JOSM plugins that I think are essential, and here is how to add them:
- Start JOSM
- Go to Edit -> Preferences
- Click on the plugins tab (looks like a wall socket/outlet)
- Click on “Download List”
- Check/tick the following: utilsplugin, validator, waydownloader
- Click on “OK”
- Restart JOSM
Next you need to tell JOSM your OpenStreetMap username and password.
- Go to Edit ->Preferences
- Click on the connection settings tab (looks like a planet)
- Enter your email address and password
- Click on “OK”
Next install the WMS Plugin for JOSM that will allow you to view Yahoo satellite images.
Download a Section of the Map
Next you will want to download the part of the map that covers your local area.
- Click on the Download From OSM toolbar button
- Check/tick “Download as a new layer”
- Drag the map with the right mouse button, zoom with the mouse wheel or Ctrl + arrow keys
- Drag a box with the left mouse button to select an area to download. Keep it small for now.
- Click on “OK” and wait a bit. It could take a few minutes so don’t give up too quickly
You will now be looking at a black screen with lots of lines on it. Zoom in to a few streets using the magnifying glass tool on the toolbar.
Get the Satellite Images
The next step is to get the satellite images so we can see how the streets compare with the real world.
- Go to WMS -> Yahoo Sat (may have a slightly different name depending on the JOSM version)
At the top right under the Layers heading a new layer should appear called “Yahoo Sat” or something like that. Wait a bit and the images should start to appear.
Edit the Map
It’s now time to start editing. It should be clear if a street is not aligned with the Yahoo images. If it isn’t then you can click on the Select tool on the toolbar and start dragging the nodes (small yellow boxes). Position a road over where it is in the satellite image.
Upload!
Once you have fixed a few roads click on the Upload to OSM toolbar button.
- Enter a description for the change
- Click on “Upload Changes”
Once complete you can go to your OSM account page and view your edits. The URL is http://www.openstreetmap.org/user/myusername/edits. Replace “myusername” with your user name. You should see your first edit!
After waiting a few minutes your changes should start to appear on the map. Mapnik (the default renderer) renders the lower zoom levels more frequently, so you should see your changes appear in stages and only in some zoom levels. After a day or so all the lower zoom levels should show your changes.
Some Notes
The Yahoo satellite images are not always in the right place, but it seems from my experience they are pretty good. However this is something to keep in mind.
Along with fixing streets, it’s also possible to add in schools, malls, hospitals, businesses, rivers, streams, parks, etc. all by using the satellite images. There is plenty to do!
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.