Reconstructing terrain from contours
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Reconstructing terrain from contours
I was recently looking at QGIS, and I managed to create contour curves of a piece of terrain like this:
I'll blog about the whole process, but it basically involved grabbing a geoTIFF image from ASTER satellite data (freely available from the NASA reverb echo site), opening it in QGIS, cropping it to the desired area, generating contours, then saving to DXF and importing in FreeCAD.
Now the big problem: How to build a nice terrain surface from that... At the moment this is one single compound shape made of several disconnected edges. Later on I'll extend the DXF exporter to recreate the wires, that will already be a good step forward.
Now what would be a good strategy to recreate the terrain? Lofts? Unfortunately this is a terrible mix of open and closed wires... This won't work well, and would be complicated to select which wire goes with which other wire. Any other idea?
I'll blog about the whole process, but it basically involved grabbing a geoTIFF image from ASTER satellite data (freely available from the NASA reverb echo site), opening it in QGIS, cropping it to the desired area, generating contours, then saving to DXF and importing in FreeCAD.
Now the big problem: How to build a nice terrain surface from that... At the moment this is one single compound shape made of several disconnected edges. Later on I'll extend the DXF exporter to recreate the wires, that will already be a good step forward.
Now what would be a good strategy to recreate the terrain? Lofts? Unfortunately this is a terrible mix of open and closed wires... This won't work well, and would be complicated to select which wire goes with which other wire. Any other idea?
- Attachments
-
- gis.fcstd
- (581.17 KiB) Downloaded 113 times
Re: Reconstructing terrain from contours
wow cool, Any software we work with for an excavation off building sites would mesh the surface with triangles, build some vertical faces and base face. If all is put together there is a nice solid. An example is shown here viewtopic.php?f=13&t=12796&start=10#p103693yorik wrote:Now what would be a good strategy to recreate the terrain? Lofts? Unfortunately this is a terrible mix of open and closed wires... This won't work well, and would be complicated to select which wire goes with which other wire. Any other idea?
But later own would like to get again the hight lines ...

Re: Reconstructing terrain from contours
I think microelly knows this best (he has shown some nice work in this direction)
You can scale a uv-space up to the rectangular domain and least-square solve all interpolation-points. Therefor create a matrix from the influence of all base functions on the uv position of the interpolation points. Using a sparse matrix and a leastsquare solver from eigen will make it fast.
But I don't know if the basefunctions of bsplines are available...
Also radial-base interpolations can be used for this.
You can scale a uv-space up to the rectangular domain and least-square solve all interpolation-points. Therefor create a matrix from the influence of all base functions on the uv position of the interpolation points. Using a sparse matrix and a leastsquare solver from eigen will make it fast.
But I don't know if the basefunctions of bsplines are available...
Also radial-base interpolations can be used for this.
- microelly2
- Veteran
- Posts: 4691
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Reconstructing terrain from contours
I have a method to interpolate an elevation grid (quad mesh) from pathes
viewtopic.php?f=8&t=14595&hilit=elevati ... 20#p127208
I will write the tutorial to use the Elevation Grid of the reconstruction workbench,
but I need some days.
EDIT:
we had this problem some weeks ago: viewtopic.php?t=6973&start=100#p133280
viewtopic.php?f=8&t=14595&hilit=elevati ... 20#p127208
I will write the tutorial to use the Elevation Grid of the reconstruction workbench,
but I need some days.
EDIT:
we had this problem some weeks ago: viewtopic.php?t=6973&start=100#p133280
Re: Reconstructing terrain from contours
Interesting! Wow, I completely forgot about that topic... Yeah, it's high time that i have a look at your new WB microelly2!
Re: Reconstructing terrain from contours
yorik, can you post link to a geotiff image? I had a problem finding it on the nasa webpage (too much information). I found something from aster, but it was marked as "not downloadable". I'd like to see how the raw data looks like.
- microelly2
- Veteran
- Posts: 4691
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Reconstructing terrain from contours
A simple way to get small datasets is:
http://topex.ucsd.edu/cgi-bin/get_srtm30.cgi
here is a link to data in osm format:
http://geoweb.hft-stuttgart.de/SRTM/srtm_as_osm/
and here binary
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/
http://topex.ucsd.edu/cgi-bin/get_srtm30.cgi
here is a link to data in osm format:
http://geoweb.hft-stuttgart.de/SRTM/srtm_as_osm/
and here binary
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/
Re: Reconstructing terrain from contours
Filling contours with colour gradients makes them suitable for heightfield generators. Profiles can be closed by height, filled all-of-a-piece, then the higher values are superimposed rather than being treated as islands in a hatch, as an analogy.yorik wrote: Now what would be a good strategy to recreate the terrain? Lofts? Unfortunately this is a terrible mix of open and closed wires... This won't work well, and would be complicated to select which wire goes with which other wire. Any other idea?
- microelly2
- Veteran
- Posts: 4691
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Reconstructing terrain from contours
At the moment I use for tests
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/
in relation with python methods described here https://librenepal.com/article/reading- ... th-python/
This can be used to create a grid directly from the hgt files.
The files can be downloaded and unzipped on demand and then a grid for
a wished area can be computed.
The methods to get a height color map/curvature and gradient maps are under construction:
http://freecadbuch.de/doku.php?id=blog: ... en_bringen
http://freecadbuch.de/doku.php?id=blog: ... ungenmasse
The idea is:
create an elevation grid
create a nurbs surface
calculate some useful information and put the results into an image
put the image as texture onto the nurbs
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/
in relation with python methods described here https://librenepal.com/article/reading- ... th-python/
This can be used to create a grid directly from the hgt files.
The files can be downloaded and unzipped on demand and then a grid for
a wished area can be computed.
The methods to get a height color map/curvature and gradient maps are under construction:
http://freecadbuch.de/doku.php?id=blog: ... en_bringen
http://freecadbuch.de/doku.php?id=blog: ... ungenmasse
The idea is:
create an elevation grid
create a nurbs surface
calculate some useful information and put the results into an image
put the image as texture onto the nurbs
Re: Reconstructing terrain from contours
I have seen this sort of activity done by @microelly2 in the past few months. Surely some conclusions can be made from it. Or better the code that could be reused already exists?