# Miscellaneous

Below is a list of miscellaneous geospatial operations.

## Split

using GeoStats
using GeoStatsImages

๐ = geostatsimage("Strebelle")

# 50/50 split perpendicular to (1.,1.)
S = split(๐, 0.5, (1.,1.))

plot(plot(S[1],ms=0.2), plot(S[2],ms=0.2))

## Slice

Meshes.slice โ Function
slice(object, xmin:xmax, ymin:ymax, ...)

Slice the object using real coordinate ranges xmin:xmax, ymin:ymax, ...

Notes

This function is equivalent to view(object, Box(first.(ranges), last.(ranges)).

In Julia the range 0.5:10.0 is materialized as [0.5, ..., 9.5] so it won't necessarily include the right value. This behavior is different than the more intuitive behavior of view(object, Box((0.5,0.5), (10.0,10.0)).

# slice image
I = geostatsimage("Strebelle")
S = slice(I, 50.5:100.2, 41.7:81.3)

# slide point set
P = sample(I, 100)
S = slice(P, 50.5:150.7, 175.2:250.3)

p2 = plot(plot(P), plot(S), link=:both, ms=3)

plot(p1, p2, layout=(2,1))

## Unique

GeoStatsBase.uniquecoords โ Function
uniquecoords(data, agg=Dict())

Retain locations in data with unique coordinates.

Duplicates of a variable var are aggregated with aggregation function agg[var]. Default aggregation function is mean for continuous variables and first otherwise.

D = georef((z=[0, 1, 0],), [(0.,0.), (1.,0.), (0.,0.)])

U = uniquecoords(D)

Tables.rows(U)
Meshes.DataRows{DomainView{2, Float64, PointSet{2, Float64}, Vector{Int64}}, TypedTables.Table{NamedTuple{(:z,), Tuple{Int64}}, 1, NamedTuple{(:z,), Tuple{Vector{Int64}}}}}(2 View{3 PointSet{2,Float64}}, NamedTuple{(:z,), Tuple{Int64}}[(z = 1,), (z = 0,)])

## Trend

# quadratic + noise
r = range(-1,stop=1,length=100)
ฮผ = [x^2 + y^2 for x in r, y in r]
ฯต = 0.1rand(100,100)
๐ = georef((z=ฮผ+ฯต,))

โณ = trend(๐, :z, degree=2)

plot(plot(๐), plot(โณ))

## Groupby

GeoStatsBase.groupby โ Method
groupby(data, var)

Partition spatial data into groups of constant value for spatial variable var.

Notes

Missing values are grouped into a separate group.

๐ = geostatsimage("Strebelle")

โฑ = groupby(๐, :facies)

plot(plot(โฑ[1],ms=0.2), plot(โฑ[2],ms=0.2))

## Integrate

GeoStatsBase.integrate โ Method
integrate(data, var; rank=nothing)

Integrate data for variable var over geometries of given rank. Default rank is the parametric dimension of the underlying domain where the data is georeferenced.