A point in a raster class

class PointInRaster(raster, affine, x, y)[source]

Class denoting a point in a raster. This a wrapper around class rasterstats.point optimizing some operations, primarily the bilinear interpolation

See also https://pythonhosted.org/rasterstats/_modules/rasterstats/point.html

COMPLETELY_MASKED = 1
PARTIALLY_MASKED = 2
window

Window representing 2x2 window whose center points encompass point

x

X coordinate of the point

y

Y coordinate of the point

is_masked() bool[source]
array(raster)[source]

Returns an array consisting of the corners of the rectangular, containing this point.

Parameters:

raster

Returns:

bilinear(raster) Optional[float][source]

An optimized version of rasterstats.point function: given a point’s window as 2x2 array, and x, y as its coordinates, treat center points as a unit square.

+---+---+
| A | B |      +----+
+---+---+  =>  |    |
| C | D |      +----+
+---+---+
e.g.: Center of A is at (0, 1) on unit square, D is at (1, 0), etc
Parameters:

raster – Raster, to which the point belongs

Returns:

the value for the fractional row/col using bilinear interpolation between the cells