Re: Understanding use of epsilon in transform.rowcol


Sean Gillies
 

Hi,

Sorry for the late reply. I've just returned from vacation.

We've found that we need to account for float imprecision when inverting the forward geotransform. Specifically, we intend (with op=floor, the default) that points on the left edge of pixels in column 0 to compute as within column 0 and we want points on the boundary between column 0 and column 1 to compute as within column 1. Now, this is only an internal detail. We may yet determine that there is a better way to deal with the precision issues and I suspect there probably is a better way.


On Wed, Jul 14, 2021 at 7:16 AM <tom.russell@...> wrote:
Hi, I'm trying to understand the use of epsilon in rasterio.transform.rowcol

Specifically here - https://github.com/groutr/rasterio/blob/95d77c5e8553405a9dee373ae815072cf91d5cd1/rasterio/transform.py#L240 - where, as I read it, a point to be transformed from world coordinates to raster row/column indices is nudged by epsilon before being transformed, in the direction of the interior of the raster cell.

Why do we need to translate it that small amount before transforming? My guess is that it avoids later rounding or off-by-one errors, but I'm struggling to come up with an example or small test case.

Am I on the right lines? Is there good background material (or keywords to search on) that I'm missing for this kind of thing?

Thanks in advance, I hope this is the right forum for these questions.

--
Sean Gillies

Join main@rasterio.groups.io to automatically receive all group messages.