0
$\begingroup$

I am trying to figure out if it's possible to create vector velocity field from some raster containing spatial distribution of scalar variable (timestamp of some mass-media event in my case).

Here is my GeoTIFF overlapped with isochrones drown from the six-hours interval. Cold colors correspond to zones where some event happened earlier. Warm colors match to the areas where that event occurred later:

enter image description here

I would like to convert that GeoTIFF image to format quite common for fluid dynamics and hydro-meteorology: a quiver plot. I suggest that vectors should represent the speed of information spatial dissemination.

import gdal
from gdalconst import *
import numpy
import pylab

dataset = gdal.Open("raster.tif", GA_ReadOnly)
_ar = dataset.ReadAsArray()

#Making the dataset little bit sparser...
nth=4
ar = _ar[::nth, ::nth]
X = numpy.arange(0, _ar.shape[0], nth)
Y = numpy.arange(0, _ar.shape[0], nth)
x, y = numpy.gradient(ar)

pylab.quiver(X, Y, x, y)
pylab.savefig("out.png")

The resulting vector field: enter image description here

I guess I'm doing something wrong in the code above cause result is confusing. You can see that in fact I'm getting the gradients of timestamp, whereas I really need the gradients of velocity. The warmer zones are surrounded by large arrows corresponding to long periods of information dissemination, BUT I need the opposite effect:

longer time lag <-> low information distribution speed <-> warmer color <-> shorter arrows

shorter time lag <-> high information distribution speed <-> colder color <-> longer arrows

I would appreciate to get possible solutions in Python or R.

$\endgroup$
  • $\begingroup$ Could you elaborate on exactly how your result is "wrong"? What would the right result look like and what would it represent? $\endgroup$ – whuber Nov 20 '14 at 23:49
  • $\begingroup$ @whuber, I think I get time gradients whereas I really need velocity gradients. $\endgroup$ – Vitaly Isaev Nov 21 '14 at 0:02

Your Answer

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

Browse other questions tagged or ask your own question.