[gdal-dev] Slope obtained with GDAL has weird lines
Martin Chapman
mchapman at hyperacktive.com
Tue Mar 17 15:50:03 PDT 2020
Danilo,
Resampling only occurs when an image is being resized or warped. If the dimensions are not changing then resampling is not really appropriate. If you do need to resample, the utilities called gdal_translate.exe and gdalwarp.exe may be used depending on your needs. Other utilities also provide resample options but they may not fit your purposes.
As a general rule you should NOT use nearest neighbor to resample elevation (floating point) data because it can drastically alter the elevation values from the original values and creates a staircase like effect in the output imagery. Use something like cubic or bilinear. That said, if the input data is bad then nothing you do will fix it. Maybe look on the web for the USGS 3Dep elevation data if you are in the USA or SRTM 1 arc second data for continuous worldwide coverage. Maybe the source data you are using is just bad or has been altered.
You should definitely NOT resample the slope output. I think your source data may just be bad but it’s hard to know. Download other sources and compare the output. If the output looks similar then review your code or command line options.
Best regards,
Martin Chapman
From: gdal-dev [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Danilo da Rosa
Sent: Tuesday, March 17, 2020 2:25 PM
To: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] Slope obtained with GDAL has weird lines
Thanks for your answers Joaquim, Alex and Martin!
I think the problem is height is measured by 1m intervals, thatś why I see 1 meter contour lines in the slope result. The dem grid was not interpolated from contours, at least not by me, the data comes from Mapzen terrain tiles, I don't know exactly how they are producing it.
Do you think it would be a good idea to do some kind of interpolation to smooth the DEM file or the slope file? Do you have any recommendations on how to do that using gdal? The idea is to use the gdaldem color-relief command to generate a coloured and easy to read map. The problem is that this lines makes the map more difficult to understand, which is a priority in this case.
Thanks again!
Danilo
El mar., 17 mar. 2020 a las 4:50, Martin Chapman (<mchapman at hyperacktive.com>) escribió:
A slope map indicates the maximum rate of change between a pixel elevation value and its neighboring 8 pixels. In other words, the output value for each pixel represents the steepest slope, or decent to the neighboring elevation values. The output values are given as either percent slope or degrees from 0 (flat) to 90 (vertical) depending on the command line switches you choose.
Therefore, the output raster values no longer represent elevation values from the input but rather slope (steepness) values and should be interpreted differently. A common way to visually interpret them would be to color code them with a color ramp where each color in the ramp represents a range of degrees somewhere between 0 and 90. That way a user can look at the image and quickly identify steep slopes versus not so steep slopes and flat areas. To create a color ramp that matches changes in steepness you will need to use a statistical method on the slope values such as standard deviations or jenks natural breaks to group similar slope values together and where they change. In other words, you will want your color ramp to change colors where flat areas start to get steeper. I hope that makes sense.
Another way to use the results would be to write an algorithm to identify areas that are within a certain range of steepness so you could identify a good place to build a road or perhaps lay train tracks that must not exceed a certain steepness.
I hope that helps.
Best regards,
Martin Chapman
On Mar 16, 2020, at 5:09 PM, Danilo da Rosa <daniloide at gmail.com> wrote:
Hi!
This may be a very basic question, but I can't find the answer anyware.
I am working with this DEM obtained using terraincache <https://pypi.org/project/terraincache/> , it uses mapzen data. The SRC is WGS 84.
<https://i.stack.imgur.com/Sp4Sg.jpg> DEM File in QGIS
I ran this GDAL command to get the slope:
gdaldem slope -s 111120 dem.tif slope.tif (I had to do scaling because of the SRC)
The resulting image looks fine but it's not smooth, it has weird lines over it, like contour lines.
<https://i.stack.imgur.com/POcHR.jpg> Slope file on QGIS
You can download the DEM file here: https://gofile.io/?c=Du7WnM
Does anyone have an idea of how to solve it?
Thanks in advance for your help,
Danilo
P.S. I made this question here too: https://gis.stackexchange.com/questions/353983/slope-obtained-with-gdal-has-weird-lines
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200317/21d26ae8/attachment.html>
More information about the gdal-dev
mailing list