Introduction: Make a 3d Print of Your Hike From a GPS Track
Imagine your favorite hike, the ultimate backpacking bucket list adventure of your dreams or your weekly walk with your cat. Now imagine a miniature 3d map which you can hold in your hand which shows every detail of your route perfectly to scale. It doesn't need to be a hike, if you have a favorite ride on your Ducati or your camel that will work too. You just need to record a GPS track of the route. This can be done with a hand held GPS but it can be done easier, cheaper and just as accurately with a smart phone. For this example I will be using a track which I recorded while climbing Yosemite's Mt Conness with my 10 year old daughter. Its a tough climb. Luckily she's a tough girl.
The process is simple if you break it down into steps. You make a 3d printable map of the terrain. You make a 3d cutting tool based on your GPS track. You use that tool to cut a groove in your terrain map. If you do it just right you can make a groove which perfectly fits the tip of a marker like an ultra fine point sharpie or another .2mm marker. Then you just print it and color however you like. Its fun, kinda like paint by numbers, only 3d.
Step 1: Getting Started
I use the amazing, versatile and free Blender for most of my 3d editing. For this project you will need a recent version of Blender available from Blender.org and a couple of free or low cost add-ons. We will also use Autodesk's amazingly useful, and amazingly free Meshmixer to help fix some problems with our model.
After you have installed Blender go to the Add-ons menu in the User Preferences section and turn on the 3D Print Toolbox. The tool box is included with Blender but you need to turn it on. This set of tools is very useful for checking and fixing models you plan to print. You will also need to download the free Blender gpx importer tool from https://github.com/vvoovv/blender-gpx and the Blender terrain importer from https://github.com/vvoovv/blender-terrain/wiki/Documentation. As with all downloaded Blender add-ons you choose "Install Add-on from File" and point Blender at the zip file to install the tool. Don't unzip it first.
I use the very handy Blender Open Street Map tool kit which is available for a paultry $5.90, or a meager $15.80 for the premium version, from https://gumroad.com/l/blender-osm. It is a more complete tool kit produced by Vladimir Elistratov, the author of the free tools. It makes the process of selecting and acquiring the terrain a little easier. It isn't necessary for this project, but it is a great way to support the guy who created the tools we will be using.
Step 2: Filter Your Gpx Data
Most GPS units will allow you to export a track to a format called gpx. Gpx is a simple XML format so you could edit it using any text editor but that would be about as fun as a root canal. It is so much easier use a gpx track editor. I use a great free open source one called (rather descriptively) "GPX Track Editor". It is available from the straightforwardly named www.gpstrackeditor.com. It very conveniently projects the gpx track on to the exact same Open Street Map you will later use to choose the bounds for your map. Keep the program open when you come to the next step and you can easily locate your area of interest.
Open your gpx file and look at your track. Chances are it isn't as neat as it could be. Your handheld gps or phone app records a data point on a clock schedule so if you stay in one place, say to have a picnic or wrestle a bear, you will end up with a lot of data points in pretty much the same place. Similarly if you are slogging along with a 90lb pack up a 45 degree slope your points will be much closer together than you need. Luckily there is an easy tool to filter these out. The considerately named "Filter" tool allows you to remove any points which aren't a minimum distance away from each other. A filter distance of 100 ft works well for a hiking trip. The point here is to remove as much of the data as possible while retaining the shape of the gpx track. The rest of the process is much faster and simpler if you are using as small a data set as possible. It is also a good idea to eliminate any doubled tracks, so if you went out and back on the same trail delete one of these so it doesn't confuse things later.
Make sure to save a copy of your filtered data so it will be ready for the later steps.
Step 3: Grab Your Map Data
Start by selecting the area for your map. If you are using the OSM toolkit in Blender it is easy: Click on the select button on the "osm" panel on the tool shelf. This will open a browser and direct you to a website where you can use a rectangular selection tool on an Open Street Map browser to pick the area you want to map. It is best to select an area a little larger than you think you will need. You will need to crop it later so give yourself some space. You also can't see your gpx track at this point so you will need to rely on landmarks. When you are happy with your selection click the copy button and it will confirm you have copied the coordinates of the edges of the box. Moving back to Blender click the paste button and you will see your coordinates automagically appear in the right spots.
If you are doing it the free way you will need to go directly to Open Street Map and locate your area of interest. Click the export button and "manually select. . ." option then adjust the box. You will need to manually cut and paste (or write down and type in if you really feel like punishing yourself) the resulting coordinates into the import Terrain dialog in Blender. The import Terrain dialog box looks like a Blender file browser, but if you enter coordinates manually it will download from a server directly. Kinda weird, but it works.
Before you import your terrain be sure to check the "ignore existing georeferencing" box. If this button isn't checked it will import your terrain to its actual location on earth, and it's actual size. As you might imagine having a model space large enough to fit the whole earth is somewhat taxing. Poor Blender, mighty though it is, may start to misbehave. If you check the box it will arrange its map of the world so your point of interest is centered on the origin. That keeps everyone much happier. It is much easier to start at the origin than it is to end with a model which tells your slicer that it wants to be thousands of kilometers outside your printer's build volume.
If you are using the OSM toolkit you just click the import button, making sure the drop down menu is set to terrain. Blender will download a surface model of your coordinates. This model is based on the SRTM data set which was collected by the space shuttle. The coverage is world wide and is remarkably accurate and complete. It isn't as detailed as some of the LIDAR datasets where you can see individual trees and cars but it gives us all the detail we need for a hiking map.
Depending on where your 3d view is pointed you may see your screen go grey or your may see nothing at all. Just press the dot key on your numeric keypad ("Num ." for short) and your view will automatically center on your newly imported terrain (actually it centers on whatever is selected, a very useful shortcut) and zoom out till you can see the whole thing.
Step 4: Bring in Your Gpx and Set the Scale
After you have paused to contemplate how amazing it is that with a few clicks you have a tiny piece of earth on your computer it is time to bring in your gpx track. Use the import gpx add-on and hopefully it will magically pop into place. Make sure not to check the "ignore georeferencing" box. We have established a georeferencing system by importing our terrain and we want to respect it so the gpx matches up to its real world location.
If you click the import and nothing seems to happen look at your Outliner window (That's Benderese for the parts tree) If you can see your gpx track listed then all is well. What sometimes happens is that the gpx track is recorded without altitude data so when it imports it is under the terrain and can't be seen. Just grab its z arrow and drag it above the terrain. Make sure not to move it in the x or y dimensions or you will lose its location.
Blender has it's own units which it calls blender units. Their relation to the real world depends on how you use the data once you export it. Most slicers will interpret the units as millimeters. The terrain data is imported at a scale of 1 meter to one blender unit. So, as imported, the terrain is a 1/1000th scale model of the real world. As far as your printer is concerned this is ridiculously massive, but don't worry it is easy to scale it down. Hit the A key to select all objects, then hit the S key to scale and type your scaling factor. A factor of 0.005 or so will get you to the right neighborhood. You can pick whatever scale fits your printer. Make sure the gpx track scales with the terrain. Remember your scaling factor, write it down if you need to, because if you change anything in your gpx file or your terrain and import a new version you will need to scale it the same to make it fit.
Once you have your model scaled properly select the gpx track and type Ctrl-A and select Scale. This will reset the scale so it will now consider itself to be at scale 1.0, even though it won't change size. If you skip this step you will have difficulties later on as Blender gets confused as to what scale you are working at.
Step 5: Make Your Terrain Model
The process for turning your terrain surface into a printable solid model is quite simple. Create a cube which overlaps the terrain surface exactly where you want the model. See the screen cap above for a cool trick. If you select a Maximum Draw Level of wireframe you can show just the wireframe of your cube which makes it easier to line it up exactly where you want. The extent of the cube under the terrain surface defines your model. The cube above the surface doesn't matter. Once you are happy with your layout add a boolean intersect modifier and make sure you select the "carve" solver. Whenever you apply a modifier in Blender make sure you have everything set up before you assign the object. Assigning the object sets Blender off and running to calculate the boolean which can take some time, so make sure everything is set the way you want before you turn it loose.
If you want to introduce a vertical exaggeration to your model this is a good time to do so. You can turn molehills into mountains with the click of a button. This can make a relatively flat model more interesting. If you give the Z scale a value greater than 1.0 everything gets taller and more impressive. But make sure to use your new found power carefully. A model with vertical exaggeration isn't accurate to the real world.
Step 6: Make Your Cutter Tool
Hopefully by this point your terrain model is properly scaled and solidified and your gpx track is hovering above it in proper alignment. Blender has a modifier called "shrinkwrap" which will project the gpx track onto the surface of the terrain model. Set the modifier to project mode and select Z axis, Negative. Then select the terrain model as the target. You should see your gpx track draped perfectly over the terrain surface. If everything looks good apply the modifier.
Now we have a gpx track which lies perfectly on the surface of the model, but we need to make it into a solid so we can use it to cut a groove in the model surface. First, with the gpx track selected type Alt-C and convert it to a curve. It is a good idea to check the "Keep Original" box. There are things in this process that are difficult or impossible to fix without going back to a previous step so it makes sense to preserve all your versions. Now that you have a curve you can make it a solid by sweeping an object along the path. Blender calls this, for reasons of its own, a bevel object. To create your bevel object make a plane somewhere beside your model, the location doesn't matter so just put it somewhere out of the way. Scale your plane to 1 in the X dimension and 1.5 in the Y dimension. The X dimension determines the width of the groove, the Y dimension is the height of the cutter tool which will be centered on the surface of the model so the cut will be half the Y dimension deep. These dimensions work well for my printers, but feel free to change them. Finally you must type Alt-C to convert the plane to a curve.
In the curve panel select your bevel object and you should see your track expand to the cutter object. If it doesn't check your scale. The width of the object you are making is dependent on the scale of the curve, so if you failed to reset the scale in the previous step the bevel won't be properly scaled.
Step 7: Refine Your Cutter Tool
After you have made your cutter tool you will need to refine it a bit. First type Alt-C and convert it to a mesh. If you zoom in on your cutter object you will see it is one ugly mess. For starters enter edit mode and use the 3d printing tool panel to "make manifold". This will fix some of the mess, but if you analyze the mesh you will see it is probably crawling with intersecting faces. These will kill the boolean algorithm so we need to do some more clean up. Unfortunately Blender doesn't have any easy way to fix intersecting faces. Luckily our friends at Autodesk have a great tool available in Meshmixer. Export your cutter object as an stl, making sure to check the "export selection only" box. Import your cutter object into Meshmixer and select the "make solid" tool. Make solid converts your model into voxels, and then back to a surface mesh which fixes most of the problems with it. The default setting may yield a yucky model but max out the Model Density and Mesh Accuracy and set it to accurate mode and you should get a nice result. If there are problems with your model or it is missing parts you will need to go back to your blender model and fix them and then run them through Meshmixer again. If you filtered your gpx track and eliminated any doubled tracks you should get a good result here.
Step 8: Finishing Up
If your cutter tool is all cleaned up then making the actual boolean should be a breeze. When you re-import your repaired tool it should appear at exactly the same place as the original. In fact you may need to hide the original one to see the repaired tool. You will want to select the terrain and set up a boolean difference with the cutter tool. I like to hide the tool before I run the boolean so I can see the results clearly once the calculations are done. If all goes well you will end up with a solid terrain model with a perfectly sized groove exactly tracing your gpx track. If everything looks like it should apply the boolean and export the final stl.
When you set up to slice your print you have two options. The first is to print the model flat on the build plate. This is cool because the layer lines in the print end up forming topo lines which is kind of cool for a map. The topo line effect is neat but it limits the amount of detail you can capture in the print. For the smoothest, most detailed print it is best to turn the model on its side. This is because x-y printing produces smooth continuous extrusions while the z-axis moves in discreet layers. The only time this doesn't work is somewhere like Yosemite where the cliffs will require support. Set the lowest layer height you can for the smoothest print. I like white material because it shows details well and shows any color, but you can color lines on almost any color of print except black.
If you followed my instructions closely your gpx track will be a groove which more or less exactly fits the point of an ultra fine point sharpie marker or other .2mm marker. Carefully run the marker along the groove and its like idiot-proof painting. You may notice that if you use a sharpie or other marker to color a print you end up with a soft, kind of blurry mark. This is because the tiny nooks and crannies between the extrusions tend to wick the ink in which spreads it slightly. It can be unsightly on the surface of a print, but if you are just coloring the grooves it actually helps. The wicking action spreads the ink to the sides of the groove, but the geometry prevents it from spreading further. If you ever want to color something on the surface of a print I recommend painting the print first. This seals all the little nooks and crannies and you can color away without the ink bleeding.
Step 9: Taking It to the Streets
Once you have mastered the basic technique you will start to see the other possibilities. As you may have already figured out, you can make maps of places you have never been by using other people's data. Open Street Map is an amazing resource which contains thousands of hiking trails. You can extract the tracks from the map without anyone needing to hike the trail. With a little ingenuity you can make 3d trail maps of your favorite ski area like Squaw Valley, or a map of your dream hike like the John Muir Trail above. The same technique could be applied to creating a road map or show municipal boundaries, or property lines, or any other line you would find on a map. It is also possible to use a variation of this technique to make multi-part models which can be printed in multiple colors with a dual extruder or a multi color solution like the diamond hot-end. Dual extruders tend to drool on the model while the other extruder is printing which makes the finished product unsightly. Multi color hot-ends like the diamond are an improvement but they require large amounts of plastic to be purged every time you change colors which can result in wasting more material than there is actually used in your final print. Also both technologies are limited in the number of colors that can be produced in a given model. The ski area map above requires one base color and four accent colors to distinguish the ski lifts and the different difficulties of the runs. Given the limitation of both technologies I'd rather reach for my markers.