2D Site Model from Open Street Maps – Example 20.1
One very useful add-on for Grasshopper is a plugin called Elk which can be downloaded for free from Food4Rhino. While it has some issues, which I will talk about when they come up, in general it is a very powerful tool. Basically what it does is it takes data from an open crowd-sourced mapping program, Open Street Map, and allows you to use this data in the Rhino environment. This is handy for making site models of large scale landscapes, although the data is typically not sufficient for site scale design.
Before I get into the process, I want to briefly talk about what Open Street Map is. It is a mapping program, much like google Maps, etc. with one caveat. All of the data is generated by volunteer mapping hobbyists, and can be used in most any application, non-commercial and even commercial, at no charge. The map is also editable by anyone, so if you are working on a project in a particular place, you can add additional data to the public map. The end effect is some places are very well mapped, especially in Northern Europe (lots of hobbyists / nerds 😉 ) while other parts of the world not so much. It is useful to go around a bit before continuing to see what is out there.
This data has been used for many different applications. One particular application that is very useful for designers is this set of 241 CAD files for many of the world’s major cities. We will be running similar processes to generate files in Rhino, but will also be able to eventually make 3D models using Rhino + Grasshopper + Elk.
Step One – Get Data from OSM
In future posts, I will give some pointers on editing the map itself, but for this example, I will start with an area that is already pretty well mapped, exporting some data from a small village in Switzerland where I worked on a project as an intern, a small village called Ecoteaux. You can try this, or any other site you would like as long as there is sufficient data.
Simply find an area you want to work on, click the “Export” button, and either click and drag to select a window frame, or type the coordinates into the proper boxes. One thing to note, however, is that you can’t export too much information at once. You are limited to 50,000 objects. This probably doesn’t mean that much to you, but if you select too big an area, an error will be generated, or it will say the database is too busy. If this happens, select a smaller area. Usually an area of a few square kilometers will be OK. In cities where there is more data mapped, you will need to select a smaller area than you might in the countryside, where there isn’t as much information, typically. If your area isn’t too big, you will be prompted to save your export. Give it any name you want. It will have a file extension *.osm. Once you have this you can move on to the next steps.
Step Two – Setup Basic Elk Data Stream
Important: Before starting make sure your units in Rhino are set to meters otherwise you may run into problems down the road. I actually use meters as a default for all of my work, so sometimes I forget to tell students this, but there is no reason you should be using millimeters for site design work.
Elk is actually pretty simple and for all data the same basic data flow should be used, with three core components.
First you use the Grasshopper “File Path” parameter (be careful not to use the “Data Path” parameter, as this won’t work). Plug the data path into the main “Elk” component which is labeled “Loc” for Location. Right click on the “File Path” parameter and set this as your *.osm file, wherever you happened to save it. All of the OSM data is now living in the “Loc” component, we just need to extract it now. The process for extracting it is always pretty much the same. You can use the special “River” “Railroad” or “Highway” components, but for simplicity I will show it here only one way, using the “Generic OSM” component.
This component needs 3 or 4 values. The first two are the O and X values that are generated from the “Loc” component. Plug these in. The last two are what are called the “Key” and “Value”. Every object in OSM is classified using these two designations. The “key” can be thought of as the “genus” of the object, while the “value” can be thought of as the “species” In general, there are only 11 generally used “keys” but there are hundreds of “values”
As an example, we can look at the “key” designation “highway”. The values that typically are associated with highway are listed here on the Open Street Map wiki.
I made my own list of commonly used keys and values that are useful for site modeling, although this list is not exhaustive.
For our first map, we will use a few of these and I will demonstrate some basic processes for bringing in each one.
Step Three – Basic Processes for 2D Map – Example of “K=Highway”
This first image shows what you will see in Rhino if you bring in all of the data that is classified under the “Key” = “highway” You will see it gives you a 2D point cloud. The Gen OSM outputs Points “P” and a value called “K” which are attributes associated with objects. We will ignore “K” completely and only use “P” The points are structured together based on objects so don’t flatten or graft them!
To see the actual roads, we will simply hook up a “Polyline” component to the points and the roads from OSM will display properly. Here the preview for the “points” is turned off.
Note all of the highways will show up and be rendered the same when you use only “K=highway” if I want to be more specific, I can input a value into “V”. In the image above I am using the “V=track” to show the tracks, or dirt roads in the model. What qualifies as a “track” depends on the person who drew the map. Some people show minor paved roads as tracks, while others might classify it otherwise.
The reason we want to separate the values is because in our model, we want to show different kinds of roads in a different way. An autobahn has the same “K” value as a dirt hiking trail, both of these are “K=highways”, so by distinguishing the V (autobahn “V=motorway”; hiking trail “V=footway” or “V=path” depending on who drew it) I will come back to this in a minute, but let’s look at a few other objects.
Step Three – Basic Processes for 2D Map – Further Examples
Here is another process for buildings. In this case I am not distinguishing between the various building types since in 90% of cases the “V” for a building is “V=Yes”. Only special buildings tend to be differentiated. I did one thing new here, though. After drawing the Polylines for the buildings, I convert them into basic Surfaces using the “Boundary Surface” component. I can change the color of the buildings if I want, but in this case I will stick with grey.
Forests are typically drawn with the identification “landuse=forest” and more rarely as “natural=wood” Most users will use “natural=wood” for what they consider virgin forest or unmanaged woodland, but since almost every forest, especially in Europe, is managed to some degree, “natural=wood” becomes quite rare. If you are mapping forests, though, you should check both to see if they are on your map. Similar to buildings, for now I am going to create a basic surface out of the forests and color them green.
Farmland is classified under “landuse=farm” or sometimes”landuse=farmland” depending again on who drew the objects, so you should check for both on your map. Often this is not drawn in great detail, although I like to draw the individual fields when I do a map, mostly for aesthetic purposes. Here I am using a gradient to color the fields in a spectrum based on the area of the fields. To get this to work properly I had to “flatten” the polylines first.
Here I am importing two types of waterways “waterway=stream” and “waterway=river”. In both cases I offset the original geometry using the “C” value of “2” to Curve the offsets”, and then created a “Loft” between the original line and the offset line to give it some thickness. The streams are 3meters wide while the rivers are 10m wide.
Bringing it together
If you’ve been following along, and not deleting after each step, you should be getting a pretty big script by now that might look something like this.
Note that here I have separated many different road types and given them a similar treatment as I did the rivers. Also new are the trees (“natural=tree”) and the political boundaries (“K=boundary”). Note that you need only one initial “File Path” and only one initial “Loc” to output all the “O” and “X” values. Your output will look something like the image below
As you set up each process or “layer” your script will start getting very large and potentially confusing. It is important to group things together and use logical flows so your script will be usable on other projects. You also will probably want to use hidden wires, especially for routine connections like O and X, otherwise they will clutter your screen. If you don’t do this, after a few days of doing other things, or even after a short bathroom break, when you open your file again you will be lost.
A typical site modeling script can get quite daunting after a while. Below is an overall screen shot of one I use to generate site models. If everything is running smoothly, I can generate a site model in 5 minutes, but keeping things organized is key since I don’t want to run every single process at once.
To enable or disable processes, you can either use “right click > enable” on a component or you can use the “Dispatch” component hooked up to a “Boolean Toggle” When the toggle is true, items go into stream “A”, when false, they go into “B”. In this case, B can be a dead end, while items need to be in stream “A” to continue along the wires.
So that’s most everything you need to know for 2D! In the next example we’ll start getting into the 3rd dimension.