YirgacheffeLayer
A layer object represents some geospatial data. This might come from:
- A raster data source, for example, data from a GeoTIFF
- A polygon data source, for example, data from a GPKG, GeoJSON, or ESRI Shapefile
- A constant value
- An expression built up using the above inputs using operators to add, divide, etc.
yirgacheffe.YirgacheffeLayer
The common base class for the different layer types. Most still inherit from RasterLayer as deep down they end up as pixels, but this is a start to make other layers that don't need to rasterize not have to carry all that baggage.
area
property
datatype
property
map_projection
property
latlng_for_pixel(x, y)
Get geo coords for pixel. This is relative to the set view window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X axis position within raster |
required |
y
|
int
|
Y axis position within raster |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
A tuple containing the (latitude, longitude). |
pixel_for_latlng(lat, lng)
Get pixel for geo coords. This is relative to the set view window. Result is rounded down to nearest pixel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat
|
float
|
Geospatial latitude in WGS84 |
required |
lng
|
float
|
Geospatial longitude in WGS84 |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
A tuple containing the x, y coordinates in pixel space. |
read_array(x, y, width, height)
Reads data from the layer based on the current reference window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X axis offset for reading |
required |
y
|
int
|
Y axis offset for reading |
required |
width
|
int
|
Width of data to read |
required |
height
|
int
|
Height of data to read |
required |
Returns:
| Type | Description |
|---|---|
Any
|
An array of values from the layer. |
show(ax=None, max_pixels=1000, **kwargs)
Display data using matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Matplotlib axes object. If not provided, the default matplotlib context will be used. |
None
|
|
max_pixels
|
int | None
|
How many pixels to downsample to. If None, raw pixels will be used. |
1000
|
**kwargs
|
Passed to matplotlib imshow. |
{}
|
Returns:
| Type | Description |
|---|---|
|
A matplotlib image. |