rast_gdal — bridge to GDAL for windowed raster I/O.
rast does not implement raster I/O, reprojection, COG, CRS or nodata
semantics — GDAL owns all of that (ARCHITECTURE.md §8). This module is the
seam. It is a **CLI port** driven via open_port({spawn_executable, ...})
(no shell, so no Windows quoting hell): metadata via gdalinfo -json,
windowed reads via gdal_translate -srcwin into a headerless ENVI raw that
Erlang reads back. (Per-tile subprocess spawn is the simple first cut; a
persistent port or a dedicated NIF over the gdal crate is the later
optimization.)
Writes go the other way: GDAL cannot easily patch a sub-window into an
existing raster from the CLI, so the output is owned by Erlang as a flat raw
file — workers pwrite their tiles at the right offsets — and a single
gdal_translate wraps the finished raw into a GeoTIFF at the end.
application:get_env(rast, gdal_bin_dir), else $GDAL_BIN_DIR,
else the platform default (C:/Program Files/GDAL on Windows), else PATH.
handle() = #{source := string(), width := pos_integer(), height := pos_integer(), bands := pos_integer(), dtype := binary()}
out() = #{path := string(), fd := file:io_device(), width := pos_integer(), height := pos_integer(), bpp := pos_integer(), dtype := binary()}
window() = rast_tiling:tile()
| available/0 | Whether the GDAL CLI can actually be run. |
| close/1 | Release the handle (no-op for the CLI port). |
| create_output/4 | Create a flat raw output sized W × H, ready for windowed pwrites. |
| finalize/1 | Close the raw file and wrap it into a GeoTIFF at Path via a single
gdal_translate. |
| info/1 | Metadata map for an open handle. |
| open/1 | Open a raster source and read its metadata via gdalinfo -json. |
| read_window/2 | Read band 1 of a window as a little-endian binary in the source dtype. |
| read_window/3 | Read Band of a window as a little-endian binary in the source dtype. |
| write_window/3 | Scatter a tile result into the flat output: TH row-writes at the
tile's byte offsets in the full-width raster. |
available() -> boolean()
Whether the GDAL CLI can actually be run. Probes by executing
gdalinfo --version; a missing or non-runnable binary yields false (so the
GDAL-backed tests skip cleanly rather than fail).
close(Handle::handle()) -> ok
Release the handle (no-op for the CLI port).
create_output(Path::string(), W::pos_integer(), H::pos_integer(), X4::map()) -> {ok, out()} | {error, term()}
Create a flat raw output sized W × H, ready for windowed pwrites.
DType is the *output* dtype (e.g. <<"Float32">> for NDVI results).
finalize(X1::out()) -> {ok, string()} | {error, term()}
Close the raw file and wrap it into a GeoTIFF at Path via a single
gdal_translate. Writes a minimal ENVI header so GDAL can read the raw.
info(Handle::handle()) -> {ok, map()} | {error, term()}
Metadata map for an open handle.
open(Source::string()) -> {ok, handle()} | {error, term()}
Open a raster source and read its metadata via gdalinfo -json.
Read band 1 of a window as a little-endian binary in the source dtype.
Read Band of a window as a little-endian binary in the source dtype.
For convolution, pass a window already grown by the halo width.
Scatter a tile result into the flat output: TH row-writes at the
tile's byte offsets in the full-width raster.
Generated by EDoc