Geo-Positioning Information With Meerkat
As I’ve written before, Meerkat is a really fantastic tool for importing GIS information into Grasshopper. Since many municipalities provide GIS information for free, GIS is an accurate and facile format for introducing geographic information to the GH environment. Meerkat can also be used to provide a framework to translate between geo-spatial and rhino-space coordinates, creating a facile way of mapping geographic locations within Grasshopper.
First, use the Import Shapefile module to prep your GIS files to be referenced by Meerkat. All this means is connecting a Boolean Toggle to the Import Shapefile module and double clicking it- which toggles it to true, activating the Meerkat interface.
Once Meerkat is launched, use the “Add Shape File” button to select the GIS shapefiles you’d like to work with. If this causes Rhino to crash, go into your Components Folder where the Meerkat files are located and unblock the Meerkat component and all of it’s .dll files. This interface is a fantastic attribute of Meerkat as it allows you to crop out any GIS info you don’t want. Use the rectangle at the top of the screen to select the region you’d like to use, then click Crop Shape File(s).
And nothing happens… at least that you can see. Meerkat has saved .mkgis files for you that you now need to reference with the Parse .mkgis module. Use a File Path module to select the correct path(s), and then plug that into the Parse .mkgis module. You may want to turn your Boolean Toggle to False, this will prevent you from launching Meerkat the next time you open your script.
You’ll notice that by default Meerkat positions the GIS information pretty far from the Rhino space origin. One trick to make the data more manageable is to center your data at 0,0.
Use the Area module to get the centroid of the Bounds in Point Space polyline. If you use the Vector 2pt module to calculate the vector between that centroid and a 0,0,0 point (created here by the Construct Point module set to default values), you can then use that vector to center the GIS geometry (Geometry per Shape) in Rhino space. From here you can just use a Polyline Module to create linework from the points.
These steps have created a basemap to work with, but now we need to start positioning geo-spatial coordinates. gHowl’s GEO -> XYZ module does this well, but we need to give it more information before it can run. Use the same vector information we used before to center the Bounds in Point Space polyline on 0,0,0. Explode the polyline, and use List Items modules to isolate the 0th and 2nd point of the polyline. These will become the P1_XYZ and P2_XYZ input of the GEO -> XYZ module.
From here, you need to massage the Bounds in Lat-Long output a little to feed it to the GEO -> XYZ module. The Bounds in Lat-Long output is essentially a string of text that needs to be broken in order to read as two points, use the Text Split module to break up the coordinates at the space. From here, use the List Item module again to isolate each point, then plug them into the GEO -> XYZ. Make sure you put the 0th point into P1_GEO and the 1st point into P2_GEO. Run whatever geo-spatial coordinates you’d like into the P input of the GEO -> XYZ, and you are mapping with Meerkat.