Skip to content

API reference

AreaInterpolation.AbstractInterpolationMethod Type
julia
abstract type AbstractInterpolationMethod

The abstract type for all areal interpolation methods.

Interface

All AbstractArealInterpolators must implement the following interface:

  • interpolate(interpolator::AbstractInterpolationMethod, target::GI.AbstractPolygon, sources, values::Vector{Vector}, source_rtree)

This interface is not set in stone and can be changed!

TODOS: - extensive vs intensive variables (currently we act as though variables are intensive) - weight methods (sum vs total) - just pass any arbitrary accumulator

source

AreaInterpolation.Dasymetric Type
julia
Dasymetric(mask::Raster)

Dasymetric interpolation uses a mask to weight the influence of each polygon.

Depending on the choice of mask, like land-use data, this can prove to be a more accurate interpolation than the direct or pycnophylactic methods.

source

AreaInterpolation.Direct Type
julia
Direct()

A simple direct method for areal interpolation.

Takes the area-weighted mean of all source polygons' features, weighted by their areas of intersection with the target polygon.

This method does not allocate a Raster, but it does perform polygon intersection tests.

source

AreaInterpolation.Pycno Type
julia
Pycno(...)

Alias for Pycnophylactic.

source

AreaInterpolation.Pycnophylactic Type
julia
Pycnophylactic(cellsize; relaxation, maxiters, tol)

A pycnophylactic method for areal interpolation.

Pycnophylactic interpolation (Tobler, 1979) interpolates the source zone attribute to the target zones in a way that avoids sharp discontinuities between neighbouring target zones. It assumes that no sharp boundaries exist in the distribution of the allocated data, which may not be the case, for example, when target zones are divided by linear features (rivers, railways, roads) or are adjacent to waterbodies.

However, it generates intuitively elegant allocations for many urban case studies with many applications (Kounadi, Ristea, Leitner, & Langford, 2018; Comber, Proctor, & Anthony, 2008).

This description was taken in part from the GIS&T Body of Knowledge.

Fields

  • cellsize: The cell size of the raster to be interpolated, in units of the CRS of the input polygons (can be degrees or meters). Required argument!

  • kernel: The kernel with which to smooth the raster. Defaults to a 2-D Moore window of size 1, with value 0.5.

  • relaxation: The relaxation factor. Defaults to 0.2.

  • maxiters: The maximum number of iterations. Defaults to 300.

  • tol: The error tolerance at which convergence is achieved. Defaults to 10e-3.

Differences from other implementations

tobler in Python uses the equivalent of Stencils.Kernel(Stencils.Cross(1, 2), [0.25, 0.25, 0, 0.25, 0.25]). This implementation allows arbitrary kernels, so the user can choose the kind of smoothing and kernel window based on their desires.

source

AreaInterpolation.decompose_to_geoms_and_values Method
julia
decompose_to_geoms_and_values(sources; features = nothing)

Decompose a table or feature collection into geometries and values. Returns (geometries::Vector{Geometry}, values::NamedTuple{Vector}).

values is a namedtuple of each value column in sources. A value column is something whose eltype satisfies isvaluecol, and is currently Union{Number, Missing}.

source

AreaInterpolation.nan_aware_kernelproduct Method
julia
nan_aware_kernelproduct(hood::Stencils.Stencil{<:Any,<:Any,L}, kernel) where L

Compute the dot product of the kernel and the stencil, ignoring NaN values. This function is the equivalent of Stencils.kernelproduct.

source

AreaInterpolation.pycno_iteration! Method
julia
pycno_iteration!(old, new, sa, polygon_views, vals, relaxation)::Float64

Perform a single iteration of the pycnophylactic algorithm, and overwrites the values in new and old with the result. Returns the absolute maximum change in the data.

Steps

  1. Convolve the stencil in sa with old (stored in sa as well).

  2. Apply the relaxation term to new and old.

  3. Apply the area based correction to new.

  4. Reset any negative values to 0.

  5. Apply the mass preserving correction to new.

  6. Find the maximum change in the data.

  7. Overwrite the old data with the new data.

Note that the kernel in sa must be normalized in the 1-norm. Additionally, the kernel is slightly different than the regular finite difference kernel - the center or self element is added separately, and therefore must be 0 in the kernel weight. Instead of a window, one might pass a Moore neighbourhood (which excludes the center).

source

AreaInterpolation.pycno_raster Method
julia
pycno_raster(pycno::Pycnophylactic, source_geometries, vals; extensive = false)::Raster

Perform pycnophylactic interpolation on source_geometries, using vals as the values. If extensive is true, then vals are the extensive values, and the area-adjusted values are computed for the intensive ones. Otherwise, vals are the intensive values, and the area-adjusted values are computed for the extensive ones.

source

AreaInterpolation.rasterized_polygon_areas Method
julia
rasterized_polygon_areas(source_geometries, cellsize::Real)::Vector{Float64}

Compute the rasterized area of each polygon in source_geometries, on a Raster with resolution cellsize. sour

Returns a vector of cell counts per source geometry.

source