Tessellation
using SpeciesDistributionToolkit
using CairoMakietessellate
pol = getpolygon(PolygonData(NaturalEarth, Countries))["Austria"]Polygon Feature
├ Region => Europe
├ Subregion => Western Europe
├ Name => Austria
└ Population => 8877067up
tiles = tessellate(pol, 10.)FeatureCollection with 230 features, each with 2 propertiesproj
proj = "EPSG:3416""EPSG:3416"
Code for the figure
f = Figure()
ax = Axis(f[1,1]; aspect=DataAspect())
poly!(ax, pol, color=:grey80)
lines!(ax, tiles, color=:grey20)
Code for the figure
f = Figure()
ax = Axis(f[1,1]; aspect=DataAspect())
poly!(ax, reproject(pol, proj), color=:grey80)
lines!(ax, reproject(tiles, proj), color=:grey20)check
Related documentation
SpeciesDistributionToolkit.tessellate Function
tessellate(obj::T, d::Float64; tile::Symbol=:hexagons, keywords...)This function will take an argument obj that is either an AbstractSDM, an AbstractGeometry, an SDMLayer, or an AbstractOccurrenceCollection, and return a tessellation at a distance d (in kilometers).
Because the shapes that can be used for the tiling differ (see below), the distance d is assumed to be the radius of a circle. This information is then converted to identify the size of the tile that would have an equal area to that of this circle. This ensure that regardless of the shape of the tile that is chosen, the surface they cover is equivalent.
The tessellation is done by picking the upper left corner of the bounding box as the reference point, and working from here, down/right-wards. The shape of the tiles are controlled by the tile arguments, which can take three values: :hexagons, :square, and :triangles. The default is flat side up hexagons.
The tiling is returned as a FeatureCollection containing features that are all Polygon. The features all gain a __centroid property, giving the latitude/longitude of the centroid of the tile, as well as __tile (always true). Either of these can be used to check that the feature collection was produced through the tessellate function.
After the tessellation is finished, all tiles are inspected to ensure that they overlap with the geometry of interest, so that only the relevant tiles are returned. At this stage, in addition to __centroid, the features representing each tile gain additional propeties.
If the object is an SDMLayer, the number of cells that are contained within the tile is stored in __cells. If the object is an AbstractOccurrenceCollection (note that this includes AbstractSDM), the features gain __presences and __absences, which store the number of presence/absences in each tile.
Keyword arguments:
tile: the shape of tiles (as explained above, defaults to:hexagons)padding: a padding to be added to the boundingbox of the object to tessellate; this defaults to0pointy: for:hexagonstiles, whether they are draw pointy side or flat side up
Missing docstring.
Missing docstring for SpeciesDistributionToolkit.keeprelevant!. Check Documenter's build log for details.