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:
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, nth) Y = numpy.arange(0, _ar.shape, nth) x, y = numpy.gradient(ar) pylab.quiver(X, Y, x, y) pylab.savefig("out.png")
The resulting vector field:
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.