In this vertical cut mockup the terrain is grey, the blue star is my reference point (lon, lat, elev), the light yellow area is the cone with a given slope (1:20) and the orange areas are the ones I’m interested in.
How would you approach this problem? My experimentation so far was not very successful. I appreciate your nudging me in the right direction.
That’s a line-of-sight problem. We don’t have anything (that I know) in GMT for that. GDAL actually has a program that in principle could be called (or added to) grdgdal but when I once looked at it I got a bit disappointed with possibilities. Don’t remember more now.
I would imagine that you could create an artificial grid for the cone surface, difference the two grids, and NaN the values <0 (based on the interpretation that you’re looking for the points in orange), all using grdmath. If you want an ASCII file with the points above the cone rather than a grid, you could export with grd2xyz and -s.
With no guarantees, because I haven’t tested or checked this, these are generally the operations that I was thinking of. Feel free to let me know the reasons for this failing, in the case that it doesn’t work. gmt grdmath -R$R -I30s $lon $lat SDIST 1000 MUL 20 DIV $elev ADD data.nc SUB 0 GT 0 NAN = cone_pts.nc
I’m unsure what the unit of my calculated values is. This should give me the distance to my supplied coordinate in 30s increments or doesn’t it (-I30s)? If it is in half arc minute increments and I want Meters I need to multiply it by 3704 (1’ = 1 NM = 1852 m) and divide it by 20 to get my slope.
gmt grdmath dist_from_fra.nc 3704 MUL 20 DIV = slope.nc
I hope so far my attempt makes sense? Here I get caught by my inadequate knowledge of grdmath:
Hi @KristofKoch, the SDIST always returns distances in km:
SDIST 2 1 Spherical (Great circle geodesic) distance (in km) between nodes and stack (A, B)
So if you want meter then 1000 MUL needs to be added.
Also, you cannot use gmtmath (expects tables) to read grids hence it crashes. So stick to grdmath until you have a true/false (1/0) decision for each node, then convert false to NaN, possibly multiply that with your grid if you want the z-values, and then save. Then use grd2xyz -s to skip the NaN nodes to yield the final table.
Hi @pwessel thank you for pointing my errors out – those who can read the docs have a clear advantage. That gmtmath thing was an autocompletion SNAFU. I ran into another snag: @earth_relief_30s comes with pixel node registration … switching it to @earth_relief_30s_g did the trick.