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.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Reconstructing terrain from contours

Post by yorik »

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 6731 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 116 times
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Reconstructing terrain from contours

Post by bernd »

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:
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Reconstructing terrain from contours

Post by looo »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Reconstructing terrain from contours

Post by microelly2 »

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
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Reconstructing terrain from contours

Post by yorik »

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
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Reconstructing terrain from contours

Post by PrzemoF »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Reconstructing terrain from contours

Post by microelly2 »

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

Re: Reconstructing terrain from contours

Post by zumer »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Reconstructing terrain from contours

Post by microelly2 »

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

Re: Reconstructing terrain from contours

Post by triplus »

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?
Post Reply