Reconstructing terrain from contours

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
User avatar
yorik
Site Admin
Posts: 10719
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Reconstructing terrain from contours

Postby yorik » Tue Sep 27, 2016 4:44 pm

I was recently looking at QGIS, and I managed to create contour curves of a piece of terrain like this:
screenshot.jpg
screenshot.jpg (203.65 KiB) Viewed 2194 times
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 36 times
User avatar
bernd
Posts: 7049
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Reconstructing terrain from contours

Postby bernd » Tue Sep 27, 2016 4:53 pm

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?
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#p103693

But later own would like to get again the hight lines ... :roll:
looo
Posts: 2319
Joined: Mon Nov 11, 2013 5:29 pm

Re: Reconstructing terrain from contours

Postby looo » Tue Sep 27, 2016 5:06 pm

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.
User avatar
microelly2
Posts: 4197
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Reconstructing terrain from contours

Postby microelly2 » Tue Sep 27, 2016 7:24 pm

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
User avatar
yorik
Site Admin
Posts: 10719
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Reconstructing terrain from contours

Postby yorik » Tue Sep 27, 2016 10:39 pm

Interesting! Wow, I completely forgot about that topic... Yeah, it's high time that i have a look at your new WB microelly2!
User avatar
PrzemoF
Posts: 2447
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Reconstructing terrain from contours

Postby PrzemoF » Wed Sep 28, 2016 8:09 am

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.
User avatar
microelly2
Posts: 4197
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Reconstructing terrain from contours

Postby microelly2 » Wed Sep 28, 2016 12:20 pm

zumer
Posts: 11
Joined: Mon Sep 26, 2016 9:02 am

Re: Reconstructing terrain from contours

Postby zumer » Wed Sep 28, 2016 1:18 pm

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?
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.
User avatar
microelly2
Posts: 4197
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Reconstructing terrain from contours

Postby microelly2 » Wed Sep 28, 2016 1:45 pm

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
triplus
Posts: 8148
Joined: Mon Dec 12, 2011 4:45 pm

Re: Reconstructing terrain from contours

Postby triplus » Wed Sep 28, 2016 5:30 pm

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?