"Jip " <fschoenenberger@gmx.ch> wrote in message <i84nl8$p4k$1@fred.mathworks.com>...
> Hi all,
>
> I'm facing a problem that might be very simple, but confuses me a bit.
> Imagine you have gridded topographic data (each grid point with longitude, latitude and elevation for this point).
> I need to calculate the dot product between the gradient of the elevation and a horizontal wind vector (x and y direction) at each grid point.
>
> I used [gridx gridy] = gradient(elevation_data) to calculate the gradient of the topography. Then combined the x and y vector (A=[gridx gridy]) and used dot(A,Wind) to calculate what I wanted.
>
> The problem now is that I:
> 1. don't know if I really calculate the gradient I need if i do it just for x and y dimension or if I have to take more dimensions into account for this problem?
>
> 2. The grid is defined in degrees for longitude and latitude, whereas the gradient should be somehow related to "SI distance" (for example: the gradient is 300m per 5km etc.). For a single Latitude the distance between 2 gridpoints in longitudinal direction could be assumed constant, but as my calculations go from the equator up to about 45°N, I have to take this change into account.
>
> Is there a "simple" solution for that? Any input/comments/suggestions are highly appreciated. Thanks & regards
> Jip
          
On point number 2, you do indeed need to make a variable correction which depends on the local latitude. One of the components of the gradient you get from [gridx gridy] = gradient(elevation_data) will be the (approximate) partial derivative of elevation change with respect to longitude and the other component the partial derivative with respect to latitude. It is the first of these, the derivative with respect to longitude that needs the correction, and this should depend on the latitude there. If latitude is the angle between the equator and the given point, then you should multiply the component by the secant of the latitude or divide it by the cosine. That will make the two partial derivatives comparable  as though they were both being taken at the equator.
I assume in this discussion that your gridded data has equal increments for the latitude and longitude data. Otherwise you would need to input the second and third arguments of 'gradient' for increment information.
On number 1, I don't know what dimension you would have to worry about other than the two local x and y horizontal coordinates. It is the change of the third dimension, elevation, that this procedure is all about.
Roger Stafford
