Geostatex.GeoFrame (Geostatex v0.6.0)

Copy Markdown View Source

Adapter between GeoFrame and Geostatex.

Geostatex does not depend on GeoFrame. This module calls GeoFrame's public API (and Explorer's, which GeoFrame brings) at runtime, and raises an ArgumentError saying so when GeoFrame is not loaded. Add {:geoframe, ...} to your own dependencies to use it.

The observations are the centroids of the geometries of a GeoFrame.GeoDataFrame (a point is its own centroid) and the values one of its numeric columns:

Geographic coordinates

Variograms and universal kriging are Euclidean, so they raise ArgumentError on a geographic CRS unless allow_geographic: true. kriging/4 with :ordinary instead uses great-circle distances on a geographic frame (coordinates_type: :geographic) unless told otherwise.

Examples

samples = GeoFrame.read_file!("meuse.gpkg")
model = Geostatex.GeoFrame.kriging(samples, "log_zinc", :ordinary, variogram_model: :spherical)
Geostatex.GeoFrame.grid(model, samples, cell: 40.0)

Summary

Functions

Leave-one-out cross-validation (Geostatex.Kriging.cross_validate/4) of column at the frame's centroids, with the options of kriging/4 (and :n_closest_points).

Predictions on a regular grid of points, as a GeoFrame.GeoDataFrame with the columns "x", "y", "prediction" and "variance". extent is a frame (its total bounds) or {min_x, min_y, max_x, max_y}. Options

A kriging model of column at the frame's centroids: kind is :ordinary (default) or :universal, with the options of Geostatex.Kriging.ordinary/3 or universal/3. A geographic frame uses great-circle distances for ordinary kriging unless :coordinates_type is given.

The centroid coordinates of a frame's (or series') geometries, as {xs, ys} lists.

Predicts at the centroids of targets (a GeoFrame.GeoDataFrame) and returns it with two new columns, "prediction" and "variance" (or prefix <> "prediction" with prefix:). Other options go to Geostatex.Kriging.execute/5 (:n_closest_points, :specified_drift_arrays).

The experimental variogram (Geostatex.Variogram.new/3) of column at the frame's centroids. Options of Geostatex.Variogram.new/3, plus allow_geographic: true.

Functions

cross_validate(frame, column, kind \\ :ordinary, opts \\ [])

@spec cross_validate(struct(), String.t() | atom(), :ordinary | :universal, keyword()) ::
  map()

Leave-one-out cross-validation (Geostatex.Kriging.cross_validate/4) of column at the frame's centroids, with the options of kriging/4 (and :n_closest_points).

grid(model, extent, opts \\ [])

@spec grid(Geostatex.Kriging.t(), struct() | tuple(), keyword()) :: struct()

Predictions on a regular grid of points, as a GeoFrame.GeoDataFrame with the columns "x", "y", "prediction" and "variance". extent is a frame (its total bounds) or {min_x, min_y, max_x, max_y}. Options:

  • :cell - the grid spacing, or :nx and :ny, the number of columns and rows (default 50 each);
  • :max_distance - drop the cells farther than this from every observation;
  • :crs - the CRS of the result (default the extent frame's);
  • other options go to Geostatex.Kriging.execute/5 (:n_closest_points).

kriging(frame, column, kind \\ :ordinary, opts \\ [])

@spec kriging(struct(), String.t() | atom(), :ordinary | :universal, keyword()) ::
  Geostatex.Kriging.t()

A kriging model of column at the frame's centroids: kind is :ordinary (default) or :universal, with the options of Geostatex.Kriging.ordinary/3 or universal/3. A geographic frame uses great-circle distances for ordinary kriging unless :coordinates_type is given.

points(frame)

@spec points(struct()) :: {[float()], [float()]}

The centroid coordinates of a frame's (or series') geometries, as {xs, ys} lists.

predict(model, targets, opts \\ [])

@spec predict(Geostatex.Kriging.t(), struct(), keyword()) :: struct()

Predicts at the centroids of targets (a GeoFrame.GeoDataFrame) and returns it with two new columns, "prediction" and "variance" (or prefix <> "prediction" with prefix:). Other options go to Geostatex.Kriging.execute/5 (:n_closest_points, :specified_drift_arrays).

variogram(frame, column, opts \\ [])

@spec variogram(struct(), String.t() | atom(), keyword()) :: Geostatex.Variogram.t()

The experimental variogram (Geostatex.Variogram.new/3) of column at the frame's centroids. Options of Geostatex.Variogram.new/3, plus allow_geographic: true.