dem-net/DEM.Net

(Question) Can DEM.Net create terrain along a path?

shawty opened this issue · 9 comments

If I already have suitable geoTiff tiles of the landscape I want to work with, can I using a 2D path, and a start height and end height, get DEM.Net to create terrain across my tiles filling in the required cut/fill parts along said path?

My use case is one that I have to take a terrain with no roads, flat planes or anything, and using a set of 2D shapes of proposed road routes, flatten those road corridors through the terrain, starting at start height and interpolating to end height.

Once the road corridors are carved through the terrain, I should then be able to save the tiles back to disk with the exact same geo attributes as they had when loaded.

Hi @shawty. DEM.Net can create terrain from paths: it's already done with GPX tracks. I'm trying to understand your case.
Do you need 3D terrain, or just elevation of given path (calculated from your tiles) ?

You may also join the Slack https://join.slack.com/t/dem-net/shared_invite/enQtNjAxOTE3NTcwMDY1LWJjZDRmMzAxZDI3YzM3MWVjMzAzNjY4NDFkMWM3MmViN2E1YzI5OWM2ZDEyYmZlNWUyYmYzMjJlYThlNTU3ZWI to chat more easily.

Hi @xfischer ,

A picture speaks a 1000 words:

image

This is a segment of a map from 1977 showing part of a steelworks that used to be located near to where I live.

For the past 8+ years I've been creating a digital model of what the site used to like, right down to the terrain.

On the picture you can see a red/green line following the trajectory of the road that used to be the main entrance into the plant.

Now in 2020 all the part of that road in red has been destroyed and the landscape filled in, only the green bit is left.

image

I have 1m resolution Lidar of the entire area, but it's for 2019 and the earliest I can get is 2009, the road and all the embankments where filled in in the mid 1980's!

As part of my project, I'd like to be able to model all these features back in, and even though I have some workflow using GIS packages, it's long labour intensive work, work which I as a professional .NET programmer know I could hugely automate with the right tools and libraries.

