As far as information synthesis goes, Grasshopper is pretty amazing. A frequent starting point for representing data is with the conventional geographic map, which creating in GH is not always an intuitive process, so I thought I’d create a tutorial on creating a geographic map in GH to begin to map spatial data. The plugins I use in this example are gHowl and Elk. If you follow along with the exercise, feel free to click on the images below to enlarge them.

First, download your vector information from OpenStreetMap.org. Use OpenStreetMap’s interface to crop to the area you’d like to map, and download an .osm file by selecting the export tab and then OpenStreetMap xml data.

GISMap_OpenStreetMap_02

In GH, use Timothy Logan’s Elk to bring the .osm info into GH. Use the File Path module to connect to the P input of the Location module, this identifies the .osm file you’d like to use.

GISMap_GH_Elk_Location_02

The Location module parses the .osm file and identifies what objects are what. You then need to start connecting the rest of the Elk modules to pull out the different kinds of data- connect the O and X outputs of the Location module to the O and X inputs of any of the other Elk modules (except the topo module) to start building your map.

GISMap_GH_Elk_MajorRoads_02

The points representing the different objects will be organized in different branches, which will allow you to create different geometry from them.

GISMap_GH_Elk_MajorRoads_Polys_02

The GenericOSM module is crucial, it allows you to parse any other osm features there aren’t modules for, in this case Buildings. You can find a list of osm features here. You can also use a text editor to open your xml file and see what points are tagged with data. Amenity, Highway, and Railway are all worth exploring- Land Use is particularly interesting. You can also use the V input to parse for subcategories of features and the K output combined with the Text Tag module to label the objects with their metadata. GH3D user Ivor Ip posted a GH attribute list of some of the osm features that you can download here.

GISMap_GH_Elk_Buildings_02

This is a workable base for many diagrammatic maps- there’s a lot more data we can add but for now this should give us enough to work with. The next step is creating the ability to position WGS84 coordinates (longitude and latitude information) relative to this information. Use Elk’s sTopo module to use SRTM data to create a topography. First we’ll need to download the right SRTM file, I’ve been using the the WGS84 info from Elk’s Location module to help find the right file from the USGS repository. Be sure to verify that you’re looking at the right data with QGIS or another program- the naming convention can be a little tricky… but once you have your .hgt file, use the File Path again to reference it to the sTopo module.

GISMap_GH_Elk_Topo

If you’re interested in creating a 3D topography, flattening the points from the sTopo module and inputting them into a Delaunay Mesh will create a quick and easy mesh. For our purposes, we’re just going to use the points created from the topography as a reference for mapping our coordinates. The goal here is to use gHowl’s Geo To XYZ module to position coordinates relative to our map. Find the first and last points from the sTopo for the P1_XYZ and P2_XYZ inputs, then use the Lo and La outputs of Elk’s Location module to create info for the P1_Geo and P1_Geo inputs.

GISMap_GH_Elk_Coordinates

Now any WGS84 coordinates that are loaded into the Geo to XYZ module will be positioned on our map. This is particularly useful when mapping geotagged information, like tweets or other social media info.

  • Pingback: AFTER INPUT » Metaball Diagrams with Google Earth and gHowl()

  • Henry Stearns

    Hey Alex, great work! What is the (L|Bs|N) component and what does this part of the script do?

    • alexwebb4

      Hey Henry-

      Where do you see the (L|Bs|N) component? I’m trying to track down what you’re referring too…

      Alex

    • Anthony Laffargue

      Hi alex, i agree with Henry Stearms, what’s the (L|Bs|N) component (after sTopo composent) ?
      Your website is very nice and clear !

      • alexwebb4

        Hey Henry / Anthony-

        The BS Component is the Branch Count component. I used this to select the last branch of the sTopo tree, and then the List Length Component to select the last item of the list. This info allowed me to combine Elk’s & gHowl’s components to position a longitude / latitude coordinate in GH space.

        I hope this helps!

        Alex

        • alexwebb4

          The Bs Component is also a part of Carson Smutts’ Mosquito. Apologies for not mentioning that before.

  • Thompson

    Hey Alex, thank you so much for posting this tutorial. For some reason when i try the last step it doesn’t work. The Geo->xyz has a runtime error. Also i noticed that my topography is floating above the constructed map in rhino. Could these things be related? I’m relatively new to grasshopper so any help would be greatly appreciated, Thanks!

    • alexwebb4

      Hey Thompson-

      What is the runtime error you’re getting? The constructed map should be below your topography, you just need to construct a surface out of your points and project your map info onto the surface. It’s a little crude, but it’ll work.

      Alex

  • Romeo

    Hi Alex, great work. I am trying to find out how you got the building outlines. And what plug-in is used to get the Tex Tag module to call out the buildings. Thanks!

    • alexwebb4

      Hey Romeo-

      The text tag should be native to GH (it’s tough to keep track of what’s a plugin and what’s not though). Just double click in the GH workspace and type “text tag”, or to the Vector Menu and then the Point Sub-Menu to select it. I would definitely recommend using the Area module to grab the centroid of each OSM outline, and then using that to position your text tag.

      Good luck,

      Alex

  • Pingback: Visualizing Social Data using Grasshopper and Google Earth | ClaviOn Unlimited - Fine Art by Chris Clavio()

  • Patrick

    Tutorial on generating 3D buildings would be beyond amazing!!! My attempt works but is very messy/ not very efficient.

  • Frank

    Hey Alex.
    I have a problem whith the “genOSM” component. when extracting a riverbank there are some of the areas missing I can see in openstreet map. When i looked up the definition in the OSM editer view all the areas missing where “multipolygons”. Is there a way to get this data?

    • alexwebb4

      Hey Frank-

      This is one of the quirks of OSM, anyone can categorize data any way they want with little oversight… I would just type “multipolygons” in a panel and connect that to the genOSM module. This should let you grab that data in GH.

      Good luck!

      Alex

  • R

    Hi,

    i was just wondering what the branch count command is as there is no option for it on my version of grasshopper as far as i can see?

    thanks.

    • alexwebb4

      Hey R-

      The branch count command is actually the “Tree Branch” component. I’m pretty sure this is on most versions of GH, except very, very early ones.

      Let me know if you can’t find it.

      Alex

    • alexwebb4

      There’s also the “Bs” module, which is part of Carson Smutts’ Mosquito.

  • lmz

    Hi Alex, where can I find the “dedomain” component?
    thanks!

    • Hey there-

      The “DeDomain” component is the “Deconstruct Domain” component. Depending on your version of GH, it might show up as something else but searching “Deconstruct Domain” should point you in the right direction.

      Good luck,

      Alex

  • Priyansh Jain