How can I find the cells which lie on a straight line between two points? I.e. how can I find the indices of the cells (in grey) which are intersected by the line defined by the two points (in blue):
I want to do this in order to read off values from the underlying DTM and thus extract the height profile along the line....
Using the geotransform of the raster, it is easy to convert the two points to cell offsets, so my first thought was to create many points along the line and convert each of these. However the problem here is creating points at the right distance to successfully capture each intersected cell (while also not creating a ridiculous number of points so that it would be incredibly inefficient)
Looking for ideas that are either programmatic (python/C++) or theory (e.g. no arcgis tools! gdal ok...)