What I would like to be able to do is to draw a center line down the middle of the road, tell the algorithm the start height and the end height (Which if you examine the map image closely you'll see are 248.6m & 233.46m respectively, and then have the lib follow the profile of the line for half the width on each side, filling in the correct smoothed grey scale values to create a flat corridor that the road can then be painted into. The algorithm would take into account the surrounding terrain, and where required fill in gaps underneath, while cutting through land that's higher creating valleys and embankments as it goes.

Many of the high end expensive softwares like "Global Mapper" can perform operations like this, but for a hobby project that isn't going to make any money I cannot justify spending $10000 on a package I'll only use a few times.

I'd also if possible like to be able to generate break lines at the top and bottom of embankments so I can remodel bank sides (Such as those around the cooling towers in the map image.

Hope that's a better explanation?

If DEM.Net could help me create something to perform this task, I'd be more than happy to give the app back to open source for others to use.

I think we could do something... Do you have time to work on this with me ?
So to be clear you want the library to alter the elevation model to build a surface model from the red road, resulting in a new DEM GeoTIFF ?
What exactly are your inputs, which data is stored in those GeoTIFFs ? Can you send me out some data ?

@xfischer I'll try my best to work with you, but between running LiDNUG, beta testing on dotnet core 3/blazor & webview2 and about half a dozen other projects, my time does get a bit on the tight side :-)

It's a bit late in the UK now, but over the next few days let me upload a .NET app and some SQL in a PostgreSQL GIS db I was using to try to help make this task easier.

In the meantime, take a look at this video : https://www.youtube.com/watch?v=p7XT9VXAX5E at around the 41 minute mark.

The video is of the top price software global mapper that's used for these kind's of operations.

The demo they give is of a rectangle and a "level playing field" and the result is a flattened plateau, with it's back cut into the hillside, and the front filled to support it. My use case is very similar, except that the flattened area would run as a channel, from a start to an end. so if you imagine the video demo starting at the top and ending at the bottom of the hill, the algorithm would first need to work out the optimum angle, then look to see what areas needed "supporting" (Filled) and what would need to be removed to maintain the trajectory.

The inputs are a start height and an end height a channel width, and a 2d line drawn down the middle representing the trajectory "center line"

The way I've been doing it in my "app" that I wrote to assist me, was to load a map geo-referenced map into sharp map in a .NET winforms app. I then used GDI to draw a line where I wanted the road to appear, I then linear referenced the line and created a point every 1 meter along it's length (This is UK so I'm using EPSG:27700 - OSGB36) at each of those 1 meter intervals half the width of my road I created a new point, and I interpolated from start to finish for the number of points I had, so for EG:

If the road was 100 meters long, that was "(start - end)/100", which I then used to give a z position to each point. That then created me a set of points which I then loaded into QGis and used the TIN Surface maker algorithm on.

This work OK'ish for straight roads & cuttings, but starts to break down very quickly when you start having to go around curves.

As for sample height dems, yes I do have them, but the files are 36mb & 57mb respectively. I can however point you to where they where downloaded from:

https://environment.data.gov.uk/DefraDataDownload/?Mode=survey

For my location (IE: the map and google earth image above) you want to be zooming in on the town of consett (Near Newcastle-upon-tyne) in north east England.

The actual area you want is here:

image

The ones I'm currently using are the 1m tiles from 2009

image

The earliest they are, but as I said above, the landscape I'm trying to rebuild was destroyed in the mid to late 1980's long before any lidar level mapping was done.

The ordnance Survey Open Data "Terrain 50" product does go back further about 20 years ago, but that's at 50 meter resolution, so on that data set it all just looks like shallow rolling hills.

You can get a feel for the modeling work I've been doing so far here:

https://www.flickr.com/photos/18885387@N00/albums/72157653372497261

on my flikr page.

I also have some 2D mapping in vector format that I've been adding to my Google Maps page: https://www.google.com/maps/d/u/0/edit?hl=en&mid=1iQuPGLNC37FLdcARaPoS_lRW-QYvB9tn&ll=54.85015498825382%2C-1.844993986000758&z=16

The area in the black and white map above is here:

image

The two orange circles are the 2 cooling towers to the upper left of the map image in the first post.

Thanks for all that information @shawty :)
OK I think I get it. Please correct me if I'm wrong :

Given

  • a set of Digital Elevation Models (here LiDAR Tiles DTM 1m)
  • a set of connected polylines (ie: a road network) with know heights at various curvilinear locations, and a given width
  • an algorithm giving a slope for any "supporting" hill and "excavated" hill

You want

  • an updated DTM "supporting the road"

If this is true, then what should we do if the "supporting" hill intersects a building you have ? Is that part of the algorithm giving the required slope (with an avoidance rule ?)

Hi @xfischer

a set of connected polylines (ie: a road network) with know heights at various curvilinear locations, and a given width

Just the start and end for what I was doing, but yes I guess if some of the points in between are known then it would be useful to be able to describe them.

an algorithm giving a slope for any "supporting" hill and "excavated" hill

I was using "algorithm" to describe the procedure in the code, and not supplied by the caller of the library function, but I guess it wouldn't hurt to be able to do it.

• an updated DTM "supporting the road"

Yep pretty much, so a raw DEM would go in, and a modified DEM would be emitted at the other side

If this is true, then what should we do if the "supporting" hill intersects a building you have ? Is that part of the algorithm giving the required slope (with an avoidance rule ?)

To be fair, I've never actually thought about this scenario :-) in terms of small adjustments like that, I always used to like the way you could edit terrain in the older versions of terragen, where you had a small 2D canvas and a grey scale brush, that heightened terrain with the left button press and lowered with the right, I always envisaged being able to paint things like that.

The app I created to help me looks like this:

image

You can see the thin black line, drawn on the road, and the dialog it pops up and asks me after I've double clicked to finish drawing.

The result is a polygon drawn the width of the road, with the points around the sides set at appropriate heights.

image

The polygon is then saved (Or mores the point, the point locations around the edge, with an X,Y and a Z/m set of co-ordinates)

Those co-ordinates where then fed into some "grass" algorithms in QGis to generate a TIN model as previously described.

I've attached the sources for the code I've written to date, however it uses a local/internal WMS service for the 2D mapping, which you won't have access too, so you'll need to wire up your own WMS service to make it work.

Essentially though, once the polygon is buffered and created, that should give you a suitable polygon to then grade from start to end height, and stamp into a given DEM.

GMRoadMakerSM.zip

If this zip gives you problems, let me know, I have a couple of different versions, I'm sure this was the working one :-)

@shawty I have a couple of strategies to solve your problem. Not so much time to work on that but sure later on. Is there a time constraint on your side ?

Hi @xfischer nope, no time constraint. It's only a pet project, and it's took me over 8 years to get where I am now :-)

I'm going to be too busy to pursue any of it for about 6 months starting in a weeks time anyway, as I've just landed a new client and that's going to be keeping me busy for a while.

Just ping me when you have anything to go on, and I'll jump in and see what I can rustle up.

Hi @xfischer - well 6 months, turned into just over a year with that client mentioned above :-)

Now I'm back to a little bit if a Hiatus between projects, looking for my next gig, so going have a look at this again, and see what I might be able to come up with.