Working with terrain in

Since I have not much new FreeCAD-related development to show this week, I'll showcase an existing feature that has been around for some time, which is an external workbench named geodata, programmed by the long-time FreeCAD community member and guru Microelly2.

That workbench is part of the FreeCAD addons collection, which is a collection of additional workbenches that are not part of the core FreeCAD package but, since they are programmed entirely in Python and therefore don't need to be compiled, can be easily added to an existing FreeCAD installation. The FreeCAD addons repo linked above also provides a macro, which, once run inside FreeCAD, gives you an easy graphical installer that allows you to install, update or remove any of those additional workbenches. Click the link above and you'll get all the necessary instructions.

Also, this year was the first participation of FreeCAD to the Google Summer of Code. We got one student, Mandeep, who worked on building a more solid plugins installer for FreeCAD, capable of installing these workbenches but also all the macros found on the wiki. The work is not finished yet, but no doubt in the near future we will finally have a decent way to install all these additional features in FreeCAD.

Microelly2's geodata workbench basically allows you to fetch terrain data from the net, basically roads and building data from openstreetmap and terrain height data from both openstreetmap (but it doesn't always have accurate data) and NASA's SRTM data.

The procedure to get a piece of terrain with its height data in FreeCAD is quite simple:

  1. Install the geodata workbench and restart FreeCAD
  2. Switch to the geodata workbench
  3. Get the exact coordinates of the center of the zone you wish to import. You can do that simply by zooming in openstreetmap or in google maps, and you will see the coordinates in the URL bar of your browser
  4. In FreeCAD, menu GeoData -> Import OSM Map, fill in the coordinates. Leave "process elevation data" off. Buildings and roads are imported
  5. Click menu GeoData->Import OSM Heights and/or GeoData -> Import SRTM Heights to import height data from these two sources (use the same coordinates).

When done, you will get a piece of terrain with the roads and buildings, and the two terrain data (the SRTM data comes as a points cloud):

There will still be a bit of work necessary to turn this into data you can work with, but it's already a huge part of the work done.

The reason why I got interested in terrain data this week is aalso because I'm working on extending the Arch Site tool. Currently it is a simple container (it's actually simply a FreeCAD group with a couple of additional properties), but the idea is to turn it into something useful to:

  • Hold and process terrain data coming in various forms, such as meshes
  • Be able to get basic properties such as perimeter length or area
  • Be able to subtract or add volumes to it

A made already a couple of experiments to see how far that is possible, and it actually works surprisingly well. In the image below, a mesh was quickly made in Blender, imported and scaled in FreeCAD, then turned into an open Part shape (a shell). Doing boolean operations with shells gives a lot of interesting possibilities, and it's totally possible to keep the terrain surface "open" (no need to add an artificial thickness to it), and be able to subtract or add solids to/from it. Of course the volumes of earth that need to be added/removed are therefore easily computable.

I still need to solve a couple of minor issues, then all this should be in the FreeCAD code pretty soon.