1

I need to create a raster with values showing directions relative to a single point. Each cell will have the azimuth to the origin point.

Basic trigonometry could calculate this using the differences in x and y coordinates of the 'point.shp' for each cell but I am not aware of a suitable QGIS process.

Is it possible to access the geographic coordinates for each cell within raster calculator, to allow me to calculate the azimuths for each cell into a new raster?

  • do you want the result to be a raster where each cell is the azimuth to a single point (if you're familiar with GIMP / Photoshop / Illustrator, the result will look like a conical fill)? Or do you have multiple points? – Steven Kay Jul 18 '17 at 19:23
1

In theory this should be possible using either GRASS r.mapcalc or SAGA raster calculator. I'll assume you have a single origin point for this.

However I've not been able to get this to work, but I'll leave this here in case someone can suggest improvements/corrections, or it sets you off in the right direction.

To get this to work you'll need an origin x and y values and your raster calculator needs to

  • be able to use the geographic x and y coordinates in the function (question 1)
  • have an atan2 function (or atan) to be able to compute the azimuth to the origin

Both GRASS and SAGA tick both boxes.

  • In GRASS, use x() and y() to get current pixel coordinate
  • In SAGA use xpos() and ypos() to get the same

QGIS doesn't seem to support geographic coordinates as part of the formula, but does support atan. So QGIS raster calculator is no use here. (Someone correct me if I'm wrong)

From this source, I think the function should look something like (in GRASS)

90 - ((180/PI) * atan2( y()-origin_y, x()-origin_x))

Replace origin_y and origin_x with the coords of the point.

As I said, I've not got this to work (and in some cases it crashes QGIS completely, although I found that making sure the origin point is not exactly on a pixel centre fixes that).

Note that cartesian approach like this is suitable for small areas on a UTM projection. If you're working with lat/lon or over larger areas, you'd need a different approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.