API reference
AreaInterpolation.AbstractInterpolationMethod
AreaInterpolation.Dasymetric
AreaInterpolation.Direct
AreaInterpolation.Pycno
AreaInterpolation.Pycnophylactic
AreaInterpolation.decompose_to_geoms_and_values
AreaInterpolation.nan_aware_kernelproduct
AreaInterpolation.pycno_iteration!
AreaInterpolation.pycno_raster
AreaInterpolation.rasterized_polygon_areas
AreaInterpolation.AbstractInterpolationMethod Type
abstract type AbstractInterpolationMethod
The abstract type for all areal interpolation methods.
Interface
All AbstractArealInterpolator
s 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
AreaInterpolation.Dasymetric Type
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.
AreaInterpolation.Direct Type
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.
AreaInterpolation.Pycnophylactic Type
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 to0.2
.maxiters
: The maximum number of iterations. Defaults to300
.tol
: The error tolerance at which convergence is achieved. Defaults to10e-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.
AreaInterpolation.decompose_to_geoms_and_values Method
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}
.
AreaInterpolation.nan_aware_kernelproduct Method
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
.
AreaInterpolation.pycno_iteration! Method
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
Convolve the stencil in
sa
withold
(stored insa
as well).Apply the relaxation term to
new
andold
.Apply the area based correction to
new
.Reset any negative values to 0.
Apply the mass preserving correction to
new
.Find the maximum change in the data.
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).
AreaInterpolation.pycno_raster Method
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.
AreaInterpolation.rasterized_polygon_areas Method
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.