Extents.jl

A shared Extent object for Julia spatial data
Author rafaqz
Popularity
2 Stars
Updated Last
12 Months Ago
Started In
March 2022

Extents

Stable Dev Build Status Coverage

Extents.jl is a small package that defines an Extent object that can be used by the different Julia spatial data packages. Extent is a wrapper for a NamedTuple of tuples holding the lower and upper bounds for each dimension of a object. It is used in GeoInterface.jl, as the required return type for the extent function, and in DimensionalData.jl and Rasters.jl to subset arrays with named dimensions.

Quick start

julia> using Extents

julia> ext1 = Extent(X = (1.0, 2.0), Y = (3.0, 4.0))

julia> ext2 = Extent(X = (1.5, 2.5), Y = (3.0, 4.0))

julia> # find the dimensions

julia> keys(ext1)
(:X, :Y)

julia> # get the extent for a single dimension by name

julia> ext1.X
(1.0, 2.0)

julia> # get the underlying NamedTuple

julia> bounds(ext1)
(X = (1.0, 2.0), Y = (3.0, 4.0))

julia> # compare different extents

julia> Extents.intersects(ext1, ext2)
true

julia> Extents.intersect(ext1, ext2)
Extent(X = (1.5, 2.0), Y = (3.0, 4.0))

julia> Extents.union(ext1, ext2)
Extent(X = (1.0, 2.5), Y = (3.0, 4.0))