diff --git a/dev/reference/index.html b/dev/reference/index.html index 415fa13ed..c06acfd2a 100644 --- a/dev/reference/index.html +++ b/dev/reference/index.html @@ -826,14 +826,14 @@

Reference - Exported functionssource

+

source

# Rasters.AbstractRasterType.

AbstractRaster <: DimensionalData.AbstractDimArray
 

Abstract supertype for objects that wrap an array (or location of an array) and metadata about its contents. It may be memory or hold a FileArray, which holds the filename, and is only opened when required.

AbstractRasters inherit from AbstractDimArray from DimensionalData.jl. They can be indexed as regular Julia arrays or with DimensionalData.jl Dimensions. They will plot as a heatmap in Plots.jl with correct coordinates and labels, even after slicing with getindex or view. getindex on a AbstractRaster will always return a memory-backed Raster.

-

source

+

source

# Rasters.AbstractRasterSeriesType.

AbstractRasterSeries <: DimensionalData.AbstractDimensionalArray
@@ -844,7 +844,7 @@ 

Reference - Exported functions
RasterSeries[Time(Near(DateTime(2001, 1))][:temp][Y(Between(70, 150)), X(Between(-20,20))] |> plot`
 

RasterSeries is the concrete implementation.

-

source

+

source

# Rasters.AbstractRasterStackType.

AbstractRasterStack
@@ -854,7 +854,7 @@ 

Reference - Exported functions. raster[:somelayer] |> plot plots the layers array, while raster[:somelayer, X(1:100), Band(2)] |> plot will plot the subset without loading the whole array.

getindex on an AbstractRasterStack with a key returns another stack with getindex applied to all the arrays in the stack.

-

source

+

source

# Rasters.BandType.

Band <: Dimension
@@ -869,7 +869,7 @@ 

Reference - Exported functions# Or mean(A; dims=Band)

-

source

+

source

# Rasters.MappedType.

Mapped <: AbstractProjected
@@ -880,7 +880,7 @@ 

Reference - Exported functionsAbstractSampled LookupArray, where the dimension index has been mapped to another projection, usually lat/lon or EPSG(4326). Mapped matches the dimension format commonly used in netcdf files.

Fields and behaviours are identical to Sampled with the addition of crs and mappedcrs fields.

The mapped dimension index will be used as for Sampled, but to save in another format the underlying crs may be used to convert it.

-

source

+

source

# Rasters.ProjectedType.

Projected <: AbstractProjected
@@ -895,7 +895,7 @@ 

Reference - Exported functionssource

+

source

# Rasters.RasterType.

Raster <: AbsractRaster
@@ -922,7 +922,7 @@ 

Reference - Exported functionssource

+

source

# Rasters.RasterSeriesType.

RasterSeries <: AbstractRasterSeries
@@ -973,7 +973,7 @@ 

Reference - Exported functionssource

+

source

# Rasters.RasterStackType.

RasterStack <: AbstrackRasterStack
@@ -1004,7 +1004,7 @@ 

Reference - Exported functionsstack = RasterStack(files; mappedcrs=EPSG(4326)) stack[:relhum][Lat(Contains(-37), Lon(Contains(144))

-

source

+

source

# DimensionalData.modifyMethod.

modify(f, series::AbstractRasterSeries)
@@ -1013,7 +1013,7 @@ 

Reference - Exported functionssource

+

source

# Rasters.aggregateFunction.

aggregate(method, object, scale; filename, progress, skipmissing)
@@ -1044,7 +1044,7 @@ 

Reference - Exported functions

Note: currently it is faster to aggregate over memory-backed arrays. Use read on src before use where required.

-

source

+

source

# Rasters.aggregate!Method.

aggregate!(method, dst::AbstractRaster, src::AbstractRaster, scale; skipmissingval=false)
@@ -1062,7 +1062,7 @@ 

Reference - Exported functionsread on src before use where required.

-

source

+

source

# Rasters.boolmaskFunction.

boolmask(obj::Raster; [missingval])
@@ -1112,7 +1112,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.classifyFunction.

classify(x, pairs; lower=(>=), upper=(<), others=nothing)
@@ -1149,7 +1149,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.classify!Method.

classify!(x, pairs...; lower, upper, others)
@@ -1199,7 +1199,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.combineMethod.

combine(A::Union{AbstractRaster,AbstractRasterStack,AbstracRasterSeries}, [dims]) => Raster
@@ -1207,14 +1207,14 @@ 

Reference - Exported functionssource

+

source

<a id='Rasters.convertlookup-Tuple{Type{<:LookupArray}, AbstractDimArray}' href='#Rasters.convertlookup-Tuple{Type{<:LookupArray}, AbstractDimArray}'># Rasters.convertlookupMethod.

convertlookup(dstlookup::Type{<:LookupArray}, x)
 

Convert the dimension lookup between Projected and Mapped. Other dimension lookups pass through unchanged.

This is used to e.g. save a netcdf file to GeoTiff.

-

source

+

source

# Rasters.coverage!Method.

coverage!(A, geom; [mode, scale])
@@ -1238,7 +1238,7 @@ 

Reference - Exported functionssource

+

source

# Rasters.coverageMethod.

coverage(mode, geom; [to, res, size, scale, verbose, progress])
@@ -1268,7 +1268,7 @@ 

Reference - Exported functionssource

+

source

# Rasters.cropFunction.

crop(x; to)
@@ -1321,14 +1321,14 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.crsFunction.

crs(x)
 

Get the projected coordinate reference system of a Y or X Dimension, or of the Y/X dims of an AbstractRaster.

For Mapped lookup this may be nothing as there may be no projected coordinate reference system at all. See setcrs to set it manually.

-

source

+

source

# Rasters.disaggregateFunction.

disaggregate(method, object, scale; filename, progress, keys)
@@ -1345,7 +1345,7 @@ 

Reference - Exported functionsread on src before use where required.

-

source

+

source

# Rasters.disaggregate!Method.

disaggregate!(method, dst::AbstractRaster, src::AbstractRaster, filename, scale)
@@ -1356,7 +1356,7 @@ 

Reference - Exported functionsread on src before use where required.

-

source

+

source

# Rasters.extendFunction.

extend(xs...; [to])
@@ -1389,7 +1389,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.extractFunction.

-

source

+

source

# Rasters.mappedboundsFunction.

mappedbounds(x)
 

Get the bounds converted to the mappedcrs value.

Whithout ArchGDAL loaded, this is just the regular bounds.

-

source

+

source

# Rasters.mappedcrsFunction.

mappedcrs(x)
@@ -1445,14 +1445,14 @@ 

Reference - Exported functionsProjected lookup this is used to convert Selector values form the mappedcrs defined projection to the underlying projection, and to show plot axes in the mapped projection.

In Mapped lookup this is the coordinate reference system of the index values. See setmappedcrs to set it manually.

-

source

+

source

# Rasters.mappedindexFunction.

mappedindex(x)
 

Get the index value of a dimension converted to the mappedcrs value.

Whithout ArchGDAL loaded, this is just the regular dim value.

-

source

+

source

# Rasters.mask!Function.

mask!(x; with, missingval=missingval(A))
@@ -1495,7 +1495,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.maskMethod.

mask(A:AbstractRaster; with, missingval=missingval(A))
@@ -1544,7 +1544,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.missingmaskMethod.

missingmask(obj::Raster; kw...)
@@ -1573,13 +1573,13 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.missingvalFunction.

missingval(x)
 

Returns the value representing missing data in the dataset

-

source

+

source

# Rasters.mosaic!Method.

mosaic!(f, x, regions...; missingval, atol)
@@ -1611,7 +1611,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.mosaicMethod.

mosaic(f, regions...; missingval, atol)
@@ -1658,7 +1658,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.pointsMethod.

points(A::AbstractRaster; dims=(YDim, XDim), ignore_missing) => Array{Tuple}
@@ -1671,7 +1671,7 @@ 

Reference - Exported functionssource

+

source

# Rasters.rasterizeFunction.

rasterize([reducer], data; kw...)
@@ -1735,7 +1735,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.rasterize!Function.

rasterize!([reducer], dest, data; kw...)
@@ -1801,7 +1801,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.replace_missingMethod.

replace_missing(a::AbstractRaster, newmissingval)
@@ -1820,13 +1820,13 @@ 

Reference - Exported functions# output missing

-

source

+

source

# Rasters.reprojectMethod.

reproject(source::GeoFormat, target::GeoFormat, dim::Dimension, val)
 

reproject uses ArchGDAL.reproject, but implemented for a reprojecting a value array of values, a single dimension at a time.

-

source

+

source

# Rasters.reprojectMethod.

reproject(target::GeoFormat, x)
@@ -1838,19 +1838,19 @@ 

Reference - Exported functionssource

+

source

# Rasters.setcrsMethod.

setcrs(x, crs)
 

Set the crs of a Raster, RasterStack, Tuple of Dimension, or a Dimension. The crs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type

-

source

+

source

# Rasters.setmappedcrsMethod.

setmappedcrs(x, crs)
 

Set the mapped crs of a Raster, a RasterStack, a Tuple of Dimension, or a Dimension. The crs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type

-

source

+

source

# Rasters.sliceMethod.

slice(A::Union{AbstractRaster,AbstractRasterStack,AbstracRasterSeries}, dims) => RasterSeries
@@ -1859,7 +1859,7 @@ 

Reference - Exported functionssource

+

source

# Rasters.trimMethod.

trim(x; dims::Tuple, pad::Int)
@@ -1899,7 +1899,7 @@ 

Reference - Exported functions

WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

-

source

+

source

# Rasters.zonalMethod.

Abstract supertype for projected index lookups.

-

source

+

source

# Rasters.FileArrayType.

FileArray{X} <: DiskArrays.AbstractDiskArray
 

Filearray is a DiskArrays.jl AbstractDiskArray. Instead of holding an open object, it just holds a filename string that is opened lazily when it needs to be read.

-

source

+

source

# Rasters.FileStackType.

FileStack{X,K}
@@ -1956,7 +1956,7 @@ 

Reference - Internal functions

+

source

# Rasters.OpenStackType.

OpenStack{X,K}
@@ -1966,13 +1966,13 @@ 

Reference - Internal functions

+

source

# Rasters.RasterDiskArrayType.

RasterDiskArray <: DiskArrays.AbstractDiskArray
 

A basic DiskArrays.jl wrapper for objects that don't have one defined yet. When we open a FileArray it is replaced with a RasterDiskArray.

-

source

+

source

# Base.openMethod.

open(f, A::AbstractRaster; write=false)
@@ -1988,7 +1988,7 @@ 

Reference - Internal functionsend

By using a do block to open files we ensure they are always closed again after we finish working with them.

-

source

+

source

# Base.read!Method.

read!(src::Union{AbstractString,AbstractRaster}, dst::AbstractRaster)
@@ -1997,7 +1997,7 @@ 

Reference - Internal functionssource

+

source

# Base.readMethod.

read(A::AbstractRaster)
@@ -2005,13 +2005,13 @@ 

Reference - Internal functionsread(A::AbstractRasterSeries)

read will move a Rasters.jl object completely to memory.

-

source

+

source

# Base.skipmissingMethod.

skipmissing(itr::Raster)
 

Returns an iterable over the elements in a Raster object, skipping any values equal to either the missingval or missing.

-

source

+

source

# Base.writeMethod.

Base.write(filepath::AbstractString, s::AbstractRasterSeries; kw...)
@@ -2020,7 +2020,7 @@ 

Reference - Internal functionssource

+

source

# Base.writeMethod.

Base.write(filename::AbstractString, s::AbstractRasterStack; suffix, kw...)
@@ -2032,21 +2032,21 @@ 

Reference - Internal functionssource

+

source

# Base.writeMethod.

Base.write(filename::AbstractString, A::AbstractRaster; kw...)
 

Write an AbstractRaster to file, guessing the backend from the file extension.

Keyword arguments are passed to the write method for the backend.

-

source

+

source

# Base.writeMethod.

Base.write(filename::AbstractString, ::Type{GRDsource}, s::AbstractRaster; force=false)
 

Write a Raster to a .grd file with a .gri header file. The extension of filename will be ignored.

Returns filename.

-

source

+

source

diff --git a/dev/scripts/generated/basics/burramys_parvus_predictors.csv b/dev/scripts/generated/basics/burramys_parvus_predictors.csv index 7ee5ae0e4..1a9da9f64 100644 --- a/dev/scripts/generated/basics/burramys_parvus_predictors.csv +++ b/dev/scripts/generated/basics/burramys_parvus_predictors.csv @@ -2,25 +2,25 @@ geometry,bio1,bio3,bio7,bio12 "(148.391097, -36.30362)",6.1706977,41.119827,23.4645,1692.0 "(148.332969, -36.433349)",7.8357186,41.597527,23.50275,1500.0 "(148.396453, -36.381847)",6.881583,42.268078,23.133,1544.0 +"(147.1, -37.0)",9.408354,40.790546,23.0895,1292.0 "(148.235596, -36.524924)",8.001604,41.846535,22.85225,1368.0 "(147.096394, -36.935687)",9.408354,40.790546,23.0895,1292.0 "(148.328896, -36.431684)",7.8357186,41.597527,23.50275,1500.0 "(148.240881, -36.400058)",7.8357186,41.597527,23.50275,1500.0 "(148.347186, -36.504673)",8.420698,43.542496,23.142,1223.0 -"(147.1, -37.0)",9.408354,40.790546,23.0895,1292.0 -"(148.338776, -36.430986)",6.881583,42.268078,23.133,1544.0 "(151.250866, -33.831883)",17.316963,45.777245,18.43916,1320.0 +"(148.338776, -36.430986)",6.881583,42.268078,23.133,1544.0 "(151.25, -33.83)",17.316963,45.777245,18.43916,1320.0 -"(148.5, -36.6667)",12.083521,46.92699,24.3545,668.0 +"(148.3667, -36.2667)",6.1706977,41.119827,23.4645,1692.0 +"(148.4167, -36.35)",6.881583,42.268078,23.133,1544.0 "(148.25, -36.4167)",7.8357186,41.597527,23.50275,1500.0 +"(148.5, -36.6667)",12.083521,46.92699,24.3545,668.0 "(148.3167, -36.4167)",7.8357186,41.597527,23.50275,1500.0 "(148.3, -36.45)",7.8357186,41.597527,23.50275,1500.0 -"(148.4167, -36.35)",6.881583,42.268078,23.133,1544.0 +"(148.4833, -36.45)",6.881583,42.268078,23.133,1544.0 "(148.3, -36.45)",7.8357186,41.597527,23.50275,1500.0 -"(148.3667, -36.2667)",6.1706977,41.119827,23.4645,1692.0 "(148.4167, -36.35)",6.881583,42.268078,23.133,1544.0 "(148.3, -36.45)",7.8357186,41.597527,23.50275,1500.0 -"(148.4833, -36.45)",6.881583,42.268078,23.133,1544.0 "(148.3167, -36.4167)",7.8357186,41.597527,23.50275,1500.0 "(148.5, -36.6667)",12.083521,46.92699,24.3545,668.0 "(148.4167, -36.35)",6.881583,42.268078,23.133,1544.0 diff --git a/dev/scripts/generated/basics/data_sources/index.html b/dev/scripts/generated/basics/data_sources/index.html index cb60a278d..745626954 100644 --- a/dev/scripts/generated/basics/data_sources/index.html +++ b/dev/scripts/generated/basics/data_sources/index.html @@ -688,7 +688,7 @@

SMAP¤
  • kw: Passed to RasterSeries.
  • -

    source

    +

    source

    Writing file formats to disk¤

    @@ -703,7 +703,7 @@

    RasterDataSources.jl integrationA = Raster(WorldClim{Climate}, :tavg; month=June) Makie.plot(A)

    -

    +

    See the docs for Raster, RasterStack and RasterSeries, and the docs for RasterDataSources.getraster for syntax to specify various data sources.


    This page was generated using Literate.jl.

    diff --git a/dev/scripts/generated/basics/first_raster/index.html b/dev/scripts/generated/basics/first_raster/index.html index 56cc26488..1741f2370 100644 --- a/dev/scripts/generated/basics/first_raster/index.html +++ b/dev/scripts/generated/basics/first_raster/index.html @@ -639,13 +639,13 @@

    Quick start

    Ti Sampled{DateTime} DateTime("2001-01-01T00:00:00"):Month(1):DateTime("2002-01-01T00:00:00") ForwardOrdered Regular Points extent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime("2001-01-01T00:00:00"), DateTime("2002-01-01T00:00:00")))missingval: missingparent: [:, :, 1] - 25 26 27 28 29 30 - 25 0.688369 0.444839 0.865557 0.894021 0.310606 0.789457 - 26 0.927933 0.929943 0.499855 0.0696172 0.389926 0.447074 - 27 0.339432 0.0955447 0.241425 0.481324 0.532353 0.273658 - 28 0.138295 0.0858343 0.0938807 0.795397 0.103956 0.650885 - 29 0.138143 0.0778367 0.834551 0.260469 0.701014 0.225302 - 30 0.365167 0.682476 0.014285 0.193982 0.916624 0.894284 + 25 26 27 28 29 30 + 25 0.429008 0.93986 0.971662 0.430087 0.682266 0.535061 + 26 0.145596 0.898459 0.443608 0.443415 0.915046 0.662115 + 27 0.563926 0.831003 0.407218 0.406627 0.660327 0.0124977 + 28 0.201234 0.262332 0.399131 0.882657 0.743907 0.493154 + 29 0.202371 0.898827 0.317586 0.5708 0.307101 0.694126 + 30 0.404285 0.818468 0.917196 0.286121 0.268186 0.407958 [and 12 more slices...]

    @@ -669,13 +669,13 @@

    Select by index

    also

    or and interval of indices using the syntax =a:b or (a:b)

    @@ -723,13 +723,13 @@

    Select by value

    More options are available, like Near, Contains and Where.

    -

    +


    This page was generated using Literate.jl.

    diff --git a/dev/scripts/generated/basics/gbif_wflow/index.html b/dev/scripts/generated/basics/gbif_wflow/index.html index ae0fccb9c..e3a8b69b3 100644 --- a/dev/scripts/generated/basics/gbif_wflow/index.html +++ b/dev/scripts/generated/basics/gbif_wflow/index.html @@ -623,16 +623,16 @@

    Load¤Extract coordinatesGet layer / Band

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Get layer / Band - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Get layer / Band - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Get layer / Band - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Get layer / Band - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Get layer / Band - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Get layer / Band - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Get layer / Band - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Get layer / Band - +

    Then extract predictor variables and write to CSV.

    5×5 DataFrame
    -
    Rowgeometrybio1bio3bio7bio12
    Tuple…Float32Float32Float32Float32
    1(148.391, -36.3036)6.170741.119823.46451692.0
    2(148.333, -36.4333)7.8357241.597523.50281500.0
    3(148.396, -36.3818)6.8815842.268123.1331544.0
    4(148.236, -36.5249)8.001641.846522.85221368.0
    5(147.096, -36.9357)9.4083540.790523.08951292.0
    +
    Rowgeometrybio1bio3bio7bio12
    Tuple…Float32Float32Float32Float32
    1(148.391, -36.3036)6.170741.119823.46451692.0
    2(148.333, -36.4333)7.8357241.597523.50281500.0
    3(148.396, -36.3818)6.8815842.268123.1331544.0
    4(147.1, -37.0)9.4083540.790523.08951292.0
    5(148.236, -36.5249)8.001641.846522.85221368.0

    This page was generated using Literate.jl.

    diff --git a/dev/scripts/generated/basics/xiqywts.png b/dev/scripts/generated/basics/gugegdt.png similarity index 100% rename from dev/scripts/generated/basics/xiqywts.png rename to dev/scripts/generated/basics/gugegdt.png diff --git a/dev/scripts/generated/basics/rfgvokg.png b/dev/scripts/generated/basics/iwpjbqm.png similarity index 100% rename from dev/scripts/generated/basics/rfgvokg.png rename to dev/scripts/generated/basics/iwpjbqm.png diff --git a/dev/scripts/generated/basics/tbzjton.png b/dev/scripts/generated/basics/oshmsiw.png similarity index 100% rename from dev/scripts/generated/basics/tbzjton.png rename to dev/scripts/generated/basics/oshmsiw.png diff --git a/dev/scripts/generated/basics/scafuzn.png b/dev/scripts/generated/basics/ouzvbxm.png similarity index 100% rename from dev/scripts/generated/basics/scafuzn.png rename to dev/scripts/generated/basics/ouzvbxm.png diff --git a/dev/scripts/generated/basics/plot_makie/index.html b/dev/scripts/generated/basics/plot_makie/index.html index a445f15e7..610a1b98b 100644 --- a/dev/scripts/generated/basics/plot_makie/index.html +++ b/dev/scripts/generated/basics/plot_makie/index.html @@ -663,7 +663,7 @@

    2-D rasters in Makiesurface(fig[2, 2], A) # even a 3D plot works! fig

    -

    +

    3-D rasters in Makie¤

    -

    +

    You can pass any theming keywords in, which are interpreted by Makie appropriately.

    The plots seem a little squished here. We provide a Makie theme which makes text a little smaller and has some other space-efficient attributes:

    Makie.set_theme!(Rasters.theme_rasters())
     Rasters.rplot(stack)
     
    -

    +

    reset theme

    Makie.set_theme!()
     
    @@ -728,7 +728,7 @@

    Plotting with Observablecolorrange = Makie.automatic: The colormap for the heatmap. This can be set to a vector of (low, high) if plotting a 3D raster or RasterStack.
  • nan_color = :transparent: The color which NaN values should take. Default to transparent.
  • -

    source

    +

    source

    Using vanilla Makie¤

    diff --git a/dev/scripts/generated/basics/plotting/index.html b/dev/scripts/generated/basics/plotting/index.html index bcec85d04..b53b3d7db 100644 --- a/dev/scripts/generated/basics/plotting/index.html +++ b/dev/scripts/generated/basics/plotting/index.html @@ -684,55 +684,55 @@

    Plots, simple

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plots, simple - + - + Plots, simple - +

    For Makie, plot functions in a similar way. plot will only accept two-dimensional rasters. You can invoke contour, contourf, heatmap, surface or any Makie plotting function which supports surface-like data on a 2D raster.

    To obtain tiled plots for 3D rasters and RasterStacks, use the function Rasters.rplot([gridposition], raster; kw_args...). This is an unexported function, since we're not sure how the API will change going forward.

    @@ -13669,7 +13669,7 @@

    Makie, simpleA = Raster(WorldClim{BioClim}, 5) Makie.plot(A)

    -

    +

    Loading data¤

    @@ -13707,49 +13707,49 @@

    Loading data

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Loading data - + - + Loading data - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Loading data - + - + Loading data - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Loading data - + - + Loading data - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Loading data - + - + Loading data - - + + - + -

    +

    Now plot the ocean temperatures around the Americas in the first month of 2001. Notice we are using lat/lon coordinates and date/time instead of regular indices. The time dimension uses DateTime360Day, so we need to load CFTime.jl to index it with Near.

    using CFTime
     A[Ti(Near(DateTime360Day(2001, 01, 17))), Y(-60.0 .. 90.0), X(45.0 .. 190.0)] |> plot
    @@ -16711,53 +16711,53 @@ 

    Loading data

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Loading data - + - + Loading data - +

    Now get the mean over the timespan, then save it to disk, and plot it as a filled contour.

    Other plot functions and sliced objects that have only one X/Y/Z dimension fall back to generic DimensionalData.jl plotting, which will still correctly label plot axes.

    @@ -17326,349 +17326,349 @@

    Plot a contour plot

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +

    @@ -17684,52 +17684,52 @@

    write to disk

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Polygon masking, mosaic and plot¤

    @@ -17830,51 +17830,51 @@

    Plotting with Plots

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - +

    and sweden

    sp = plot(sweden)
    @@ -18517,45 +18517,45 @@ 

    Plotting with Plots

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - +

    and norway

    np = plot(norway)
    @@ -20131,45 +20131,45 @@ 

    Plotting with Plots

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - +

    The Norway shape includes a lot of islands. Lets crop them out using .. intervals:

    norway_region = climate[X(0..40), Y(55..73)]
    @@ -21779,49 +21779,49 @@ 

    Plotting with Plots

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - + - + Plotting with Plots - +

    And mask it with the border again:

    norway = mask_trim(norway_region, norway_border)
    @@ -24749,55 +24749,55 @@ 

    Plotting with Plots

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - +

    Now we can combine the countries into a single raster using mosaic. first will take the first value if/when there is an overlap.

    scandinavia = mosaic(first, denmark, norway, sweden)
    @@ -26943,47 +26943,47 @@ 

    Plotting with Plots

    - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + Plotting with Plots - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + Plotting with Plots - +

    And save to netcdf - a single multi-layered file, and tif, which will write a file for each stack layer.

    write("scandinavia.nc", scandinavia)
    diff --git a/dev/scripts/generated/basics/ukvbepd.png b/dev/scripts/generated/basics/vvmlrxo.png
    similarity index 100%
    rename from dev/scripts/generated/basics/ukvbepd.png
    rename to dev/scripts/generated/basics/vvmlrxo.png
    diff --git a/dev/scripts/generated/basics/hcewwtl.png b/dev/scripts/generated/basics/zovvcdw.png
    similarity index 100%
    rename from dev/scripts/generated/basics/hcewwtl.png
    rename to dev/scripts/generated/basics/zovvcdw.png
    diff --git a/dev/search/search_index.json b/dev/search/search_index.json
    index c45c6f009..07a45ba4a 100644
    --- a/dev/search/search_index.json
    +++ b/dev/search/search_index.json
    @@ -1 +1 @@
    -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#rastersjl","title":"Rasters.jl","text":"

    Rasters.jl defines common types and methods for reading, writing and manipulating rasterized spatial data.

    These currently include raster arrays like GeoTIFF and NetCDF, R grd files, multi-layered stacks, and multi-file series of arrays and stacks.

    Data-source abstraction

    Rasters provides a standardised interface that allows many source data types to be used with identical syntax.

    • Scripts and packages building on Rasters.jl can treat Raster,

    RasterStack, and RasterSeries as black boxes.

    • The data could hold GeoTiff or NetCDF files, Arrays in memory or CuArrays on the GPU - they will all behave in the same way.
    • RasterStack can be backed by a Netcdf or HDF5 file, or a NamedTuple of Raster holding .tif files, or all Raster in memory.
    • Users do not have to deal with the specifics of spatial file types.
    • Projected lookups with Cylindrical projections can by indexed using other Cylindrical projections

    by setting the mappedcrs keyword on construction. You don't need to know the underlying projection, the conversion is handled automatically. This means lat/lon EPSG(4326) can be used seamlessly if you need that.

    Packages extensions and Rasters 0.8 and onwards

    On Julia 1.9 we can put additional packages in extensions, so the code only loads when you load a specific package. Rasters.jl was always intended to work like this, and its finally possible. This reduced package using time from many seconds to well under a second.

    But, it means you have to manually load packages you need for each backend or additional functionality.

    For example, to use the GDAL backend, and download files, you now need to do:

    using Rasters, ArchGDAL, RasterDataSources\n

    where previously it was just using Rasters.

    Sources and packages needed:

    • :gdal: using ArchGDAL
    • :netcdf: using NCDatasets
    • :grd: built-in.
    • :smap: using HDF5
    • :grib: not yet finished.

    Other functionality in extensions:

    • Raster data downloads, like Worldclim{Climate}: using RasterDataSources
    • Makie plots: using Makie
    • Coordinate transformations for gdal rasters: using CoordinateTransformations
    Bugs, errors and making issues for Rasters.jl

    Raster data is complicated and there are many places for subtle or not-so-subtle bugs to creep in.

    We need bug reports to reduce how often they occur over time. But also, we need issues that are easy to reproduce or it isn't practically possible to fix them.

    Because there are so many raster file types and variations of them, most of the time we need the exact file that caused your problem to know how to fix it, and be sure that we have actually fixed it when we are done. So fixing a Rasters.jl bug nearly always involves downloading some file and running some code that breaks with it (if you can trigger the bug without a file, thats great! but its not always possible).

    To make an issue we can fix quickly (or at all) there are three key steps:

    1. Include the file in an accessible place on web without autentication or any other work on our part, so we can just get it and find your bug. You can put it on a file hosting platform (e.g. google drive, drop box, whatever you use) and share the url.
    2. Add a minimum working example to the issue template that first downloads the file, then runs the function that triggers the bug.
    3. Paste the complete stack trace of the error it produces, right to the bottom, into the issue template. Then we can be sure we reproduced the same problem.

    Good issues are really appreciated, but they do take just a little extra effort with Rasters.jl because of this need for files.

    "},{"location":"reference/","title":"API Reference","text":""},{"location":"reference/#index","title":"Index","text":"
    • Rasters.Rasters
    • Rasters.AbstractProjected
    • Rasters.AbstractRaster
    • Rasters.AbstractRasterSeries
    • Rasters.AbstractRasterStack
    • Rasters.Band
    • Rasters.FileArray
    • Rasters.FileStack
    • Rasters.Mapped
    • Rasters.OpenStack
    • Rasters.Projected
    • Rasters.Raster
    • Rasters.RasterDiskArray
    • Rasters.RasterSeries
    • Rasters.RasterStack
    • Rasters.aggregate
    • Rasters.aggregate!
    • Rasters.boolmask
    • Rasters.classify
    • Rasters.classify!
    • Rasters.combine
    • Rasters.convertlookup
    • Rasters.coverage
    • Rasters.coverage!
    • Rasters.crop
    • Rasters.crs
    • Rasters.disaggregate
    • Rasters.disaggregate!
    • Rasters.extend
    • Rasters.extract
    • Rasters.mappedbounds
    • Rasters.mappedcrs
    • Rasters.mappedindex
    • Rasters.mask
    • Rasters.mask!
    • Rasters.missingmask
    • Rasters.missingval
    • Rasters.mosaic
    • Rasters.mosaic!
    • Rasters.points
    • Rasters.rasterize
    • Rasters.rasterize!
    • Rasters.replace_missing
    • Rasters.reproject
    • Rasters.reproject
    • Rasters.rplot
    • Rasters.setcrs
    • Rasters.setmappedcrs
    • Rasters.slice
    • Rasters.smapseries
    • Rasters.trim
    • Rasters.zonal
    "},{"location":"reference/#reference-exported-functions","title":"Reference - Exported functions","text":"

    # Rasters.Rasters \u2014 Module.

    Rasters

    Rasters.jl defines common types and methods for reading, writing and manipulating rasterized spatial data.

    These currently include raster arrays like GeoTIFF and NetCDF, R grd files, multi-layered stacks, and multi-file series of arrays and stacks.

    :warning: Packages extensions and Rasters 0.8 and onwards

    On Julia 1.9 we can put additional packages in extensions, so the code only loads when you load a specific package. Rasters.jl was always intended to work like this, and its finally possible. This reduced package using time from many seconds to well under a second.

    But, it means you have to manually load packages you need for each backend or additional functionality.

    For example, to use the GDAL backend, and download files, you now need to do:

    using Rasters, ArchGDAL, RasterDataSources\n

    where previously it was just using Rasters.

    Sources and packages needed:

    • :gdal: using ArchGDAL
    • :netcdf: using NCDatasets
    • :grd: built-in.
    • :smap: using HDF5
    • :grib: not yet finished.

    Other functionality in extensions:

    • Raster data downloads, like Worldclim{Climate}: using RasterDataSources
    • Makie plots: using Makie
    • Coordinate transformations for gdal rasters: using CoordinateTransformations

    Quick start

    Install the package by typing:

    ]\nadd Rasters\n
    using Rasters\n

    Using Rasters to read GeoTiff or NetCDF files will output something similar to the following toy examples. This is possible because Rasters.jl extends DimensionalData.jl so that spatial data can be indexed using named dimensions like X, Y and Ti (time) and e.g. spatial coordinates.

    using Rasters, Dates\nlon, lat = X(25:1:30), Y(25:1:30)\nti = Ti(DateTime(2001):Month(1):DateTime(2002))\nras = Raster(rand(lon, lat, ti)) # this generates random numbers with the dimensions given\n
    6\u00d76\u00d713 Raster{Float64,3} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2002-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2002-01-01T00:00:00\")))\nmissingval: missing\nvalues: [:, :, 1]\n     25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n[and 12 more slices...]\n

    Getting the lookup array from dimensions

    lon = lookup(ras, X) # if X is longitude\nlat = lookup(ras, Y) # if Y is latitude\n
    Sampled{Int64} ForwardOrdered Regular Points\nwrapping: 25:1:30\n

    Select by index

    Selecting a time slice by index is done via

    ras[Ti(1)]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))\nmissingval: missing\nvalues:      25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n
    ras[Ti=1]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))\nmissingval: missing\nvalues:      25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n

    or and interval of indices using the syntax =a:b or (a:b)

    ras[Ti(1:10)]\n
    6\u00d76\u00d710 Raster{Float64,3} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-10-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2001-10-01T00:00:00\")))\nmissingval: missing\nvalues: [:, :, 1]\n     25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n[and 9 more slices...]\n

    Select by value

    ras[Ti=At(DateTime(2001))]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))\nmissingval: missing\nvalues:      25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n

    More options are available, like Near, Contains and Where. For more details go here.

    Dimensions can also be used in most Base and Statistics methods like mean and reduce where dims arguments are required. Much of the behaviour is covered in the DimensionalData docs.

    See the docs for more details and examples for Rasters.jl.

    Data-source abstraction

    Rasters provides a standardised interface that allows many source data types to be used with identical syntax.

    • Scripts and packages building on Rasters.jl can treat Raster, RasterStack, and RasterSeries as black boxes.

      • The data could hold GeoTiff or NetCDF files, Arrays in memory or CuArrays on the GPU - they will all behave in the same way.
      • RasterStack can be backed by a Netcdf or HDF5 file, or a NamedTuple of Raster holding .tif files, or all Raster in memory.
      • Users do not have to deal with the specifics of spatial file types.
      • Projected lookups with Cylindrical projections can by indexed using other Cylindrical projections by setting the mappedcrs keyword on construction. You don't need to know the underlying projection, the conversion is handled automatically. This means lat/lon EPSG(4326) can be used seamlessly if you need that.

    Bugs, errors and making issues for Rasters.jl

    Raster data is complicated and there are many places for subtle or not-so-subtle bugs to creep in.

    We need bug reports to reduce how often they occur over time. But also, we need issues that are easy to reproduce or it isn't practically possible to fix them.

    Because there are so many raster file types and variations of them, most of the time we need the exact file that caused your problem to know how to fix it, and be sure that we have actually fixed it when we are done. So fixing a Rasters.jl bug nearly always involves downloading some file and running some code that breaks with it (if you can trigger the bug without a file, thats great! but its not always possible).

    To make an issue we can fix quickly (or at all) there are three key steps:

    1. Include the file in an accessible place on web without autentication or any other work on our part, so we can just get it and find your bug. You can put it on a file hosting platform (e.g. google drive, drop box, whatever you use) and share the url.
    2. Add a minimum working example to the issue template that first downloads the file, then runs the function that triggers the bug.
    3. Paste the complete stack trace of the error it produces, right to the bottom, into the issue template. Then we can be sure we reproduced the same problem.

    Good issues are really appreciated, but they do take just a little extra effort with Rasters.jl because of this need for files.

    source

    # Rasters.AbstractRaster \u2014 Type.

    AbstractRaster <: DimensionalData.AbstractDimArray\n

    Abstract supertype for objects that wrap an array (or location of an array) and metadata about its contents. It may be memory or hold a FileArray, which holds the filename, and is only opened when required.

    AbstractRasters inherit from AbstractDimArray from DimensionalData.jl. They can be indexed as regular Julia arrays or with DimensionalData.jl Dimensions. They will plot as a heatmap in Plots.jl with correct coordinates and labels, even after slicing with getindex or view. getindex on a AbstractRaster will always return a memory-backed Raster.

    source

    # Rasters.AbstractRasterSeries \u2014 Type.

    AbstractRasterSeries <: DimensionalData.AbstractDimensionalArray\n

    Abstract supertype for high-level DimensionalArray that hold RasterStacks, Rasters, or the paths they can be loaded from. RasterSeries are indexed with dimensions as with a AbstractRaster. This is useful when you have multiple files containing rasters or stacks of rasters spread over dimensions like time and elevation.

    As much as possible, implementations should facilitate loading entire directories and detecting the dimensions from metadata.

    This allows syntax like below for a series of stacks of arrays:

    RasterSeries[Time(Near(DateTime(2001, 1))][:temp][Y(Between(70, 150)), X(Between(-20,20))] |> plot`\n

    RasterSeries is the concrete implementation.

    source

    # Rasters.AbstractRasterStack \u2014 Type.

    AbstractRasterStack\n

    Abstract supertype for objects that hold multiple AbstractRasters that share spatial dimensions.

    They are NamedTuple-like structures that may either contain NamedTuple of AbstractRasters, string paths that will load AbstractRasters, or a single path that points to a file containing multiple layers, like NetCDF or HDF5. Use and syntax is similar or identical for all cases.

    AbstractRasterStack can hold layers that share some or all of their dimensions. They cannot have the same dimension with different length or spatial extent as another layer.

    getindex on an AbstractRasterStack generally returns a memory backed standard Raster. raster[:somelayer] |> plot plots the layers array, while raster[:somelayer, X(1:100), Band(2)] |> plot will plot the subset without loading the whole array.

    getindex on an AbstractRasterStack with a key returns another stack with getindex applied to all the arrays in the stack.

    source

    # Rasters.Band \u2014 Type.

    Band <: Dimension\n\nBand(val=:)\n

    Band Dimension for multi-band rasters.

    Example:

    banddim = Band(10:10:100)\n# Or\nval = A[Band(1)]\n# Or\nmean(A; dims=Band)\n

    source

    # Rasters.Mapped \u2014 Type.

    Mapped <: AbstractProjected\n\nMapped(order, span, sampling, crs, mappedcrs)\nMapped(; order=AutoOrder(), span=AutoSpan(), sampling=AutoSampling(), crs=nothing, mappedcrs)\n

    An AbstractSampled LookupArray, where the dimension index has been mapped to another projection, usually lat/lon or EPSG(4326). Mapped matches the dimension format commonly used in netcdf files.

    Fields and behaviours are identical to Sampled with the addition of crs and mappedcrs fields.

    The mapped dimension index will be used as for Sampled, but to save in another format the underlying crs may be used to convert it.

    source

    # Rasters.Projected \u2014 Type.

    Projected <: AbstractProjected\n\nProjected(order, span, sampling, crs, mappedcrs)\nProjected(; order=AutoOrder(), span=AutoSpan(), sampling=AutoSampling(), crs, mappedcrs=nothing)\n

    An AbstractSampled LookupArray with projections attached.

    Fields and behaviours are identical to Sampled with the addition of crs and mappedcrs fields.

    If both crs and mappedcrs fields contain CRS data (in a GeoFormat wrapper from GeoFormatTypes.jl) the selector inputs and plot axes will be converted from and to the specified mappedcrs projection automatically. A common use case would be to pass mappedcrs=EPSG(4326) to the constructor when loading eg. a GDALarray:

    GDALarray(filename; mappedcrs=EPSG(4326))\n

    The underlying crs will be detected by GDAL.

    If mappedcrs is not supplied (ie. mappedcrs=nothing), the base index will be shown on plots, and selectors will need to use whatever format it is in.

    source

    # Rasters.Raster \u2014 Type.

    Raster <: AbsractRaster\n\nRaster(filepath::AbstractString, dims; kw...)\nRaster(A::AbstractArray{T,N}, dims; kw...)\nRaster(A::AbstractRaster; kw...)\n

    A generic AbstractRaster for spatial/raster array data. It may hold memory-backed arrays or FileArray, that simply holds the String path to an unopened file. This will only be opened lazily when it is indexed with getindex or when read(A) is called. Broadcasting, taking a view, reversing and most other methods do not load data from disk: they are applied later, lazily.

    Keywords

    • dims: Tuple of Dimensions for the array.
    • lazy: A Bool specifying if to load the stack lazily from disk. false by default.
    • name: Symbol name for the array, which will also retreive named layers if Raster is used on a multi-layered file like a NetCDF.
    • missingval: value reprsenting missing data, normally detected form the file. Set manually when you know the value is not specified or is incorrect. This will not change any values in the raster, it simply assigns which value is treated as missing. To replace all of the missing values in the raster, use replace_missing.
    • metadata: ArrayMetadata object for the array, or NoMetadata().
    • crs: the coordinate reference system of the objects XDim/YDim dimensions. Only set this if you know the detected crs is incrorrect, or it is not present in the file. The crs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type.
    • mappedcrs: the mapped coordinate reference system of the objects XDim/YDim dimensions. for Mapped lookups these are the actual values of the index. For Projected lookups this can be used to index in eg. EPSG(4326) lat/lon values, having it converted automatically. Only set this if the detected mappedcrs in incorrect, or the file does not have a mappedcrs, e.g. a tiff. The mappedcrs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type.
    • dropband: drop single band dimensions. true by default.

    Internal Keywords

    In some cases it is possible to set these keywords as well.

    • data: can replace the data in an AbstractRaster
    • refdims: Tuple of position Dimensions the array was sliced from, defaulting to ().

    source

    # Rasters.RasterSeries \u2014 Type.

    RasterSeries <: AbstractRasterSeries\n\nRasterSeries(rasters::AbstractArray{<:AbstractRaster}, dims; [refdims])\nRasterSeries(stacks::AbstractArray{<:AbstractRasterStack}, dims; [refdims]) \n\nRasterSeries(paths::AbstractArray{<:AbstractString}, dims; child, duplicate_first, kw...)\nRasterSeries(path:::AbstractString, dims; ext, separator, child, duplicate_first, kw...)\n

    Concrete implementation of AbstractRasterSeries.

    A RasterSeries is an array of Rasters or RasterStacks, along some dimension(s).

    Existing Raster RasterStack can be wrapped in a RasterSeries, or new files can be loaded from an array of String or from a single String.

    A single String can refer to a whole directory, or the name of a series of files in a directory, sharing a common stem. The differnce between the filenames can be used as the lookup for the series.

    For example, with some tifs at these paths :

    \"series_dir/myseries_2001-01-01T00:00:00.tif\"\n\"series_dir/myseries_2002-01-01T00:00:00.tif\"\n

    We can load a RasterSeries with a DateTime lookup:

    julia> ser = RasterSeries(\"series_dir/myseries.tif\", Ti(DateTime))\n2-element RasterSeries{Raster,1} with dimensions: \n  Ti Sampled{DateTime} DateTime[DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2002-01-01T00:00:00\")] ForwardOrdered Irregular Points\n

    The DateTime suffix is parsed from the filenames. Using Ti(Int) would try to parse integers intead.

    Just using the directory will also work, unless there are other files mixed in it:

    julia> ser = RasterSeries(\"series_dir\", Ti(DateTime))\n2-element RasterSeries{Raster,1} with dimensions: \n  Ti Sampled{DateTime} DateTime[DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2002-01-01T00:00:00\")] ForwardOrdered Irregular Points\n

    Arguments

    • dims: series dimension/s.

    Keywords

    When loading a series from a Vector of String paths or a single String path:

    • child: constructor of child objects for use when filenames are passed in, can be Raster or RasterStack. Defaults to Raster.
    • duplicate_first::Bool: wether to duplicate the dimensions and metadata of the first file with all other files. This can save load time with a large series where dimensions are identical. false by default.
    • lazy: load files lazily, false by default.
    • kw: keywords passed to the child constructor Raster or RasterStack.

    When loading a series from a single String path:

    • ext: filename extension such as \".tiff\" or \".nc\". Use to specify a subset of files if only a directory path is passed in.
    • separator: separator used to split lookup elements from the rest of a filename. '_' by default.

    Others:

    • refdims: existing reference dimension/s, normally not required.

    source

    # Rasters.RasterStack \u2014 Type.

    RasterStack <: AbstrackRasterStack\n\nRasterStack(data...; name, kw...)\nRasterStack(data::Union{Vector,Tuple}; name, kw...)\nRasterStack(data::NamedTuple; kw...))\nRasterStack(s::AbstractRasterStack; kw...)\nRasterStack(s::AbstractRaster; layersfrom=Band, kw...)\nRasterStack(filename::AbstractString; kw...)\n

    Load a file path or a NamedTuple of paths as a RasterStack, or convert arguments, a Vector or NamedTuple of Rasters to RasterStack.

    Arguments

    • data: A NamedTuple of Rasters, or a Vector, Tuple or splatted arguments of Raster. The latter options must pass a name keyword argument.
    • filename: A file (such as netcdf or tif) to be loaded as a stack, or a directory path containing multiple files.

    Keywords

    • name: Used as stack layer names when a Tuple, Vector or splat of Raster is passed in. Has no effect when NameTuple is used - the NamedTuple keys are the layer names.
    • metadata: A Dict or DimensionalData.Metadata object.
    • refdims: Tuple of Dimension that the stack was sliced from.
    • layersfrom: Dimension to source stack layers from if the file is not already multi-layered. nothing is default, so that a single RasterStack(raster) is a single layered stack. RasterStack(raster; layersfrom=Band) will use the bands as layers.
    • lazy: A Bool specifying whether to load the stack lazily from disk. false by default.
    • dropband: drop single band dimensions when creating stacks from filenames. true by default.
    files = (temp=\"temp.tif\", pressure=\"pressure.tif\", relhum=\"relhum.tif\")\nstack = RasterStack(files; mappedcrs=EPSG(4326))\nstack[:relhum][Lat(Contains(-37), Lon(Contains(144))\n

    source

    # DimensionalData.modify \u2014 Method.

    modify(f, series::AbstractRasterSeries)\n

    Apply function f to the data of the child object. If the child is an AbstractRasterStack the function will be passed on to its child AbstractRasters.

    f must return an idenically sized array.

    This method triggers a complete rebuild of all objects, and disk based objects will be transferred to memory.

    An example of the usefulnesss of this is for swapping out array backend for an entire series to CuArray from CUDA.jl to copy data to a GPU.

    source

    # Rasters.aggregate \u2014 Function.

    aggregate(method, object, scale; filename, progress, skipmissing)\n

    Aggregate a Raster, or all arrays in a RasterStack or RasterSeries, by scale using method.

    Arguments

    • method: a function such as mean or sum that can combine the value of multiple cells to generate the aggregated cell, or a Locus like Start() or Center() that specifies where to sample from in the interval.
    • object: Object to aggregate, like AbstractRasterSeries, AbstractStack, AbstractRaster or Dimension.
    • scale: the aggregation factor, which can be an integer, a tuple of integers for each dimension, or any Dimension, Selector or Int combination you can usually use in getindex. Using a Selector will determine the scale by the distance from the start of the index.

    When the aggregation scale of is larger than the array axis, the length of the axis is used.

    Keywords

    • skipmissingval: if true, any missingval will be skipped during aggregation, so that only areas of all missing values will be aggregated to missingval. If false, any aggegrated area containing a missingval will be assigned missingval.
    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.
    • progress: show a progress bar, true by default, false to hide.

    Example

    using Rasters, RasterDataSources, Statistics, Plots\nusing Rasters: Center\nst = read(RasterStack(WorldClim{Climate}; month=1))\nag = aggregate(Center(), st, (Y(20), X(20)); skipmissingval=true, progress=false)\nplot(ag)\nsavefig(\"docs/build/aggregate_example.png\"); nothing\n# output\n

    Note: currently it is faster to aggregate over memory-backed arrays. Use read on src before use where required.

    source

    # Rasters.aggregate! \u2014 Method.

    aggregate!(method, dst::AbstractRaster, src::AbstractRaster, scale; skipmissingval=false)\n

    Aggregate array src to array dst by scale, using method.

    Arguments

    • method: a function such as mean or sum that can combine the value of multiple cells to generate the aggregated cell, or a Locus like Start() or Center() that species where to sample from in the interval.
    • scale: the aggregation factor, which can be an integer, a tuple of integers for each dimension, or any Dimension, Selector or Int combination you can usually use in getindex. Using a Selector will determine the scale by the distance from the start of the index in the src array.

    When the aggregation scale of is larger than the array axis, the length of the axis is used.

    Keywords

    • progress: show a progress bar.
    • skipmissingval: if true, any missingval will be skipped during aggregation, so that only areas of all missing values will be aggregated to missingval. If false, any aggegrated area containing a missingval will be assigned missingval.

    Note: currently it is much faster to aggregate over memory-backed arrays. Use read on src before use where required.

    source

    # Rasters.boolmask \u2014 Function.

    boolmask(obj::Raster; [missingval])\nboolmask(obj; [to, res, size])\n

    Create a mask array of Bool values, from another Raster. An AbstractRasterStack or AbstractRasterSeries are also accepted, but a mask is taken of the first layer or object not all of them.

    The array returned from calling boolmask on a AbstractRaster is a Raster with the same dimensions as the original array and a missingval of false.

    Arguments

    • obj: a Raster, a GeoInterface.jl geometry, or a vector or table of geometries.

    Raster / RasterStack Keywords

    • missingval: The missing value of the source array, with default missingval(raster).

    Keywords

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.
    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.
    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • crs: a crs which will be attached to the resulting raster when to not passed or is an Extent. Otherwise the crs from to is used.
    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    • threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur.

    • progress: show a progress bar, true by default, false to hide.

    And specifically for shape=:polygon:

    • boundary: include pixels where the :center is inside the polygon, where the line :touches the pixel, or that are completely :inside inside the polygon. The default is :center.

    For tabular data, feature collections and other iterables

    • collapse: if true, collapse all geometry masks into a single mask. Otherwise return a Raster with an additional geometry dimension, so that each slice along this axis is the mask of the geometry opbject of each row of the table, feature in the feature collection, or just each geometry in the iterable.

    Example

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates\nwc = Raster(WorldClim{Climate}, :prec; month=1)\nboolmask(wc) |> plot\n\nsavefig(\"docs/build/boolmask_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.classify \u2014 Function.

    classify(x, pairs; lower=(>=), upper=(<), others=nothing)\nclassify(x, pairs...; lower, upper, others)\n

    Create a new array with values in x classified by the values in pairs.

    pairs can hold tuples fo values (2, 3), a Fix2 function e.g. <=(1), a Tuple of Fix2 e.g. (>=(4), <(7)), or an IntervalSets.jl interval, e.g. 3..9 or OpenInterval(10, 12). pairs can also be a n * 3 matrix where each row is lower bounds, upper bounds, replacement.

    If tuples or a Matrix are used, the lower and upper keywords define how the lower and upper boundaries are chosen.

    If others is set other values not covered in pairs will be set to that values.

    Arguments

    • x: a Raster or RasterStack
    • pairs: each pair contains a value and a replacement, a tuple of lower and upper range and a replacement, or a Tuple of Fix2 like (>(x), <(y).

    Keywords

    • lower: Which comparison (< or <=) to use for lower values, if Fix2 are not used.
    • upper: Which comparison (> or >=) to use for upper values, if Fix2 are not used.
    • others: A value to assign to all values not included in pairs. Passing nothing (the default) will leave them unchanged.

    Example

    using Rasters, RasterDataSources, ArchGDAL, Plots\nA = Raster(WorldClim{Climate}, :tavg; month=1)\nclasses = <=(15) => 10,\n          15..25 => 20,\n          25..35 => 30,\n          >(35) => 40\nclassified = classify(A, classes; others=0, missingval=0)\nplot(classified; c=:magma)\n\nsavefig(\"docs/build/classify_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.classify! \u2014 Method.

    classify!(x, pairs...; lower, upper, others)\nclassify!(x, pairs; lower, upper, others)\n

    Classify the values of x in-place, by the values in pairs.

    If Fix2 is not used, the lower and upper keywords

    If others is set other values not covered in pairs will be set to that values.

    Arguments

    • x: a Raster or RasterStack
    • pairs: each pair contains a value and a replacement, a tuple of lower and upper range and a replacement, or a Tuple of Fix2 like (>(x), <(y).

    Keywords

    • lower: Which comparison (< or <=) to use for lower values, if Fix2 are not used.
    • upper: Which comparison (> or >=) to use for upper values, if Fix2 are not used.
    • others: A value to assign to all values not included in pairs. Passing nothing (the default) will leave them unchanged.

    Example

    classify! to disk, with key steps:

    • copying a tempory file so we don't write over the RasterDataSources.jl version.
    • use open with write=true to open the file with disk-write permissions.
    • use Float32 like 10.0f0 for all our replacement values and other, because the file is stored as Float32. Attempting to write some other type will fail.
    using Rasters, RasterDataSources, ArchGDAL, Plots\n# Download and copy the file\nfilename = getraster(WorldClim{Climate}, :tavg; month=6)\ntempfile = tempname() * \".tif\"\ncp(filename, tempfile)\n# Define classes\nclasses = (5, 15) => 10,\n          (15, 25) => 20,\n          (25, 35) => 30,\n          >=(35) => 40\n# Open the file with write permission\nopen(Raster(tempfile); write=true) do A\n    classify!(A, classes; others=0)\nend\n# Open it again to plot the changes\nplot(Raster(tempfile); c=:magma)\n\nsavefig(\"docs/build/classify_bang_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.combine \u2014 Method.

    combine(A::Union{AbstractRaster,AbstractRasterStack,AbstracRasterSeries}, [dims]) => Raster\n

    Combine a RasterSeries along some dimension/s, creating a new Raster or RasterStack, depending on the contents of the series.

    If dims are passed, only the specified dimensions will be combined with a RasterSeries returned, unless dims is all the dims in the series.

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    <a id='Rasters.convertlookup-Tuple{Type{<:LookupArray}, AbstractDimArray}' href='#Rasters.convertlookup-Tuple{Type{<:LookupArray}, AbstractDimArray}'># Rasters.convertlookup \u2014 Method.

    convertlookup(dstlookup::Type{<:LookupArray}, x)\n

    Convert the dimension lookup between Projected and Mapped. Other dimension lookups pass through unchanged.

    This is used to e.g. save a netcdf file to GeoTiff.

    source

    # Rasters.coverage! \u2014 Method.

    coverage!(A, geom; [mode, scale])\n

    Calculate the area of a raster covered by GeoInterface.jl compatible geomtry geom, as a fraction.

    Each pixel is assigned a grid of points (by default 10 x 10) that are each checked to be inside the geometry. The sum divided by the number of points to give coverage.

    In pracice, most pixel coverage is not calculated this way - shortcuts that produce the same result are taken wherever possible.

    If geom is an AbstractVector or table, the mode keyword will determine how coverage is combined.

    Keywords

    • mode: method for combining multiple geometries - union or sum.

      • union (the default) gives the areas covered by all geometries. Usefull in spatial coverage where overlapping regions should not be counted twice. The returned raster will contain Float64 values between 0.0 and 1.0.
      • sum gives the summed total of the areas covered by all geometries, as in taking the sum of running coverage separately on all geometries. The returned values are positive Float64.

      For a single geometry, the mode keyword has no effect - the result is the same. * scale: Integer scale of pixel subdivision. The default of 10 means each pixel has 10 x 10 or 100 points that contribute to coverage. Using 100 means 10,000 points contribute. Performance will decline as scale increases. Memory use will grow by scale^2 when mode=:union. * threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur. * progress: show a progress bar, true by default, false to hide. * vebose: whether to print messages about potential problems. true by default.

    source

    # Rasters.coverage \u2014 Method.

    coverage(mode, geom; [to, res, size, scale, verbose, progress])\ncoverage(geom; [to, mode, res, size, scale, verbose, progress])\n

    Calculate the area of a raster covered by GeoInterface.jl compatible geomtry geom, as a fraction.

    Each pixel is assigned a grid of points (by default 10 x 10) that are each checked to be inside the geometry. The sum divided by the number of points to give coverage.

    In pracice, most pixel coverage is not calculated this way - shortcuts that produce the same result are taken wherever possible.

    If geom is an AbstractVector or table, the mode keyword will determine how coverage is combined.

    Keywords

    • mode: method for combining multiple geometries - union or sum.

      • union (the default) gives the areas covered by all geometries. Usefull in spatial coverage where overlapping regions should not be counted twice. The returned raster will contain Float64 values between 0.0 and 1.0.
      • sum gives the summed total of the areas covered by all geometries, as in taking the sum of running coverage separately on all geometries. The returned values are positive Float64.

      For a single geometry, the mode keyword has no effect - the result is the same. * scale: Integer scale of pixel subdivision. The default of 10 means each pixel has 10 x 10 or 100 points that contribute to coverage. Using 100 means 10,000 points contribute. Performance will decline as scale increases. Memory use will grow by scale^2 when mode=:union. * threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur. * progress: show a progress bar, true by default, false to hide. * vebose: whether to print messages about potential problems. true by default.

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.

    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.

    source

    # Rasters.crop \u2014 Function.

    crop(x; to)\ncrop(xs...; to)\n

    Crop one or multiple AbstractRaster or AbstractRasterStack x to match the size of the object to, or smallest of any dimensions that are shared.

    crop is lazy, using a view into the object rather than alocating new memory.

    Keywords

    • to: the object to crop to. If no to keyword is passed, the smallest shared area of all xs is used.
    • touches: true or false. Whether to use Touches wraper on the object extent. When lines need to be included in e.g. zonal statistics, true should be used.

    As crop is lazy, filename and suffix keywords are not used.

    Example

    Crop to another raster:

    using Rasters, RasterDataSources, Plots\nevenness = Raster(EarthEnv{HabitatHeterogeneity}, :evenness)\nrnge = Raster(EarthEnv{HabitatHeterogeneity}, :range)\n\n# Roughly cut out New Zealand from the evenness raster\nnz_bounds = X(165 .. 180), Y(-50 .. -32)\nnz_evenness = evenness[nz_bounds...]\n\n# Crop range to match evenness\nnz_range = crop(rnge; to=nz_evenness)\nplot(nz_range)\n\nsavefig(\"docs/build/nz_crop_example.png\")\nnothing\n\n# output\n

    Crop to a polygon:

    using Rasters, RasterDataSources, Plots, Dates, Shapefile, Downloads\n\n# Download a borders shapefile\nshapefile_url = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp\"\nshapefile_name = \"boundary.shp\"\nisfile(shapefile_name) || Downloads.download(shapefile_url, shapefile_name)\nshp = Shapefile.Handle(shapefile_name).shapes[6]\n\nevenness = Raster(EarthEnv{HabitatHeterogeneity}, :evenness)\nargentina_evenness = crop(evenness; to=shp)\nplot(argentina_evenness)\n\nsavefig(\"docs/build/argentina_crop_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.crs \u2014 Function.

    crs(x)\n

    Get the projected coordinate reference system of a Y or X Dimension, or of the Y/X dims of an AbstractRaster.

    For Mapped lookup this may be nothing as there may be no projected coordinate reference system at all. See setcrs to set it manually.

    source

    # Rasters.disaggregate \u2014 Function.

    disaggregate(method, object, scale; filename, progress, keys)\n

    Disaggregate array, or all arrays in a stack or series, by some scale.

    Arguments

    • method: a function such as mean or sum that can combine the value of multiple cells to generate the aggregated cell, or a Locus like Start() or Center() that species where to sample from in the interval.
    • object: Object to aggregate, like AbstractRasterSeries, AbstractStack, AbstractRaster or a Dimension.
    • scale: the aggregation factor, which can be an integer, a tuple of integers for each dimension, or any Dimension, Selector or Int combination you can usually use in getindex. Using a Selector will determine the scale by the distance from the start of the index.

    Keywords

    • progress: show a progress bar.

    Note: currently it is faster to aggregate over memory-backed arrays. Use read on src before use where required.

    source

    # Rasters.disaggregate! \u2014 Method.

    disaggregate!(method, dst::AbstractRaster, src::AbstractRaster, filename, scale)\n

    Disaggregate array src to array dst by some scale, using method.

    • method: a function such as mean or sum that can combine the value of multiple cells to generate the aggregated cell, or a Locus like Start() or Center() that species where to sample from in the interval.
    • scale: the aggregation factor, which can be an integer, a tuple of integers for each dimension, or any Dimension, Selector or Int combination you can usually use in getindex. Using a Selector will determine the scale by the distance from the start of the index in the src array.

    Note: currently it is faster to aggregate over memory-backed arrays. Use read on src before use where required.

    source

    # Rasters.extend \u2014 Function.

    extend(xs...; [to])\nextend(xs; [to])\nextend(x::Union{AbstractRaster,AbstractRasterStack}; to, kw...)\n

    Extend one or multiple AbstractRaster to match the area covered by all xs, or by the keyword argument to.

    Keywords

    • to: the Raster or dims to extend to. If no to keyword is passed, the largest shared area of all xs is used.
    • touches: true or false. Whether to use Touches wraper on the object extent. When lines need to be included in e.g. zonal statistics, true shoudle be used.
    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.
    using Rasters, RasterDataSources, Plots\nevenness = Raster(EarthEnv{HabitatHeterogeneity}, :evenness)\nrnge = Raster(EarthEnv{HabitatHeterogeneity}, :range)\n\n# Roughly cut out South America\nsa_bounds = X(-88 .. -32), Y(-57 .. 13)\nsa_evenness = evenness[sa_bounds...]\n\n# Extend range to match the whole-world raster\nsa_range = extend(sa_evenness; to=rnge)\nplot(sa_range)\n\nsavefig(\"docs/build/extend_example.png\")\nnothing\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.extract \u2014 Function.

    extract(x, geoms; atol)\n

    Extracts the value of Raster or RasterStack at given points, returning an iterable of NamedTuple with properties for :geometry and raster or stack layer values.

    Note that if objects have more dimensions than the length of the point tuples, sliced arrays or stacks will be returned instead of single values.

    Arguments

    • x: a Raster or RasterStack to extract values from.
    • geoms: GeoInterface.jl compatible geometries, or tables or iterables of geometries.

    Keywords

    • atol: a tolorerance for floating point lookup values for when the LookupArray contains Points. atol is ignored for Intervals.

    Example

    Here we extact points matching the occurrence of the Mountain Pygmy Possum, Burramis parvus. This could be used to fit a species distribution model.

    using Rasters, RasterDataSources, ArchGDAL, GBIF2, CSV\n\n# Get a stack of BioClim layers, and replace missing values with `missing`\nst = RasterStack(WorldClim{BioClim}, (1, 3, 5, 7, 12)) |> replace_missing\n\n# Download some occurrence data\nobs = GBIF2.occurrence_search(\"Burramys parvus\"; limit=5, year=\"2009\")\n\n# Convert observations to points\npnts = collect((o.decimalLongitude, o.decimalLatitude) for o in obs if !ismissing(o.decimalLongitude))\n\n# use `extract` to get values for all layers at each observation point.\n# We `collect` to get a `Vector` from the lazy iterator.\ncollect(extract(st, pnts))\n\n# output\n5-element Vector{NamedTuple{(:geometry, :bio1, :bio3, :bio5, :bio7, :bio12)}}:\n (geometry = (0.21, 40.07), bio1 = 17.077084f0, bio3 = 41.20417f0, bio5 = 30.1f0, bio7 = 24.775f0, bio12 = 446.0f0)\n (geometry = (0.03, 39.97), bio1 = 17.076923f0, bio3 = 39.7983f0, bio5 = 29.638462f0, bio7 = 24.153847f0, bio12 = 441.0f0)\n (geometry = (0.03, 39.97), bio1 = 17.076923f0, bio3 = 39.7983f0, bio5 = 29.638462f0, bio7 = 24.153847f0, bio12 = 441.0f0)\n (geometry = (0.52, 40.37), bio1 = missing, bio3 = missing, bio5 = missing, bio7 = missing, bio12 = missing)\n (geometry = (0.32, 40.24), bio1 = 16.321388f0, bio3 = 41.659454f0, bio5 = 30.029825f0, bio7 = 25.544561f0, bio12 = 480.0f0)\n

    source

    # Rasters.mappedbounds \u2014 Function.

    mappedbounds(x)\n

    Get the bounds converted to the mappedcrs value.

    Whithout ArchGDAL loaded, this is just the regular bounds.

    source

    # Rasters.mappedcrs \u2014 Function.

    mappedcrs(x)\n

    Get the mapped coordinate reference system for the Y/X dims of an array.

    In Projected lookup this is used to convert Selector values form the mappedcrs defined projection to the underlying projection, and to show plot axes in the mapped projection.

    In Mapped lookup this is the coordinate reference system of the index values. See setmappedcrs to set it manually.

    source

    # Rasters.mappedindex \u2014 Function.

    mappedindex(x)\n

    Get the index value of a dimension converted to the mappedcrs value.

    Whithout ArchGDAL loaded, this is just the regular dim value.

    source

    # Rasters.mask! \u2014 Function.

    mask!(x; with, missingval=missingval(A))\n

    Mask A by the missing values of with, or by all values outside with if it is a polygon.

    If with is a polygon, creates a new array where points falling outside the polygon have been replaced by missingval(A).

    Return a new array with values of A masked by the missing values of with, or by a polygon.

    Arguments

    • x: a Raster or RasterStack.

    Keywords

    • with: another AbstractRaster, a AbstractVector of Tuple points, or any GeoInterface.jl AbstractGeometry. The coordinate reference system of the point must match crs(A).
    • missingval: the missing value to write to A in masked areas, by default missingval(A).

    Example

    Mask an unmasked AWAP layer with a masked WorldClim layer, by first resampling the mask to match the size and projection.

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates\n\n# Load and plot the file\nawap = read(RasterStack(AWAP, (:tmin, :tmax); date=DateTime(2001, 1, 1)))\na = plot(awap; clims=(10, 45), c=:imola)\n\n# Create a mask my resampling a worldclim file\nwc = Raster(WorldClim{Climate}, :prec; month=1)\nwc_mask = resample(wc; to=awap)\n\n# Mask\nmask!(awap; with=wc_mask)\nb = plot(awap; clims=(10, 45))\n\nsavefig(a, \"docs/build/mask_bang_example_before.png\");\nsavefig(b, \"docs/build/mask_bang_example_after.png\"); nothing\n\n# output\n

    Before mask!:

    After mask!:

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.mask \u2014 Method.

    mask(A:AbstractRaster; with, missingval=missingval(A))\nmask(x; with)\n

    Return a new array with values of A masked by the missing values of with, or by the shape of with, if with is a geometric object.

    Arguments

    • x: a Raster or RasterStack

    Keywords

    • with: an AbstractRaster, or any GeoInterface.jl compatible objects or table. The coordinate reference system of the point must match crs(A).
    • missingval: the missing value to use in the returned file.
    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.

    Geometry keywords

    These can be used when with is a GeoInterface.jl compatible object:

    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    Example

    Mask an unmasked AWAP layer with a masked WorldClim layer, by first resampling the mask.

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates\n\n# Load and plot the file\nawap = read(Raster(AWAP, :tmax; date=DateTime(2001, 1, 1)))\na = plot(awap; clims=(10, 45))\n\n# Create a mask my resampling a worldclim file\nwc = Raster(WorldClim{Climate}, :prec; month=1)\nwc_mask = resample(wc; to=awap)\n\n# Mask\nawap_masked = mask(awap; with=wc_mask)\nb = plot(awap_masked; clims=(10, 45))\n\nsavefig(a, \"docs/build/mask_example_before.png\");\nsavefig(b, \"docs/build/mask_example_after.png\"); nothing\n# output\n

    Before mask:

    After mask:

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.missingmask \u2014 Method.

    missingmask(obj::Raster; kw...)\nmissingmask(obj; [to, res, size, collapse])\n

    Create a mask array of missing and true values, from another Raster. AbstractRasterStack or AbstractRasterSeries are also accepted, but a mask is taken of the first layer or object not all of them.

    For AbstractRaster the default missingval is missingval(A), but others can be chosen manually.

    The array returned from calling missingmask on a AbstractRaster is a Raster with the same size and fields as the original array.

    Keywords

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.
    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.
    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • crs: a crs which will be attached to the resulting raster when to not passed or is an Extent. Otherwise the crs from to is used.
    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    Example

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates\nwc = Raster(WorldClim{Climate}, :prec; month=1)\nmissingmask(wc) |> plot\n\nsavefig(\"docs/build/missingmask_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.missingval \u2014 Function.

    missingval(x)\n

    Returns the value representing missing data in the dataset

    source

    # Rasters.mosaic! \u2014 Method.

    mosaic!(f, x, regions...; missingval, atol)\nmosaic!(f, x, regions::Tuple; missingval, atol)\n

    Combine regions in x using the function f.

    Arguments

    • f a function (e.g. mean, sum, first or last) that is applied to values where regions overlap.
    • x: A Raster or RasterStack. May be a an opened disk-based Raster, the result will be written to disk. With the current algorithm, the read speed is slow.
    • regions: source objects to be joined. These should be memory-backed (use read first), or may experience poor performance. If all objects have the same extent, mosaic is simply a merge.

    Keywords

    • missingval: Fills empty areas, and defualts to the `missingval/ of the first layer.
    • atol: Absolute tolerance for comparison between index values. This is often required due to minor differences in range values due to floating point error. It is not applied to non-float dimensions. A tuple of tolerances may be passed, matching the dimension order.

    Example

    Cut out Australia and Africa stacks, then combined them into a single stack.

    using Rasters, RasterDataSources, ArchGDAL, Statistics, Plots\nst = read(RasterStack(WorldClim{Climate}; month=1))\naus = st[X=100.0 .. 160.0, Y=-50.0 .. -10.0]\nafrica = st[X=-20.0 .. 60.0, Y=-40.0 .. 35.0]\nmosaic!(first, st, aus, africa)\nplot(st)\nsavefig(\"docs/build/mosaic_bang_example.png\")\nnothing\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.mosaic \u2014 Method.

    mosaic(f, regions...; missingval, atol)\nmosaic(f, regions; missingval, atol)\n

    Combine regions into a single raster.

    Arguments

    • f: A reducing function (mean, sum, first, last etc.) for values where regions overlap.
    • regions: Iterable or splatted Raster or RasterStack.

    Keywords

    • missingval: Fills empty areas, and defualts to the missingval of the first region.
    • atol: Absolute tolerance for comparison between index values. This is often required due to minor differences in range values due to floating point error. It is not applied to non-float dimensions. A tuple of tolerances may be passed, matching the dimension order.
    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.

    If your mosaic has has apparent line errors, increase the atol value.

    Example

    Here we cut out Australia and Africa from a stack, and join them with mosaic.

    using Rasters, RasterDataSources, ArchGDAL, Plots\nst = RasterStack(WorldClim{Climate}; month=1);\n\nafrica = st[X(-20.0 .. 60.0), Y(-40.0 .. 35.0)]\na = plot(africa)\n\naus = st[X(100.0 .. 160.0), Y(-50.0 .. -10.0)]\nb = plot(aus)\n\n# Combine with mosaic\nmos = mosaic(first, aus, africa)\nc = plot(mos)\n\nsavefig(a, \"docs/build/mosaic_example_africa.png\")\nsavefig(b, \"docs/build/mosaic_example_aus.png\")\nsavefig(c, \"docs/build/mosaic_example_combined.png\")\nnothing\n# output\n

    Individual continents

    Mosaic of continents

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.points \u2014 Method.

    points(A::AbstractRaster; dims=(YDim, XDim), ignore_missing) => Array{Tuple}\n

    Returns a generator of the points in A for dimensions in dims, where points are a tuple of the values in each specified dimension index.

    Keywords

    • dims the dimensions to return points from. The first slice of other layers will be used.
    • ignore_missing: wether to ignore missing values in the array when considering points. If true, all points in the dimensions will be returned, if false only the points that are not === missingval(A) will be returned.

    The order of dims determines the order of the points.

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.rasterize \u2014 Function.

    rasterize([reducer], data; kw...)\n

    Rasterize a GeoInterface.jl compatable geometry or feature, or a Tables.jl table with a :geometry column of GeoInterface.jl objects, or X, Y points columns.

    Arguments

    • reducer: a reducing function to reduce the fill value for all geometries that cover or touch a pixel down to a single value. The default is last. Any that takes an iterable and returns a single value will work, including custom functions. However, there are optimisations for built-in methods including sum, first, last, minimum, maximum, extrema and Statistics.mean. These may be an order of magnitude or more faster than count is a special-cased as it does not need a fill value.
    • data: a GeoInterface.jl AbstractGeometry, or a nested Vector of AbstractGeometry, or a Tables.jl compatible object containing a :geometry column or points and values columns.

    Keywords

    These are detected automatically from data where possible.

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.
    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.
    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • crs: a crs which will be attached to the resulting raster when to not passed or is an Extent. Otherwise the crs from to is used.
    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    • fill: the value or values to fill a polygon with. A Symbol or tuple of Symbol will be used to retrieve properties from features or column values from table rows. An array or other iterable will be used for each geometry, in order. fill can also be a function of the current value, e.g. x -> x + 1.

    • op: A reducing function that accepts two values and returns one, like min to minimum. For common methods this will be assigned for you, or is not required. But you can use it instead of a reducer as it will usually be faster.
    • shape: force data to be treated as :polygon, :line or :point, where possible Points can't be treated as lines or polygons, and lines may not work as polygons, but an attempt will be made.
    • geometrycolumn: Symbol to manually select the column the geometries are in when data is a Tables.jl compatible table, or a tuple of Symbol for columns of point coordinates.
    • progress: show a progress bar, true by default, false to hide..
    • verbose: print information and warnings whne there are problems with the rasterisation. true by default.
    • threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur.

    • filename: a filename to write to directly, useful for large files.

    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.

    Example

    Rasterize a shapefile for China and plot, with a border.

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates, Shapefile, Downloads\nusing Rasters.LookupArrays\n\n# Download a borders shapefile\nshapefile_url = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp\"\nshapefile_name = \"country_borders.shp\"\nisfile(shapefile_name) || Downloads.download(shapefile_url, shapefile_name)\n\n# Load the shapes for china\nchina_border = Shapefile.Handle(shapefile_name).shapes[10]\n\n# Rasterize the border polygon\nchina = rasterize(last, china_border; res=0.1, missingval=0, fill=1, boundary=:touches, progress=false)\n\n# And plot\np = plot(china; color=:spring, legend=false)\nplot!(p, china_border; fillalpha=0, linewidth=0.6)\n\nsavefig(\"docs/build/china_rasterized.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.rasterize! \u2014 Function.

    rasterize!([reducer], dest, data; kw...)\n

    Rasterize the geometries in data into the Raster or RasterStack dest, using the values specified by fill.

    Arguments

    • dest: a Raster or RasterStack to rasterize into.
    • reducer: a reducing function to reduce the fill value for all geometries that cover or touch a pixel down to a single value. The default is last. Any that takes an iterable and returns a single value will work, including custom functions. However, there are optimisations for built-in methods including sum, first, last, minimum, maximum, extrema and Statistics.mean. These may be an order of magnitude or more faster than count is a special-cased as it does not need a fill value.
    • data: a GeoInterface.jl AbstractGeometry, or a nested Vector of AbstractGeometry, or a Tables.jl compatible object containing a :geometry column or points and values columns.

    Keywords

    These are detected automatically from A and data where possible.

    • fill: the value or values to fill a polygon with. A Symbol or tuple of Symbol will be used to retrieve properties from features or column values from table rows. An array or other iterable will be used for each geometry, in order. fill can also be a function of the current value, e.g. x -> x + 1.
    • op: A reducing function that accepts two values and returns one, like min to minimum. For common methods this will be assigned for you, or is not required. But you can use it instead of a reducer as it will usually be faster.
    • shape: force data to be treated as :polygon, :line or :point, where possible Points can't be treated as lines or polygons, and lines may not work as polygons, but an attempt will be made.
    • geometrycolumn: Symbol to manually select the column the geometries are in when data is a Tables.jl compatible table, or a tuple of Symbol for columns of point coordinates.
    • progress: show a progress bar, true by default, false to hide..
    • verbose: print information and warnings whne there are problems with the rasterisation. true by default.
    • threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur.

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.

    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.
    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • crs: a crs which will be attached to the resulting raster when to not passed or is an Extent. Otherwise the crs from to is used.
    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    Example

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates, Shapefile, GeoInterface, Downloads\nusing Rasters.LookupArrays\n\n# Download a borders shapefile\nshapefile_url = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp\"\nshapefile_name = \"country_borders.shp\"\nisfile(shapefile_name) || Downloads.download(shapefile_url, shapefile_name)\n\n# Load the shapes for indonesia\nindonesia_border = Shapefile.Handle(shapefile_name).shapes[1]\n\n# Make an empty EPSG 4326 projected Raster of the area of Indonesia\ndimz = X(Projected(90.0:0.1:145; sampling=Intervals(), crs=EPSG(4326))),\n       Y(Projected(-15.0:0.1:10.9; sampling=Intervals(), crs=EPSG(4326)))\n\nA = zeros(UInt32, dimz; missingval=UInt32(0))\n\n# Rasterize each indonesian island with a different number. The islands are\n# rings of a multi-polygon, so we use `GI.getring` to get them all separately.\nislands = collect(GeoInterface.getring(indonesia_border))\nrasterize!(last, A, islands; fill=1:length(islands), progress=false)\n\n# And plot\np = plot(Rasters.trim(A); color=:spring)\nplot!(p, indonesia_border; fillalpha=0, linewidth=0.7)\n\nsavefig(\"docs/build/indonesia_rasterized.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.replace_missing \u2014 Method.

    replace_missing(a::AbstractRaster, newmissingval)\nreplace_missing(a::AbstractRasterStack, newmissingval)\n

    Replace missing values in the array or stack with a new missing value, also updating the missingval field/s.

    Keywords

    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.

    Example

    using Rasters, RasterDataSources, ArchGDAL\nA = Raster(WorldClim{Climate}, :prec; month=1) |> replace_missing\nmissingval(A)\n# output\nmissing\n

    source

    # Rasters.reproject \u2014 Method.

    reproject(source::GeoFormat, target::GeoFormat, dim::Dimension, val)\n

    reproject uses ArchGDAL.reproject, but implemented for a reprojecting a value array of values, a single dimension at a time.

    source

    # Rasters.reproject \u2014 Method.

    reproject(target::GeoFormat, x)\n

    Reproject the dimensions of x to a different crs.

    Arguments

    • target: any crs in a GeoFormatTypes.jl wrapper, e.g. EPSG, WellKnownText, ProjString.
    • x: a Dimension, Tuple of Dimension, Raster or RasterStack.

    Dimensions without an AbstractProjected lookup (such as a Ti dimension) are silently returned without modification.

    source

    # Rasters.setcrs \u2014 Method.

    setcrs(x, crs)\n

    Set the crs of a Raster, RasterStack, Tuple of Dimension, or a Dimension. The crs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type

    source

    # Rasters.setmappedcrs \u2014 Method.

    setmappedcrs(x, crs)\n

    Set the mapped crs of a Raster, a RasterStack, a Tuple of Dimension, or a Dimension. The crs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type

    source

    # Rasters.slice \u2014 Method.

    slice(A::Union{AbstractRaster,AbstractRasterStack,AbstracRasterSeries}, dims) => RasterSeries\n

    Slice views along some dimension/s to obtain a RasterSeries of the slices.

    For a Raster or RasterStack this will return a RasterSeries of Raster or RasterStack that are slices along the specified dimensions.

    For a RasterSeries, the output is another series where the child objects are sliced and the series dimensions index is now of the child dimensions combined. slice on a RasterSeries with no dimensions will slice along the dimensions shared by both the series and child object.

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.trim \u2014 Method.

    trim(x; dims::Tuple, pad::Int)\n

    Trim missingval(x) from x for axes in dims, returning a view of x.

    Arguments

    • x: A Raster or RasterStack. For stacks, all layers must having missing values for a pixel for it to be trimmed.

    Keywords

    • dims: By default dims=(XDim, YDim), so that trimming keeps the area of X and Y that contains non-missing values along all other dimensions.
    • pad: The trimmed size will be padded by pad on all sides, although padding will not be added beyond the original extent of the array.

    As trim is lazy, filename and suffix keywords are not used.

    Example

    Create trimmed layers of Australian habitat heterogeneity.

    using Rasters, RasterDataSources, Plots\nlayers = (:evenness, :range, :contrast, :correlation)\nst = RasterStack(EarthEnv{HabitatHeterogeneity}, layers)\n\n# Roughly cut out australia\nausbounds = X(100 .. 160), Y(-50 .. -10)\naus = st[ausbounds...]\na = plot(aus)\n\n# Trim missing values and plot\nb = plot(trim(aus))\n\nsavefig(a, \"docs/build/trim_example_before.png\");\nsavefig(b, \"docs/build/trim_example_after.png\"); nothing\n\n# output\n

    Before trim:

    After trim:

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.zonal \u2014 Method.

    zonal(f, x::Union{Raster,RasterStack}; of, kw...)\n

    Calculate zonal statistics for the the zone of a Raster or RasterStack covered by the of object/s.

    Arguments

    • f: any function that reduces an iterable to a single value, such as sum or Statistics.mean
    • x: A Raster or RasterStack
    • of: A Raster, RasterStack, dim tuple, extent, GeoInterface.jl compatible geometry, Tables.jl compatible table of a :geometry column, or an AbstractVector of any of these objects..

    Keywords

    These can be used when of is a GeoInterface.jl compatible object:

    • shape: Force data to be treated as :polygon, :line or :point, where possible.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the line :touches the pixel, or that are completely :inside inside the polygon. The default is :center.
    • progress: show a progress bar, true by default, false to hide..

    Example

    ``jldoctest using Rasters, RasterDataSources, ArchGDAL, Shapefile, DataFrames, Downloads, Statistics, Dates

    Download a borders shapefile

    neurl = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10mcultural/ne10madmin0countries\" shpurl, dbfurl = neurl * \".shp\", neurl * \".dbf\" shpname, dbfname = \"countryborders.shp\", \"countryborders.dbf\" isfile(shpname) || Downloads.download(shpurl, shpname) isfile(dbfurl) || Downloads.download(dbfurl, dbfname)

    Download and read a raster stack from WorldClim

    st = RasterStack(WorldClim{Climate}; month=Jan, lazy=false)

    Load the shapes for world countries

    countries = Shapefile.Table(shp_name) |> DataFrame

    Calculate the january mean of all climate variables for all countries

    january_stats = zonal(mean, st; of=countries, boundary=:touches, progress=false) |> DataFrame

    Add the country name column (natural earth has some string errors it seems)

    insertcols!(january_stats, 1, :country => first.(split.(countries.ADMIN, r\"[^A-Za-z ]\")))

    output

    258\u00d78 DataFrame Row \u2502 country tmin tmax tavg prec \u22ef \u2502 SubStrin\u2026 Float32 Float32 Float32 Float64 \u22ef \u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 1 \u2502 Indonesia 21.5447 29.1864 25.3656 271.063 \u22ef 2 \u2502 Malaysia 21.3087 28.4291 24.8688 273.381 3 \u2502 Chile 7.24534 17.9263 12.5858 78.1287 4 \u2502 Bolivia 17.2065 27.7454 22.4759 192.542 5 \u2502 Peru 15.0273 25.5504 20.2888 180.007 \u22ef 6 \u2502 Argentina 13.6751 27.6715 20.6732 67.1837 7 \u2502 Dhekelia Sovereign Base Area 5.87126 15.8991 10.8868 76.25 8 \u2502 Cyprus 5.65921 14.6665 10.1622 97.4474 \u22ee \u2502 \u22ee \u22ee \u22ee \u22ee \u22ee \u22f1 252 \u2502 Spratly Islands 25.0 29.2 27.05 70.5 \u22ef 253 \u2502 Clipperton Island 21.5 33.2727 27.4 6.0 254 \u2502 Macao S 11.6694 17.7288 14.6988 28.0 255 \u2502 Ashmore and Cartier Islands NaN NaN NaN NaN 256 \u2502 Bajo Nuevo Bank NaN NaN NaN NaN \u22ef 257 \u2502 Serranilla Bank NaN NaN NaN NaN 258 \u2502 Scarborough Reef NaN NaN NaN NaN 3 columns and 243 rows omitted ```

    source

    "},{"location":"reference/#reference-internal-functions","title":"Reference - Internal functions","text":"

    # Rasters.AbstractProjected \u2014 Type.

    AbstractProjected <: AbstractSampled\n

    Abstract supertype for projected index lookups.

    source

    # Rasters.FileArray \u2014 Type.

    FileArray{X} <: DiskArrays.AbstractDiskArray\n

    Filearray is a DiskArrays.jl AbstractDiskArray. Instead of holding an open object, it just holds a filename string that is opened lazily when it needs to be read.

    source

    # Rasters.FileStack \u2014 Type.

    FileStack{X,K}\n\nFileStack{X,K}(filename, types, sizes, eachchunk, haschunks, write)\n

    A wrapper object that holds file pointer and size/chunking metadata for a multi-layered stack stored in a single file, typically netcdf or hdf5.

    X is a backend type like NCDsource, and K is a tuple of Symbol keys.

    source

    # Rasters.OpenStack \u2014 Type.

    OpenStack{X,K}\n\nOpenStack{X,K}(dataset)\n

    A wrapper for any stack-like opened dataset that can be indexed with Symbol keys to retrieve AbstractArray layers.

    OpenStack is usually hidden from users, wrapped in a regular RasterStack passed as the function argument in open(stack) when the stack is contained in a single file.

    X is a backend type like NCDsource, and K is a tuple of Symbol keys.

    source

    # Rasters.RasterDiskArray \u2014 Type.

    RasterDiskArray <: DiskArrays.AbstractDiskArray\n

    A basic DiskArrays.jl wrapper for objects that don't have one defined yet. When we open a FileArray it is replaced with a RasterDiskArray.

    source

    # Base.open \u2014 Method.

    open(f, A::AbstractRaster; write=false)\n

    open is used to open any lazy=true AbstractRaster and do multiple operations on it in a safe way. The write keyword opens the file in write lookup so that it can be altered on disk using e.g. a broadcast.

    f is a method that accepts a single argument - an Raster object which is just an AbstractRaster that holds an open disk-based object. Often it will be a do block:

    lazy=false (in-memory) rasters will ignore open and pass themselves to f.

    # A is an `Raster` wrapping the opened disk-based object.\nopen(Raster(filepath); write=true) do A\n    mask!(A; with=maskfile)\n    A[I...] .*= 2\n    # ...  other things you need to do with the open file\nend\n

    By using a do block to open files we ensure they are always closed again after we finish working with them.

    source

    # Base.read! \u2014 Method.

    read!(src::Union{AbstractString,AbstractRaster}, dst::AbstractRaster)\nread!(src::Union{AbstractString,AbstractRasterStack}, dst::AbstractRasterStack)\nread!(scr::AbstractRasterSeries, dst::AbstractRasterSeries)\n

    read! will copy the data from src to the object dst.

    src can be an object or a file-path String.

    source

    # Base.read \u2014 Method.

    read(A::AbstractRaster)\nread(A::AbstractRasterStack)\nread(A::AbstractRasterSeries)\n

    read will move a Rasters.jl object completely to memory.

    source

    # Base.skipmissing \u2014 Method.

    skipmissing(itr::Raster)\n

    Returns an iterable over the elements in a Raster object, skipping any values equal to either the missingval or missing.

    source

    # Base.write \u2014 Method.

    Base.write(filepath::AbstractString, s::AbstractRasterSeries; kw...)\n

    Write any AbstractRasterSeries to file, guessing the backend from the file extension.

    The lookup values of the series will be appended to the filepath (before the extension), separated by underscores.

    Keywords

    See other docs for write. All keywords are passed through to Raster and RasterStack methods.

    source

    # Base.write \u2014 Method.

    Base.write(filename::AbstractString, s::AbstractRasterStack; suffix, kw...)\n

    Write any AbstractRasterStack to file, guessing the backend from the file extension.

    Keywords

    • suffix: suffix to append to file names. By default the layer key is used.

    Other keyword arguments are passed to the write method for the backend.

    If the source can't be saved as a stack-like object, individual array layers will be saved.

    source

    # Base.write \u2014 Method.

    Base.write(filename::AbstractString, A::AbstractRaster; kw...)\n

    Write an AbstractRaster to file, guessing the backend from the file extension.

    Keyword arguments are passed to the write method for the backend.

    source

    # Base.write \u2014 Method.

    Base.write(filename::AbstractString, ::Type{GRDsource}, s::AbstractRaster; force=false)\n

    Write a Raster to a .grd file with a .gri header file. The extension of filename will be ignored.

    Returns filename.

    source

    "},{"location":"scripts/generated/basics/array_operations/","title":"Arrays operations","text":"

    Most base methods work as for regular julia Arrays, such as reverse and rotations like rotl90. Base, statistics and linear algebra methods like mean that take a dims argument can also use the dimension name.

    "},{"location":"scripts/generated/basics/array_operations/#mean-over-the-time-dimension","title":"Mean over the time dimension:","text":"
    using Rasters, Statistics, RasterDataSources\n\nA = Raster(WorldClim{BioClim}, 5)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n           89.8333  89.6667  89.5     \u2026  -89.6667  -89.8333  -90.0\n -180.0    -3.4f38  -3.4f38  -3.4f38     -15.399   -13.805   -14.046\n -179.833  -3.4f38  -3.4f38  -3.4f38     -15.9605  -14.607   -14.5545\n -179.667  -3.4f38  -3.4f38  -3.4f38     -15.971   -14.612   -14.5685\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -3.4f38  -3.4f38  -3.4f38     -18.2955  -16.7583  -16.72\n  179.667  -3.4f38  -3.4f38  -3.4f38     -18.2847  -16.7513  -16.72\n  179.833  -3.4f38  -3.4f38  -3.4f38     -17.1478  -15.4243  -15.701\n

    Then we do the meand over the X dimension

    mean(A, dims=X) # Ti if time were available would also be possible\n
    1\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} -180.0:360.0:-180.0 ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 180.0), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n          89.8333   89.6667   89.5   89.3333  \u2026  -89.6667  -89.8333  -90.0\n -180.0  -Inf      -Inf      -Inf   -Inf         -23.0768  -22.9373  -22.0094\n

    broadcast works lazily from disk when lazy=true, and is only applied when data is directly indexed. Adding a dot to any function will use broadcast over a Raster just like an Array.

    "},{"location":"scripts/generated/basics/array_operations/#broadcasting","title":"Broadcasting","text":"

    For a disk-based array A, this will only be applied when indexing occurs or when we read the array.

    A .*= 2\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n            89.8333   89.6667   89.5  \u2026  -89.6667  -89.8333  -90.0\n -180.0    -Inf      -Inf      -Inf      -30.798   -27.61    -28.092\n -179.833  -Inf      -Inf      -Inf      -31.921   -29.214   -29.109\n -179.667  -Inf      -Inf      -Inf      -31.942   -29.224   -29.137\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -Inf      -Inf      -Inf      -36.591   -33.5165  -33.44\n  179.667  -Inf      -Inf      -Inf      -36.5695  -33.5025  -33.44\n  179.833  -Inf      -Inf      -Inf      -34.2955  -30.8485  -31.402\n

    To broadcast directly to disk, we need to open the file in write mode:

    open(Raster(filename); write=true) do O\n   O .*= 2\nend\n

    To broadcast over a RasterStack use map, which applies a function to the raster layers of the stack.

    newstack = map(stack) do raster\n   raster .* 2\nend\n

    "},{"location":"scripts/generated/basics/array_operations/#modifying-object-properties","title":"Modifying object properties","text":"

    rebuild can be used to modify the fields of an object, generating a new object (but possibly holding the same arrays or files).

    If you know that a file had an incorrectly specified missing value, you can do:

    "},{"location":"scripts/generated/basics/array_operations/#rebuild","title":"rebuild","text":"
    A = Raster(WorldClim{BioClim}, 5)\nrebuild(A; missingval=-9999)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -9999crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n           89.8333  89.6667  89.5     \u2026  -89.6667  -89.8333  -90.0\n -180.0    -3.4f38  -3.4f38  -3.4f38     -15.399   -13.805   -14.046\n -179.833  -3.4f38  -3.4f38  -3.4f38     -15.9605  -14.607   -14.5545\n -179.667  -3.4f38  -3.4f38  -3.4f38     -15.971   -14.612   -14.5685\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -3.4f38  -3.4f38  -3.4f38     -18.2955  -16.7583  -16.72\n  179.667  -3.4f38  -3.4f38  -3.4f38     -18.2847  -16.7513  -16.72\n  179.833  -3.4f38  -3.4f38  -3.4f38     -17.1478  -15.4243  -15.701\n

    (replace_missing will actualy replace the current values).

    Or if you need to change the name of the layer:

    Then use rebuild as

    B = rebuild(A; name=:temperature)\nB.name\n
    :temperature\n

    "},{"location":"scripts/generated/basics/array_operations/#replace_missing","title":"replace_missing","text":"
    replace_missing(A, missingval=-9999)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -9999.0f0crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n              89.8333     89.6667     89.5  \u2026  -89.6667  -89.8333  -90.0\n -180.0    -9999.0     -9999.0     -9999.0     -15.399   -13.805   -14.046\n -179.833  -9999.0     -9999.0     -9999.0     -15.9605  -14.607   -14.5545\n -179.667  -9999.0     -9999.0     -9999.0     -15.971   -14.612   -14.5685\n    \u22ee                                       \u22f1              \u22ee       \n  179.5    -9999.0     -9999.0     -9999.0     -18.2955  -16.7583  -16.72\n  179.667  -9999.0     -9999.0     -9999.0     -18.2847  -16.7513  -16.72\n  179.833  -9999.0     -9999.0     -9999.0     -17.1478  -15.4243  -15.701\n
    "},{"location":"scripts/generated/basics/array_operations/#set","title":"set","text":"

    set can be used to modify the nested properties of an objects dimensions, that are more difficult to change with rebuild. set works on the principle that dimension properties can only be in one specific field, so we generally don't have to specify which one it is. set will also try to update anything affected by a change you make.

    This will set the X axis to specify points, instead of intervals:

    using Rasters: Points\nset(A, X => Points)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Points crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.83333333333331), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n           89.8333  89.6667  89.5     \u2026  -89.6667  -89.8333  -90.0\n -180.0    -3.4f38  -3.4f38  -3.4f38     -15.399   -13.805   -14.046\n -179.833  -3.4f38  -3.4f38  -3.4f38     -15.9605  -14.607   -14.5545\n -179.667  -3.4f38  -3.4f38  -3.4f38     -15.971   -14.612   -14.5685\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -3.4f38  -3.4f38  -3.4f38     -18.2955  -16.7583  -16.72\n  179.667  -3.4f38  -3.4f38  -3.4f38     -18.2847  -16.7513  -16.72\n  179.833  -3.4f38  -3.4f38  -3.4f38     -17.1478  -15.4243  -15.701\n

    We can also reassign dimensions, here X becomes Z:

    set(A, X => Z)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  Z Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(Z = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n           89.8333  89.6667  89.5     \u2026  -89.6667  -89.8333  -90.0\n -180.0    -3.4f38  -3.4f38  -3.4f38     -15.399   -13.805   -14.046\n -179.833  -3.4f38  -3.4f38  -3.4f38     -15.9605  -14.607   -14.5545\n -179.667  -3.4f38  -3.4f38  -3.4f38     -15.971   -14.612   -14.5685\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -3.4f38  -3.4f38  -3.4f38     -18.2955  -16.7583  -16.72\n  179.667  -3.4f38  -3.4f38  -3.4f38     -18.2847  -16.7513  -16.72\n  179.833  -3.4f38  -3.4f38  -3.4f38     -17.1478  -15.4243  -15.701\n

    setcrs(A, crs) and setmappedcrs(A, crs) will set the crs value/s of an object to any GeoFormat from GeoFormatTypes.jl.

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/data_sources/","title":"Data Sources","text":""},{"location":"scripts/generated/basics/data_sources/#data-sources","title":"Data sources","text":"

    Rasters.jl uses a number of backends to load raster data. Raster, RasterStack and RasterSeries will detect which backend to use for you, automatically.

    "},{"location":"scripts/generated/basics/data_sources/#grd","title":"GRD","text":"

    R GRD files can be loaded natively, using Julias MMap - which means they are very fast, but are not compressed. They are always 3 dimensional, and have Y, X and Band dimensions.

    "},{"location":"scripts/generated/basics/data_sources/#netcdf","title":"NetCDF","text":"

    NetCDF .nc files are loaded using NCDatasets.jl. Layers from files can be loaded as Raster(\"filename.nc\"; key=:layername). Without key the first layer is used. RasterStack(\"filename.nc\") will use all netcdf variables in the file that are not dimensions as layers.

    NetCDF layers can have arbitrary dimensions. Known, common dimension names are converted to X, Y Z, and Ti, otherwise Dim{:layername} is used. Layers in the same file may also have different dimensions.

    NetCDF files still have issues loading directly from disk for some operations. Using read(ncstack) may help.

    "},{"location":"scripts/generated/basics/data_sources/#gdal","title":"GDAL","text":"

    All files GDAL can access, such as .tiff and .asc files, can be loaded, using ArchGDAL.jl. These are generally best loaded as Raster(\"filename.tif\"), but can be loaded as RasterStack(\"filename.tif\"; layersfrom=Band), taking layers from the Band dimension, which is also the default.

    "},{"location":"scripts/generated/basics/data_sources/#smap","title":"SMAP","text":"

    The Soil Moisture Active-Passive dataset provides global layers of soil moisture, temperature and other related data, in a custom HDF5 format. Layers are always 2 dimensional, with Y and X dimensions.

    These can be loaded as multi-layered RasterStack(\"filename.h5\"). Individual layers can be loaded as Raster(\"filename.h5\"; key=:layerkey), without key the first layer is used.

    # Rasters.smapseries \u2014 Function.

    smapseries(filenames::AbstractString; kw...)\nsmapseries(filenames::Vector{<:AbstractString}, dims=nothing; kw...)\n

    RasterSeries loader for SMAP files and whole folders of files, organised along the time dimension. Returns a RasterSeries.

    Arguments

    • filenames: A String path to a directory of SMAP files, or a vector of String paths to specific files.
    • dims: Tuple containing Ti dimension for the series. Automatically generated form filenames unless passed in.

    Keywords

    • kw: Passed to RasterSeries.

    source

    "},{"location":"scripts/generated/basics/data_sources/#writing-file-formats-to-disk","title":"Writing file formats to disk","text":"

    Files can be written to disk in all formats other than SMAP HDF5 using write(\"filename.ext\", A). See the docs for write. They can (with some caveats) be written to different formats than they were loaded in as, providing file-type conversion for spatial data.

    Some metadata may be lost in formats that store little metadata, or where metadata conversion has not been completely implemented.

    "},{"location":"scripts/generated/basics/data_sources/#rasterdatasourcesjl-integration","title":"RasterDataSources.jl integration","text":"

    RasterDataSources.jl standardises the download of common raster data sources, with a focus on datasets used in ecology and the environmental sciences. RasterDataSources.jl is tightly integrated into Rasters.jl, so that datsets and keywords can be used directly to download and load data as a Raster, RasterStack, or RasterSeries.

    using Rasters, CairoMakie, Dates\nusing RasterDataSources\nA = Raster(WorldClim{Climate}, :tavg; month=June)\nMakie.plot(A)\n

    See the docs for Raster, RasterStack and RasterSeries, and the docs for RasterDataSources.getraster for syntax to specify various data sources.

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/first_raster/","title":"Quick start","text":"

    Quick start

    Install the package by typing:

    ]\nadd Rasters\n

    then do

    using Rasters\n

    Using Rasters to read GeoTiff or NetCDF files will output something similar to the following toy examples. This is possible because Rasters.jl extends DimensionalData.jl so that spatial data can be indexed using named dimensions like X, Y and Ti (time) and e.g. spatial coordinates.

    using Rasters, Dates\n\nlon, lat = X(25:1:30), Y(25:1:30)\nti = Ti(DateTime(2001):Month(1):DateTime(2002))\nras = Raster(rand(lon, lat, ti)) # this generates random numbers with the dimensions given\n
    6\u00d76\u00d713 Raster{Float64,3} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2002-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2002-01-01T00:00:00\")))missingval: missingparent:\n[:, :, 1]\n     25         26          27          28          29         30\n 25   0.688369   0.444839    0.865557    0.894021    0.310606   0.789457\n 26   0.927933   0.929943    0.499855    0.0696172   0.389926   0.447074\n 27   0.339432   0.0955447   0.241425    0.481324    0.532353   0.273658\n 28   0.138295   0.0858343   0.0938807   0.795397    0.103956   0.650885\n 29   0.138143   0.0778367   0.834551    0.260469    0.701014   0.225302\n 30   0.365167   0.682476    0.014285    0.193982    0.916624   0.894284\n[and 12 more slices...]\n

    "},{"location":"scripts/generated/basics/first_raster/#getting-the-lookup-array-from-dimensions","title":"Getting the lookup array from dimensions","text":"
    lon = lookup(ras, X) # if X is longitude\nlat = lookup(ras, Y) # if Y is latitude\n
    Sampled{Int64} ForwardOrdered Regular Points\nwrapping: 25:1:30\n
    "},{"location":"scripts/generated/basics/first_raster/#select-by-index","title":"Select by index","text":"

    Selecting a time slice by index is done via

    ras[Ti(1)]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))missingval: missingparent:\n     25         26          27          28          29         30\n 25   0.688369   0.444839    0.865557    0.894021    0.310606   0.789457\n 26   0.927933   0.929943    0.499855    0.0696172   0.389926   0.447074\n 27   0.339432   0.0955447   0.241425    0.481324    0.532353   0.273658\n 28   0.138295   0.0858343   0.0938807   0.795397    0.103956   0.650885\n 29   0.138143   0.0778367   0.834551    0.260469    0.701014   0.225302\n 30   0.365167   0.682476    0.014285    0.193982    0.916624   0.894284\n

    also

    ras[Ti=1]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))missingval: missingparent:\n     25         26          27          28          29         30\n 25   0.688369   0.444839    0.865557    0.894021    0.310606   0.789457\n 26   0.927933   0.929943    0.499855    0.0696172   0.389926   0.447074\n 27   0.339432   0.0955447   0.241425    0.481324    0.532353   0.273658\n 28   0.138295   0.0858343   0.0938807   0.795397    0.103956   0.650885\n 29   0.138143   0.0778367   0.834551    0.260469    0.701014   0.225302\n 30   0.365167   0.682476    0.014285    0.193982    0.916624   0.894284\n

    or and interval of indices using the syntax =a:b or (a:b)

    ras[Ti(1:10)]\n
    6\u00d76\u00d710 Raster{Float64,3} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-10-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2001-10-01T00:00:00\")))missingval: missingparent:\n[:, :, 1]\n     25         26          27          28          29         30\n 25   0.688369   0.444839    0.865557    0.894021    0.310606   0.789457\n 26   0.927933   0.929943    0.499855    0.0696172   0.389926   0.447074\n 27   0.339432   0.0955447   0.241425    0.481324    0.532353   0.273658\n 28   0.138295   0.0858343   0.0938807   0.795397    0.103956   0.650885\n 29   0.138143   0.0778367   0.834551    0.260469    0.701014   0.225302\n 30   0.365167   0.682476    0.014285    0.193982    0.916624   0.894284\n[and 9 more slices...]\n

    "},{"location":"scripts/generated/basics/first_raster/#select-by-value","title":"Select by value","text":"
    ras[Ti=At(DateTime(2001))]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))missingval: missingparent:\n     25         26          27          28          29         30\n 25   0.688369   0.444839    0.865557    0.894021    0.310606   0.789457\n 26   0.927933   0.929943    0.499855    0.0696172   0.389926   0.447074\n 27   0.339432   0.0955447   0.241425    0.481324    0.532353   0.273658\n 28   0.138295   0.0858343   0.0938807   0.795397    0.103956   0.650885\n 29   0.138143   0.0778367   0.834551    0.260469    0.701014   0.225302\n 30   0.365167   0.682476    0.014285    0.193982    0.916624   0.894284\n

    More options are available, like Near, Contains and Where.

    Dimensions

    Rasters uses X, Y, and Z dimensions from DimensionalData to represent spatial directions like longitude, latitude and the vertical dimension, and subset data with them. Ti is used for time, and Band represent bands. Other dimensions can have arbitrary names, but will be treated generically. See DimensionalData for more details on how they work.

    Lookup Arrays

    These specify properties of the index associated with e.g. the X and Y dimension. Rasters.jl defines additional lookup arrays: Projected to handle dimensions with projections, and Mapped where the projection is mapped to another projection like EPSG(4326). Mapped is largely designed to handle NetCDF dimensions, especially with Explicit spans.

    "},{"location":"scripts/generated/basics/first_raster/#subsetting-an-object","title":"Subsetting an object","text":"

    Regular getindex (e.g. A[1:100, :]) and view work on all objects just as with an Array. view is always lazy, and reads from disk are deferred until getindex is used. DimensionalData.jl Dimensions and Selectors are the other way to subset an object, making use of the objects index to find values at e.g. certain X/Y coordinates. The available selectors are listed here:

    Selectors Description At(x) get the index exactly matching the passed in value(s). Near(x) get the closest index to the passed in value(s). Where(f::Function) filter the array axis by a function of the dimension index values. a..b/Between(a, b) get all indices between two values, excluding the high value. Contains(x) get indices where the value x falls within an interval.

    Info

    • Use the .. selector to take a view of madagascar:
    using Rasters, RasterDataSources\nconst RS = Rasters\nusing CairoMakie\nCairoMakie.activate!()\n\nA = Raster(WorldClim{BioClim}, 5)\nmadagascar = view(A, X(43.25 .. 50.48), Y(-25.61 .. -12.04))\n
    42\u00d780 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(43.3333, 50.1667, 42) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(-12.3333, -25.5, 80) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (43.33333333333334, 50.333333333333336), Y = (-25.5, -12.166666666666677))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n          -12.3333  -12.5     -12.6667  \u2026  -25.1667  -25.3333  -25.5\n 43.3333   -3.4f38   -3.4f38   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n 43.5      29.7175   30.5      -3.4f38      -3.4f38   -3.4f38   -3.4f38\n 43.6667   29.272    29.7587   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n  \u22ee                                     \u22f1              \u22ee       \n 49.8333   -3.4f38   -3.4f38   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n 50.0      -3.4f38   -3.4f38   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n 50.1667   -3.4f38   -3.4f38   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n

    Note the space between .. -12

    Makie.plot(madagascar)\n

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/gbif_wflow/","title":"A basic species distribution modelling workflow","text":"

    Load occurrences for the Mountain Pygmy Possum using GBIF.jl

    "},{"location":"scripts/generated/basics/gbif_wflow/#load","title":"Load","text":"
    using Rasters, GBIF2\nusing RasterDataSources\nconst RS = Rasters\n\nrecords = GBIF2.occurrence_search(\"Burramys parvus\"; limit=300)\n
    300-element GBIF2.Table{GBIF2.Occurrence, JSON3.Array{JSON3.Object, Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}}\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u2502 decimalLongitude \u2502 decimalLatitude \u2502    year \u2502   month \u2502     day \u2502  kingdom  \u22ef\n\u2502         Float64? \u2502        Float64? \u2502  Int64? \u2502  Int64? \u2502  Int64? \u2502  String?  \u22ef\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502    2021 \u2502       1 \u2502       6 \u2502 Animalia  \u22ef\n\u2502          148.391 \u2502        -36.3036 \u2502    2015 \u2502      11 \u2502      15 \u2502 Animalia  \u22ef\n\u2502          148.333 \u2502        -36.4333 \u2502    2011 \u2502      11 \u2502      21 \u2502 Animalia  \u22ef\n\u2502          148.396 \u2502        -36.3818 \u2502    2016 \u2502      11 \u2502      15 \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          148.236 \u2502        -36.5249 \u2502    2012 \u2502      11 \u2502      23 \u2502 Animalia  \u22ef\n\u2502          147.096 \u2502        -36.9357 \u2502    2020 \u2502       2 \u2502      10 \u2502 Animalia  \u22ef\n\u2502          148.329 \u2502        -36.4317 \u2502    2016 \u2502       1 \u2502       3 \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          148.241 \u2502        -36.4001 \u2502    2011 \u2502      11 \u2502      18 \u2502 Animalia  \u22ef\n\u2502          148.347 \u2502        -36.5047 \u2502    2012 \u2502      11 \u2502      22 \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502        \u22ee         \u2502        \u22ee        \u2502    \u22ee    \u2502    \u22ee    \u2502    \u22ee    \u2502    \u22ee      \u22f1\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n                                                 77 columns and 285 rows omitted\n
    "},{"location":"scripts/generated/basics/gbif_wflow/#extract-coordinates","title":"Extract coordinates","text":"

    Extract the longitude/latitude value to a Vector of points (a Tuple counts as a (x, y) point in GeoInterface.jl):

    coords = [(r.decimalLongitude, r.decimalLatitude) for r in records if !ismissing(r.decimalLatitude)]\n
    253-element Vector{Tuple{Float64, Float64}}:\n (148.391097, -36.30362)\n (148.332969, -36.433349)\n (148.396453, -36.381847)\n (148.235596, -36.524924)\n (147.096394, -36.935687)\n (148.328896, -36.431684)\n (148.240881, -36.400058)\n (148.347186, -36.504673)\n (147.1, -37.0)\n (148.338776, -36.430986)\n \u22ee\n (148.357658, -36.324288)\n (148.336891, -36.428415)\n (148.256519, -36.442973)\n (148.467196, -36.000859)\n (148.467196, -36.000859)\n (148.40889, -36.006805)\n (148.40889, -36.006805)\n (148.40889, -36.006805)\n (148.40889, -36.006805)\n

    "},{"location":"scripts/generated/basics/gbif_wflow/#get-layer-band","title":"Get layer / Band","text":"

    Get BioClim layers and subset to south-east Australia

    A = RasterStack(WorldClim{BioClim}, (1, 3, 7, 12))\nse_aus = A[X(138 .. 155), Y(-40 .. -25), RS.Band(1)]\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(138.0, 154.833, 102) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(-25.1667, -39.8333, 89) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :bio1  Float32 dims: X, Y (102\u00d789)\n  :bio3  Float32 dims: X, Y (102\u00d789)\n  :bio7  Float32 dims: X, Y (102\u00d789)\n  :bio12 Float32 dims: X, Y (102\u00d789)\n

    Plot BioClim predictors and scatter occurrence points on all subplots

    using Plots\np = plot(se_aus);\nkw = (legend=:none, opacity=0.5, markershape=:cross, markercolor=:black)\nforeach(i -> scatter!(p, coords; subplot=i, kw...), 1:4)\np\n

    Then extract predictor variables and write to CSV.

    using CSV\npredictors = collect(extract(se_aus, coords))\nCSV.write(\"burramys_parvus_predictors.csv\", predictors)\n
    \"burramys_parvus_predictors.csv\"\n

    Or convert them to a DataFrame:

    using DataFrames\ndf = DataFrame(predictors)\ndf[1:5, :]\n
    5\u00d75 DataFrame Rowgeometrybio1bio3bio7bio12Tuple\u2026Float32Float32Float32Float321(148.391, -36.3036)6.170741.119823.46451692.02(148.333, -36.4333)7.8357241.597523.50281500.03(148.396, -36.3818)6.8815842.268123.1331544.04(148.236, -36.5249)8.001641.846522.85221368.05(147.096, -36.9357)9.4083540.790523.08951292.0

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/methods/","title":"Methods","text":""},{"location":"scripts/generated/basics/methods/#methods-that-change-the-resolution-or-extent-of-an-object","title":"Methods that change the resolution or extent of an object","text":"

    Click through to the function documentation for more in-depth descriptions and examples.

    Methods Description aggregate aggregate data by the same or different amounts for each axis. disaggregate similarly disaggregate data. mosaic join rasters covering different extents into a single array or file. crop shrink objects to specific dimension sizes or the extent of another object. extend extend objects to specific dimension sizes or the extent of another object. trim trims areas of missing values for arrays and across stack layers. resample resample data to a different size and projection, or snap to another object. warp use gdalwarp on any object, e.g. a multidimensional NetCDF stack.

    "},{"location":"scripts/generated/basics/methods/#methods-that-change-an-objects-values","title":"Methods that change an objects values","text":"

    Info

    Note that most regular Julia methods, such as replace, work as for a standard Array. These additional methods are commonly required in GIS applications.

    Methods Description classify classify values into categories. mask mask an object by a polygon or Raster along X/Y, or other dimensions. replace_missing replace all missing values in an object and update missingval.

    "},{"location":"scripts/generated/basics/methods/#point-polygon-and-table-operation","title":"Point, polygon and table operation","text":"Methods Description rasterize rasterize points and geometries. extract extract values from points or geometries. zonal calculate zonal statistics for an object masked by geometries."},{"location":"scripts/generated/basics/methods/#methods-to-load-write-and-modify-data-sources","title":"Methods to load, write and modify data sources","text":"Methods Description modify replace the data in objects. Useful to e.g. move objects to/from a GPU. read read data to memory if it is on disk. read! read data to predefined memory. open open the underlying data for manually reading or writing. write write objects to file.

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/plot_makie/","title":"Examples with Makie","text":""},{"location":"scripts/generated/basics/plot_makie/#plotting-in-makie","title":"Plotting in Makie","text":"

    Plotting in Makie works somewhat differently than Plots, since the recipe system is different. You can pass a 2-D raster to any surface-like function (heatmap, contour, contourf, or even surface for a 3D plot) with ease.

    "},{"location":"scripts/generated/basics/plot_makie/#2-d-rasters-in-makie","title":"2-D rasters in Makie","text":"
    using CairoMakie, Makie\nusing Rasters, RasterDataSources, ArchGDAL\nA = Raster(WorldClim{BioClim}, 5) # this is a 3D raster, so is not accepted.\n\nfig = Figure()\nplot(fig[1, 1], A)\ncontour(fig[1, 2], A)\nax = Axis(fig[2, 1]; aspect = DataAspect())\ncontourf!(ax, A)\nsurface(fig[2, 2], A) # even a 3D plot works!\nfig\n
    "},{"location":"scripts/generated/basics/plot_makie/#3-d-rasters-in-makie","title":"3-D rasters in Makie","text":"

    Warning

    This interface is experimental, and unexported for that reason. It may break at any time!

    Just as in Plots, 3D rasters are treated as a series of 2D rasters, which are tiled and plotted.

    You can use Rasters.rplot to visualize 3D rasters or RasterStacks in this way. An example is below:

    stack = RasterStack(WorldClim{Climate}; month = 1)\nRasters.rplot(stack; Axis = (aspect = DataAspect(),),)\n

    You can pass any theming keywords in, which are interpreted by Makie appropriately.

    The plots seem a little squished here. We provide a Makie theme which makes text a little smaller and has some other space-efficient attributes:

    Makie.set_theme!(Rasters.theme_rasters())\nRasters.rplot(stack)\n

    reset theme

    Makie.set_theme!()\n

    "},{"location":"scripts/generated/basics/plot_makie/#plotting-with-observables-animations","title":"Plotting with Observables, animations","text":"

    Rasters.rplot should support Observable input out of the box, but the dimensions of that input must remain the same - i.e., the element names of a RasterStack must remain the same.

    Makie.set_theme!(Rasters.theme_rasters())\n

    stack is the WorldClim climate data for January

    stack_obs = Observable(stack)\nfig = Rasters.rplot(stack_obs;\n    Colorbar=(; height=Relative(0.75), width=5)\n)\nrecord(fig, \"rplot.mp4\", 1:12; framerate = 3) do i\n    stack_obs[] = RasterStack(WorldClim{Climate}; month = i)\nend\n
    \"rplot.mp4\"\n

    Makie.set_theme!() # reset theme\n

    # Rasters.rplot \u2014 Function.

    Rasters.rplot([position::GridPosition], raster; kw...)\n

    raster may be a Raster (of 2 or 3 dimensions) or a RasterStack whose underlying rasters are 2 dimensional, or 3-dimensional with a singleton (length-1) third dimension.

    Keywords

    • plottype = Makie.Heatmap: The type of plot. Can be any Makie plot type which accepts a Raster; in practice, Heatmap, Contour, Contourf and Surface are the best bets.
    • axistype = Makie.Axis: The type of axis. This can be an Axis, Axis3, LScene, or even a GeoAxis from GeoMakie.jl.
    • X = XDim: The X dimension of the raster.
    • Y = YDim: The Y dimension of the raster.
    • Z = YDim: The Y dimension of the raster.
    • draw_colorbar = true: Whether to draw a colorbar for the axis or not.
    • colorbar_position = Makie.Right(): Indicates which side of the axis the colorbar should be placed on. Can be Makie.Top(), Makie.Bottom(), Makie.Left(), or Makie.Right().
    • colorbar_padding = Makie.automatic: The amound of padding between the colorbar and its axis. If automatic, then this is set to the width of the colorbar.
    • title = Makie.automatic: The titles of each plot. If automatic, these are set to the name of the band.
    • xlabel = Makie.automatic: The x-label for the axis. If automatic, set to the dimension name of the X-dimension of the raster.
    • ylabel = Makie.automatic: The y-label for the axis. If automatic, set to the dimension name of the Y-dimension of the raster.
    • colorbarlabel = \"\": Usually nothing, but here if you need it. Sets the label on the colorbar.
    • colormap = nothing: The colormap for the heatmap. This can be set to a vector of colormaps (symbols, strings, cgrads) if plotting a 3D raster or RasterStack.
    • colorrange = Makie.automatic: The colormap for the heatmap. This can be set to a vector of (low, high) if plotting a 3D raster or RasterStack.
    • nan_color = :transparent: The color which NaN values should take. Default to transparent.

    source

    "},{"location":"scripts/generated/basics/plot_makie/#using-vanilla-makie","title":"Using vanilla Makie","text":"
    using Rasters, RasterDataSources\n

    The data

    layers = (:evenness, :range, :contrast, :correlation)\nst = RasterStack(EarthEnv{HabitatHeterogeneity}, layers)\nausbounds = X(100 .. 160), Y(-50 .. -10) # Roughly cut out australia\naus = st[ausbounds...] |> Rasters.trim\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(113.333, 153.542, 194) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(-10.2083, -43.5417, 161) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :evenness    UInt16 dims: X, Y (194\u00d7161)\n  :range       UInt16 dims: X, Y (194\u00d7161)\n  :contrast    UInt32 dims: X, Y (194\u00d7161)\n  :correlation UInt16 dims: X, Y (194\u00d7161)\n

    The plot colorbar attributes

    colormap = :batlow\nflipaxis = false\ntickalign=1\nwidth = 13\nticksize = 13\n
    13\n

    figure

    with_theme(theme_ggplot2()) do\n    fig = Figure(resolution=(800, 600))\n    axs = [Axis(fig[i,j], xlabel = \"lon\", ylabel = \"lat\") for i in 1:2 for j in 1:2]\n    plt = [Makie.heatmap!(axs[i], aus[l]; colormap) for (i, l) in enumerate(layers)]\n    for (i, l) in enumerate(layers) axs[i].title = string(l) end\n    hidexdecorations!.(axs[1:2]; grid=false, ticks=false)\n    hideydecorations!.(axs[[2,4]]; grid=false, ticks=false)\n    Colorbar(fig[1, 0], plt[1]; flipaxis, tickalign, width, ticksize)\n    Colorbar(fig[1, 3], plt[2]; tickalign, width, ticksize)\n    Colorbar(fig[2, 0], plt[3]; flipaxis, tickalign, width, ticksize)\n    Colorbar(fig[2, 3], plt[4]; tickalign, width, ticksize)\n    colgap!(fig.layout, 5)\n    rowgap!(fig.layout, 5)\n    Label(fig[0, :], \"RasterStack of EarthEnv HabitatHeterogeneity layers, trimmed to Australia\")\n    fig\nend\nsave(\"aus_trim.png\", current_figure());\n

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/plotting/","title":"Examples and Plotting","text":""},{"location":"scripts/generated/basics/plotting/#plots-simple","title":"Plots, simple","text":"

    Plots.jl and Makie.jl are fully supported by Rasters.jl, with recipes for plotting Raster and RasterStack provided. plot will plot a heatmap with axes matching dimension values. If mappedcrs is used, converted values will be shown on axes instead of the underlying crs values. contourf will similarly plot a filled contour plot.

    Pixel resolution is limited to allow loading very large files quickly. max_res specifies the maximum pixel resolution to show on the longest axis of the array. It can be set manually to change the resolution (e.g. for large or high-quality plots):

    using Rasters, RasterDataSources, ArchGDAL, Plots\nA = Raster(WorldClim{BioClim}, 5)\nplot(A; max_res=3000)\n

    For Makie, plot functions in a similar way. plot will only accept two-dimensional rasters. You can invoke contour, contourf, heatmap, surface or any Makie plotting function which supports surface-like data on a 2D raster.

    To obtain tiled plots for 3D rasters and RasterStacks, use the function Rasters.rplot([gridposition], raster; kw_args...). This is an unexported function, since we're not sure how the API will change going forward.

    "},{"location":"scripts/generated/basics/plotting/#makie-simple","title":"Makie, simple","text":"
    using CairoMakie\nCairoMakie.activate!(px_per_unit = 2)\nusing Rasters, CairoMakie, RasterDataSources, ArchGDAL\nA = Raster(WorldClim{BioClim}, 5)\nMakie.plot(A)\n
    "},{"location":"scripts/generated/basics/plotting/#loading-data","title":"Loading data","text":"

    Our first example simply loads a file from disk and plots it.

    This netcdf file only has one layer, if it has more we could use RasterStack instead.

    using Rasters, NCDatasets, Plots\nurl = \"https://www.unidata.ucar.edu/software/netcdf/examples/tos_O1_2001-2002.nc\";\nfilename = download(url, \"tos_O1_2001-2002.nc\");\nA = Raster(filename)\n
    180\u00d7170\u00d724 Raster{Union{Missing, Float32},3} tos with dimensions: \n  X Mapped{Float64} Float64[1.0, 3.0, \u2026, 357.0, 359.0] ForwardOrdered Explicit Intervals crs: EPSG mappedcrs: EPSG,\n  Y Mapped{Float64} Float64[-79.5, -78.5, \u2026, 88.5, 89.5] ForwardOrdered Explicit Intervals crs: EPSG mappedcrs: EPSG,\n  Ti Sampled{DateTime360Day} DateTime360Day[DateTime360Day(2001-01-16T00:00:00), \u2026, DateTime360Day(2002-12-16T00:00:00)] ForwardOrdered Explicit Intervals\nextent: Extent(X = (-0.0, 360.0), Y = (-80.0, 90.0), Ti = (DateTime360Day(2001-01-01T00:00:00), DateTime360Day(2003-01-01T00:00:00)))missingval: missingcrs: EPSG:4326\nmappedcrs: EPSG:4326\nparent:\n[:, :, 1]\n        -79.5       -78.5       \u2026   86.5     87.5     88.5     89.5\n   1.0     missing     missing     271.43   271.437  271.445  271.459\n   3.0     missing     missing     271.431  271.438  271.445  271.459\n   5.0     missing     missing     271.431  271.438  271.445  271.459\n   7.0     missing     missing     271.431  271.439  271.446  271.459\n   \u22ee                            \u22f1                      \u22ee      \n 351.0     missing     missing     271.43   271.435  271.445  271.459\n 353.0     missing     missing     271.43   271.436  271.445  271.459\n 355.0     missing     missing     271.43   271.436  271.445  271.459\n 357.0     missing     missing     271.43   271.437  271.445  271.459\n 359.0     missing     missing  \u2026  271.43   271.437  271.445  271.459\n[and 23 more slices...]\n

    Objects with Dimensions other than X and Y will produce multi-pane plots. Here we plot every third month in the first year in one plot:

    A[Ti=1:3:12] |> plot\n

    Now plot the ocean temperatures around the Americas in the first month of 2001. Notice we are using lat/lon coordinates and date/time instead of regular indices. The time dimension uses DateTime360Day, so we need to load CFTime.jl to index it with Near.

    using CFTime\nA[Ti(Near(DateTime360Day(2001, 01, 17))), Y(-60.0 .. 90.0), X(45.0 .. 190.0)] |> plot\n

    Now get the mean over the timespan, then save it to disk, and plot it as a filled contour.

    Other plot functions and sliced objects that have only one X/Y/Z dimension fall back to generic DimensionalData.jl plotting, which will still correctly label plot axes.

    using Statistics\n# Take the mean\nmean_tos = mean(A; dims=Ti)\n
    180\u00d7170\u00d71 Raster{Union{Missing, Float32},3} tos with dimensions: \n  X Mapped{Float64} Float64[1.0, 3.0, \u2026, 357.0, 359.0] ForwardOrdered Explicit Intervals crs: EPSG mappedcrs: EPSG,\n  Y Mapped{Float64} Float64[-79.5, -78.5, \u2026, 88.5, 89.5] ForwardOrdered Explicit Intervals crs: EPSG mappedcrs: EPSG,\n  Ti Sampled{DateTime360Day} DateTime360Day(2002-01-16T00:00:00):Millisecond(2592000000):DateTime360Day(2002-01-16T00:00:00) ForwardOrdered Explicit Intervals\nextent: Extent(X = (-0.0, 360.0), Y = (-80.0, 90.0), Ti = (DateTime360Day(2001-01-01T00:00:00), DateTime360Day(2003-01-01T00:00:00)))missingval: missingcrs: EPSG:4326\nmappedcrs: EPSG:4326\nparent:\n[:, :, 1]\n        -79.5       -78.5       \u2026   86.5     87.5     88.5     89.5\n   1.0     missing     missing     271.427  271.434  271.443  271.454\n   3.0     missing     missing     271.427  271.434  271.443  271.454\n   5.0     missing     missing     271.427  271.434  271.443  271.454\n   7.0     missing     missing     271.427  271.435  271.444  271.454\n   \u22ee                            \u22f1                      \u22ee      \n 351.0     missing     missing     271.427  271.433  271.443  271.454\n 353.0     missing     missing     271.427  271.433  271.443  271.454\n 355.0     missing     missing     271.427  271.433  271.443  271.454\n 357.0     missing     missing     271.427  271.433  271.443  271.454\n 359.0     missing     missing  \u2026  271.427  271.433  271.443  271.454\n

    "},{"location":"scripts/generated/basics/plotting/#plot-a-contour-plot","title":"Plot a contour plot","text":"
    using Plots\nPlots.contourf(mean_tos; dpi=300, size=(800, 400))\n
    "},{"location":"scripts/generated/basics/plotting/#write-to-disk","title":"write to disk","text":"

    Write the mean values to disk

    write(\"mean_tos.nc\", mean_tos)\n
    \"mean_tos.nc\"\n

    Plotting recipes in DimensionalData.jl are the fallback for Rasters.jl when the object doesn't have 2 X/Y/Z dimensions, or a non-spatial plot command is used. So (as a random example) we could plot a transect of ocean surface temperature at 20 degree latitude :

    A[Y(Near(20.0)), Ti(1)] |> plot\n

    "},{"location":"scripts/generated/basics/plotting/#polygon-masking-mosaic-and-plot","title":"Polygon masking, mosaic and plot","text":"

    In this example we will mask the Scandinavian countries with border polygons, then mosaic together to make a single plot.

    First, get the country boundary shape files using GADM.jl.

    using Rasters, RasterDataSources, ArchGDAL, Shapefile, Plots, Dates, Downloads, NCDatasets\n
    WARNING: using Downloads.download in module Main conflicts with an existing identifier.\n

    Download the shapefile

    shapefile_url = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp\"\nshapefile_name = \"boundary_lines.shp\"\nDownloads.download(shapefile_url, shapefile_name)\n
    \"boundary_lines.shp\"\n

    Load using Shapefile.jl

    shapes = Shapefile.Handle(shapefile_name)\ndenmark_border = shapes.shapes[71]\nnorway_border = shapes.shapes[53]\nsweden_border = shapes.shapes[54]\n
    Polygon(4665 Points)\n

    Then load raster data. We load some worldclim layers using RasterDataSources via Rasters.jl:

    climate = RasterStack(WorldClim{Climate}, (:tmin, :tmax, :prec, :wind); month=July)\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (2160\u00d71080)\n  :tmax Float32 dims: X, Y (2160\u00d71080)\n  :prec Int16 dims: X, Y (2160\u00d71080)\n  :wind Float32 dims: X, Y (2160\u00d71080)\n

    mask Denmark, Norway and Sweden from the global dataset using their border polygon, then trim the missing values. We pad trim with a 10 pixel margin.

    mask_trim(climate, poly) = trim(mask(climate; with=poly); pad=10)\n\ndenmark = mask_trim(climate, denmark_border)\nnorway = mask_trim(climate, norway_border)\nsweden = mask_trim(climate, sweden_border)\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(9.5, 25.6667, 98) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(70.5, 53.6667, 102) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (98\u00d7102)\n  :tmax Float32 dims: X, Y (98\u00d7102)\n  :prec Int16 dims: X, Y (98\u00d7102)\n  :wind Float32 dims: X, Y (98\u00d7102)\n

    Then load raster data. We load some worldclim layers using RasterDataSources via Rasters.jl:

    climate = RasterStack(WorldClim{Climate}, (:tmin, :tmax, :prec, :wind); month=July)\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (2160\u00d71080)\n  :tmax Float32 dims: X, Y (2160\u00d71080)\n  :prec Int16 dims: X, Y (2160\u00d71080)\n  :wind Float32 dims: X, Y (2160\u00d71080)\n

    mask Denmark, Norway and Sweden from the global dataset using their border polygon, then trim the missing values. We pad trim with a 10 pixel margin.

    mask_trim(climate, poly) = trim(mask(climate; with=poly); pad=10)\n\ndenmark = mask_trim(climate, denmark_border)\nnorway = mask_trim(climate, norway_border)\nsweden = mask_trim(climate, sweden_border)\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(9.5, 25.6667, 98) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(70.5, 53.6667, 102) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (98\u00d7102)\n  :tmax Float32 dims: X, Y (98\u00d7102)\n  :prec Int16 dims: X, Y (98\u00d7102)\n  :wind Float32 dims: X, Y (98\u00d7102)\n

    "},{"location":"scripts/generated/basics/plotting/#plotting-with-plots","title":"Plotting with Plots","text":"

    First define a function to add borders to all subplots.

    function borders!(p, poly)\n    for i in 1:length(p)\n        Plots.plot!(p, poly; subplot=i, fillalpha=0, linewidth=0.6)\n    end\n    return p\nend\n
    borders! (generic function with 1 method)\n

    Now we can plot the individual countries.

    dp = plot(denmark)\nborders!(dp, denmark_border)\n

    and sweden

    sp = plot(sweden)\nborders!(sp, sweden_border)\n

    and norway

    np = plot(norway)\nborders!(np, norway_border)\n

    The Norway shape includes a lot of islands. Lets crop them out using .. intervals:

    norway_region = climate[X(0..40), Y(55..73)]\nplot(norway_region)\n

    And mask it with the border again:

    norway = mask_trim(norway_region, norway_border)\nnp = plot(norway)\nborders!(np, norway_border)\n

    Now we can combine the countries into a single raster using mosaic. first will take the first value if/when there is an overlap.

    scandinavia = mosaic(first, denmark, norway, sweden)\n
    RasterStack with dimensions: \n  X Projected{Float64} 3.1666666666666443:0.16666666666666666:32.49999999999998 ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} 72.66666666666666:-0.16666666666666666:52.99999999999999 ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (177\u00d7119)\n  :tmax Float32 dims: X, Y (177\u00d7119)\n  :prec Int16 dims: X, Y (177\u00d7119)\n  :wind Float32 dims: X, Y (177\u00d7119)\n

    And plot scandinavia, with all borders included:

    p = plot(scandinavia)\nborders!(p, denmark_border)\nborders!(p, norway_border)\nborders!(p, sweden_border)\np\n

    And save to netcdf - a single multi-layered file, and tif, which will write a file for each stack layer.

    write(\"scandinavia.nc\", scandinavia)\nwrite(\"scandinavia.tif\", scandinavia)\n
    (tmin = \"scandinavia_tmin.tif\", tmax = \"scandinavia_tmax.tif\", prec = \"scandinavia_prec.tif\", wind = \"scandinavia_wind.tif\")\n

    Rasters.jl provides a range of other methods that are being added to over time. Where applicable these methods read and write lazily to and from disk-based arrays of common raster file types. These methods also work for entire RasterStacks and RasterSeries using the same syntax.

    This page was generated using Literate.jl.

    "}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":""},{"location":"#rastersjl","title":"Rasters.jl","text":"

    Rasters.jl defines common types and methods for reading, writing and manipulating rasterized spatial data.

    These currently include raster arrays like GeoTIFF and NetCDF, R grd files, multi-layered stacks, and multi-file series of arrays and stacks.

    Data-source abstraction

    Rasters provides a standardised interface that allows many source data types to be used with identical syntax.

    • Scripts and packages building on Rasters.jl can treat Raster,

    RasterStack, and RasterSeries as black boxes.

    • The data could hold GeoTiff or NetCDF files, Arrays in memory or CuArrays on the GPU - they will all behave in the same way.
    • RasterStack can be backed by a Netcdf or HDF5 file, or a NamedTuple of Raster holding .tif files, or all Raster in memory.
    • Users do not have to deal with the specifics of spatial file types.
    • Projected lookups with Cylindrical projections can by indexed using other Cylindrical projections

    by setting the mappedcrs keyword on construction. You don't need to know the underlying projection, the conversion is handled automatically. This means lat/lon EPSG(4326) can be used seamlessly if you need that.

    Packages extensions and Rasters 0.8 and onwards

    On Julia 1.9 we can put additional packages in extensions, so the code only loads when you load a specific package. Rasters.jl was always intended to work like this, and its finally possible. This reduced package using time from many seconds to well under a second.

    But, it means you have to manually load packages you need for each backend or additional functionality.

    For example, to use the GDAL backend, and download files, you now need to do:

    using Rasters, ArchGDAL, RasterDataSources\n

    where previously it was just using Rasters.

    Sources and packages needed:

    • :gdal: using ArchGDAL
    • :netcdf: using NCDatasets
    • :grd: built-in.
    • :smap: using HDF5
    • :grib: not yet finished.

    Other functionality in extensions:

    • Raster data downloads, like Worldclim{Climate}: using RasterDataSources
    • Makie plots: using Makie
    • Coordinate transformations for gdal rasters: using CoordinateTransformations
    Bugs, errors and making issues for Rasters.jl

    Raster data is complicated and there are many places for subtle or not-so-subtle bugs to creep in.

    We need bug reports to reduce how often they occur over time. But also, we need issues that are easy to reproduce or it isn't practically possible to fix them.

    Because there are so many raster file types and variations of them, most of the time we need the exact file that caused your problem to know how to fix it, and be sure that we have actually fixed it when we are done. So fixing a Rasters.jl bug nearly always involves downloading some file and running some code that breaks with it (if you can trigger the bug without a file, thats great! but its not always possible).

    To make an issue we can fix quickly (or at all) there are three key steps:

    1. Include the file in an accessible place on web without autentication or any other work on our part, so we can just get it and find your bug. You can put it on a file hosting platform (e.g. google drive, drop box, whatever you use) and share the url.
    2. Add a minimum working example to the issue template that first downloads the file, then runs the function that triggers the bug.
    3. Paste the complete stack trace of the error it produces, right to the bottom, into the issue template. Then we can be sure we reproduced the same problem.

    Good issues are really appreciated, but they do take just a little extra effort with Rasters.jl because of this need for files.

    "},{"location":"reference/","title":"API Reference","text":""},{"location":"reference/#index","title":"Index","text":"
    • Rasters.Rasters
    • Rasters.AbstractProjected
    • Rasters.AbstractRaster
    • Rasters.AbstractRasterSeries
    • Rasters.AbstractRasterStack
    • Rasters.Band
    • Rasters.FileArray
    • Rasters.FileStack
    • Rasters.Mapped
    • Rasters.OpenStack
    • Rasters.Projected
    • Rasters.Raster
    • Rasters.RasterDiskArray
    • Rasters.RasterSeries
    • Rasters.RasterStack
    • Rasters.aggregate
    • Rasters.aggregate!
    • Rasters.boolmask
    • Rasters.classify
    • Rasters.classify!
    • Rasters.combine
    • Rasters.convertlookup
    • Rasters.coverage
    • Rasters.coverage!
    • Rasters.crop
    • Rasters.crs
    • Rasters.disaggregate
    • Rasters.disaggregate!
    • Rasters.extend
    • Rasters.extract
    • Rasters.mappedbounds
    • Rasters.mappedcrs
    • Rasters.mappedindex
    • Rasters.mask
    • Rasters.mask!
    • Rasters.missingmask
    • Rasters.missingval
    • Rasters.mosaic
    • Rasters.mosaic!
    • Rasters.points
    • Rasters.rasterize
    • Rasters.rasterize!
    • Rasters.replace_missing
    • Rasters.reproject
    • Rasters.reproject
    • Rasters.rplot
    • Rasters.setcrs
    • Rasters.setmappedcrs
    • Rasters.slice
    • Rasters.smapseries
    • Rasters.trim
    • Rasters.zonal
    "},{"location":"reference/#reference-exported-functions","title":"Reference - Exported functions","text":"

    # Rasters.Rasters \u2014 Module.

    Rasters

    Rasters.jl defines common types and methods for reading, writing and manipulating rasterized spatial data.

    These currently include raster arrays like GeoTIFF and NetCDF, R grd files, multi-layered stacks, and multi-file series of arrays and stacks.

    :warning: Packages extensions and Rasters 0.8 and onwards

    On Julia 1.9 we can put additional packages in extensions, so the code only loads when you load a specific package. Rasters.jl was always intended to work like this, and its finally possible. This reduced package using time from many seconds to well under a second.

    But, it means you have to manually load packages you need for each backend or additional functionality.

    For example, to use the GDAL backend, and download files, you now need to do:

    using Rasters, ArchGDAL, RasterDataSources\n

    where previously it was just using Rasters.

    Sources and packages needed:

    • :gdal: using ArchGDAL
    • :netcdf: using NCDatasets
    • :grd: built-in.
    • :smap: using HDF5
    • :grib: not yet finished.

    Other functionality in extensions:

    • Raster data downloads, like Worldclim{Climate}: using RasterDataSources
    • Makie plots: using Makie
    • Coordinate transformations for gdal rasters: using CoordinateTransformations

    Quick start

    Install the package by typing:

    ]\nadd Rasters\n
    using Rasters\n

    Using Rasters to read GeoTiff or NetCDF files will output something similar to the following toy examples. This is possible because Rasters.jl extends DimensionalData.jl so that spatial data can be indexed using named dimensions like X, Y and Ti (time) and e.g. spatial coordinates.

    using Rasters, Dates\nlon, lat = X(25:1:30), Y(25:1:30)\nti = Ti(DateTime(2001):Month(1):DateTime(2002))\nras = Raster(rand(lon, lat, ti)) # this generates random numbers with the dimensions given\n
    6\u00d76\u00d713 Raster{Float64,3} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2002-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2002-01-01T00:00:00\")))\nmissingval: missing\nvalues: [:, :, 1]\n     25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n[and 12 more slices...]\n

    Getting the lookup array from dimensions

    lon = lookup(ras, X) # if X is longitude\nlat = lookup(ras, Y) # if Y is latitude\n
    Sampled{Int64} ForwardOrdered Regular Points\nwrapping: 25:1:30\n

    Select by index

    Selecting a time slice by index is done via

    ras[Ti(1)]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))\nmissingval: missing\nvalues:      25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n
    ras[Ti=1]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))\nmissingval: missing\nvalues:      25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n

    or and interval of indices using the syntax =a:b or (a:b)

    ras[Ti(1:10)]\n
    6\u00d76\u00d710 Raster{Float64,3} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-10-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2001-10-01T00:00:00\")))\nmissingval: missing\nvalues: [:, :, 1]\n     25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n[and 9 more slices...]\n

    Select by value

    ras[Ti=At(DateTime(2001))]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))\nmissingval: missing\nvalues:      25         26          27          28         29          30\n 25   0.9063     0.427328    0.0320967   0.297023   0.0571002   0.891377\n 26   0.443494   0.867547    0.350546    0.150155   0.24565     0.711039\n 27   0.745673   0.0991336   0.930332    0.893537   0.805931    0.360583\n 28   0.512083   0.125287    0.959434    0.354868   0.337824    0.259563\n 29   0.253849   0.692209    0.774092    0.131798   0.823656    0.390013\n 30   0.334152   0.136551    0.183555    0.941133   0.450484    0.461862\n

    More options are available, like Near, Contains and Where. For more details go here.

    Dimensions can also be used in most Base and Statistics methods like mean and reduce where dims arguments are required. Much of the behaviour is covered in the DimensionalData docs.

    See the docs for more details and examples for Rasters.jl.

    Data-source abstraction

    Rasters provides a standardised interface that allows many source data types to be used with identical syntax.

    • Scripts and packages building on Rasters.jl can treat Raster, RasterStack, and RasterSeries as black boxes.

      • The data could hold GeoTiff or NetCDF files, Arrays in memory or CuArrays on the GPU - they will all behave in the same way.
      • RasterStack can be backed by a Netcdf or HDF5 file, or a NamedTuple of Raster holding .tif files, or all Raster in memory.
      • Users do not have to deal with the specifics of spatial file types.
      • Projected lookups with Cylindrical projections can by indexed using other Cylindrical projections by setting the mappedcrs keyword on construction. You don't need to know the underlying projection, the conversion is handled automatically. This means lat/lon EPSG(4326) can be used seamlessly if you need that.

    Bugs, errors and making issues for Rasters.jl

    Raster data is complicated and there are many places for subtle or not-so-subtle bugs to creep in.

    We need bug reports to reduce how often they occur over time. But also, we need issues that are easy to reproduce or it isn't practically possible to fix them.

    Because there are so many raster file types and variations of them, most of the time we need the exact file that caused your problem to know how to fix it, and be sure that we have actually fixed it when we are done. So fixing a Rasters.jl bug nearly always involves downloading some file and running some code that breaks with it (if you can trigger the bug without a file, thats great! but its not always possible).

    To make an issue we can fix quickly (or at all) there are three key steps:

    1. Include the file in an accessible place on web without autentication or any other work on our part, so we can just get it and find your bug. You can put it on a file hosting platform (e.g. google drive, drop box, whatever you use) and share the url.
    2. Add a minimum working example to the issue template that first downloads the file, then runs the function that triggers the bug.
    3. Paste the complete stack trace of the error it produces, right to the bottom, into the issue template. Then we can be sure we reproduced the same problem.

    Good issues are really appreciated, but they do take just a little extra effort with Rasters.jl because of this need for files.

    source

    # Rasters.AbstractRaster \u2014 Type.

    AbstractRaster <: DimensionalData.AbstractDimArray\n

    Abstract supertype for objects that wrap an array (or location of an array) and metadata about its contents. It may be memory or hold a FileArray, which holds the filename, and is only opened when required.

    AbstractRasters inherit from AbstractDimArray from DimensionalData.jl. They can be indexed as regular Julia arrays or with DimensionalData.jl Dimensions. They will plot as a heatmap in Plots.jl with correct coordinates and labels, even after slicing with getindex or view. getindex on a AbstractRaster will always return a memory-backed Raster.

    source

    # Rasters.AbstractRasterSeries \u2014 Type.

    AbstractRasterSeries <: DimensionalData.AbstractDimensionalArray\n

    Abstract supertype for high-level DimensionalArray that hold RasterStacks, Rasters, or the paths they can be loaded from. RasterSeries are indexed with dimensions as with a AbstractRaster. This is useful when you have multiple files containing rasters or stacks of rasters spread over dimensions like time and elevation.

    As much as possible, implementations should facilitate loading entire directories and detecting the dimensions from metadata.

    This allows syntax like below for a series of stacks of arrays:

    RasterSeries[Time(Near(DateTime(2001, 1))][:temp][Y(Between(70, 150)), X(Between(-20,20))] |> plot`\n

    RasterSeries is the concrete implementation.

    source

    # Rasters.AbstractRasterStack \u2014 Type.

    AbstractRasterStack\n

    Abstract supertype for objects that hold multiple AbstractRasters that share spatial dimensions.

    They are NamedTuple-like structures that may either contain NamedTuple of AbstractRasters, string paths that will load AbstractRasters, or a single path that points to a file containing multiple layers, like NetCDF or HDF5. Use and syntax is similar or identical for all cases.

    AbstractRasterStack can hold layers that share some or all of their dimensions. They cannot have the same dimension with different length or spatial extent as another layer.

    getindex on an AbstractRasterStack generally returns a memory backed standard Raster. raster[:somelayer] |> plot plots the layers array, while raster[:somelayer, X(1:100), Band(2)] |> plot will plot the subset without loading the whole array.

    getindex on an AbstractRasterStack with a key returns another stack with getindex applied to all the arrays in the stack.

    source

    # Rasters.Band \u2014 Type.

    Band <: Dimension\n\nBand(val=:)\n

    Band Dimension for multi-band rasters.

    Example:

    banddim = Band(10:10:100)\n# Or\nval = A[Band(1)]\n# Or\nmean(A; dims=Band)\n

    source

    # Rasters.Mapped \u2014 Type.

    Mapped <: AbstractProjected\n\nMapped(order, span, sampling, crs, mappedcrs)\nMapped(; order=AutoOrder(), span=AutoSpan(), sampling=AutoSampling(), crs=nothing, mappedcrs)\n

    An AbstractSampled LookupArray, where the dimension index has been mapped to another projection, usually lat/lon or EPSG(4326). Mapped matches the dimension format commonly used in netcdf files.

    Fields and behaviours are identical to Sampled with the addition of crs and mappedcrs fields.

    The mapped dimension index will be used as for Sampled, but to save in another format the underlying crs may be used to convert it.

    source

    # Rasters.Projected \u2014 Type.

    Projected <: AbstractProjected\n\nProjected(order, span, sampling, crs, mappedcrs)\nProjected(; order=AutoOrder(), span=AutoSpan(), sampling=AutoSampling(), crs, mappedcrs=nothing)\n

    An AbstractSampled LookupArray with projections attached.

    Fields and behaviours are identical to Sampled with the addition of crs and mappedcrs fields.

    If both crs and mappedcrs fields contain CRS data (in a GeoFormat wrapper from GeoFormatTypes.jl) the selector inputs and plot axes will be converted from and to the specified mappedcrs projection automatically. A common use case would be to pass mappedcrs=EPSG(4326) to the constructor when loading eg. a GDALarray:

    GDALarray(filename; mappedcrs=EPSG(4326))\n

    The underlying crs will be detected by GDAL.

    If mappedcrs is not supplied (ie. mappedcrs=nothing), the base index will be shown on plots, and selectors will need to use whatever format it is in.

    source

    # Rasters.Raster \u2014 Type.

    Raster <: AbsractRaster\n\nRaster(filepath::AbstractString, dims; kw...)\nRaster(A::AbstractArray{T,N}, dims; kw...)\nRaster(A::AbstractRaster; kw...)\n

    A generic AbstractRaster for spatial/raster array data. It may hold memory-backed arrays or FileArray, that simply holds the String path to an unopened file. This will only be opened lazily when it is indexed with getindex or when read(A) is called. Broadcasting, taking a view, reversing and most other methods do not load data from disk: they are applied later, lazily.

    Keywords

    • dims: Tuple of Dimensions for the array.
    • lazy: A Bool specifying if to load the stack lazily from disk. false by default.
    • name: Symbol name for the array, which will also retreive named layers if Raster is used on a multi-layered file like a NetCDF.
    • missingval: value reprsenting missing data, normally detected form the file. Set manually when you know the value is not specified or is incorrect. This will not change any values in the raster, it simply assigns which value is treated as missing. To replace all of the missing values in the raster, use replace_missing.
    • metadata: ArrayMetadata object for the array, or NoMetadata().
    • crs: the coordinate reference system of the objects XDim/YDim dimensions. Only set this if you know the detected crs is incrorrect, or it is not present in the file. The crs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type.
    • mappedcrs: the mapped coordinate reference system of the objects XDim/YDim dimensions. for Mapped lookups these are the actual values of the index. For Projected lookups this can be used to index in eg. EPSG(4326) lat/lon values, having it converted automatically. Only set this if the detected mappedcrs in incorrect, or the file does not have a mappedcrs, e.g. a tiff. The mappedcrs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type.
    • dropband: drop single band dimensions. true by default.

    Internal Keywords

    In some cases it is possible to set these keywords as well.

    • data: can replace the data in an AbstractRaster
    • refdims: Tuple of position Dimensions the array was sliced from, defaulting to ().

    source

    # Rasters.RasterSeries \u2014 Type.

    RasterSeries <: AbstractRasterSeries\n\nRasterSeries(rasters::AbstractArray{<:AbstractRaster}, dims; [refdims])\nRasterSeries(stacks::AbstractArray{<:AbstractRasterStack}, dims; [refdims]) \n\nRasterSeries(paths::AbstractArray{<:AbstractString}, dims; child, duplicate_first, kw...)\nRasterSeries(path:::AbstractString, dims; ext, separator, child, duplicate_first, kw...)\n

    Concrete implementation of AbstractRasterSeries.

    A RasterSeries is an array of Rasters or RasterStacks, along some dimension(s).

    Existing Raster RasterStack can be wrapped in a RasterSeries, or new files can be loaded from an array of String or from a single String.

    A single String can refer to a whole directory, or the name of a series of files in a directory, sharing a common stem. The differnce between the filenames can be used as the lookup for the series.

    For example, with some tifs at these paths :

    \"series_dir/myseries_2001-01-01T00:00:00.tif\"\n\"series_dir/myseries_2002-01-01T00:00:00.tif\"\n

    We can load a RasterSeries with a DateTime lookup:

    julia> ser = RasterSeries(\"series_dir/myseries.tif\", Ti(DateTime))\n2-element RasterSeries{Raster,1} with dimensions: \n  Ti Sampled{DateTime} DateTime[DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2002-01-01T00:00:00\")] ForwardOrdered Irregular Points\n

    The DateTime suffix is parsed from the filenames. Using Ti(Int) would try to parse integers intead.

    Just using the directory will also work, unless there are other files mixed in it:

    julia> ser = RasterSeries(\"series_dir\", Ti(DateTime))\n2-element RasterSeries{Raster,1} with dimensions: \n  Ti Sampled{DateTime} DateTime[DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2002-01-01T00:00:00\")] ForwardOrdered Irregular Points\n

    Arguments

    • dims: series dimension/s.

    Keywords

    When loading a series from a Vector of String paths or a single String path:

    • child: constructor of child objects for use when filenames are passed in, can be Raster or RasterStack. Defaults to Raster.
    • duplicate_first::Bool: wether to duplicate the dimensions and metadata of the first file with all other files. This can save load time with a large series where dimensions are identical. false by default.
    • lazy: load files lazily, false by default.
    • kw: keywords passed to the child constructor Raster or RasterStack.

    When loading a series from a single String path:

    • ext: filename extension such as \".tiff\" or \".nc\". Use to specify a subset of files if only a directory path is passed in.
    • separator: separator used to split lookup elements from the rest of a filename. '_' by default.

    Others:

    • refdims: existing reference dimension/s, normally not required.

    source

    # Rasters.RasterStack \u2014 Type.

    RasterStack <: AbstrackRasterStack\n\nRasterStack(data...; name, kw...)\nRasterStack(data::Union{Vector,Tuple}; name, kw...)\nRasterStack(data::NamedTuple; kw...))\nRasterStack(s::AbstractRasterStack; kw...)\nRasterStack(s::AbstractRaster; layersfrom=Band, kw...)\nRasterStack(filename::AbstractString; kw...)\n

    Load a file path or a NamedTuple of paths as a RasterStack, or convert arguments, a Vector or NamedTuple of Rasters to RasterStack.

    Arguments

    • data: A NamedTuple of Rasters, or a Vector, Tuple or splatted arguments of Raster. The latter options must pass a name keyword argument.
    • filename: A file (such as netcdf or tif) to be loaded as a stack, or a directory path containing multiple files.

    Keywords

    • name: Used as stack layer names when a Tuple, Vector or splat of Raster is passed in. Has no effect when NameTuple is used - the NamedTuple keys are the layer names.
    • metadata: A Dict or DimensionalData.Metadata object.
    • refdims: Tuple of Dimension that the stack was sliced from.
    • layersfrom: Dimension to source stack layers from if the file is not already multi-layered. nothing is default, so that a single RasterStack(raster) is a single layered stack. RasterStack(raster; layersfrom=Band) will use the bands as layers.
    • lazy: A Bool specifying whether to load the stack lazily from disk. false by default.
    • dropband: drop single band dimensions when creating stacks from filenames. true by default.
    files = (temp=\"temp.tif\", pressure=\"pressure.tif\", relhum=\"relhum.tif\")\nstack = RasterStack(files; mappedcrs=EPSG(4326))\nstack[:relhum][Lat(Contains(-37), Lon(Contains(144))\n

    source

    # DimensionalData.modify \u2014 Method.

    modify(f, series::AbstractRasterSeries)\n

    Apply function f to the data of the child object. If the child is an AbstractRasterStack the function will be passed on to its child AbstractRasters.

    f must return an idenically sized array.

    This method triggers a complete rebuild of all objects, and disk based objects will be transferred to memory.

    An example of the usefulnesss of this is for swapping out array backend for an entire series to CuArray from CUDA.jl to copy data to a GPU.

    source

    # Rasters.aggregate \u2014 Function.

    aggregate(method, object, scale; filename, progress, skipmissing)\n

    Aggregate a Raster, or all arrays in a RasterStack or RasterSeries, by scale using method.

    Arguments

    • method: a function such as mean or sum that can combine the value of multiple cells to generate the aggregated cell, or a Locus like Start() or Center() that specifies where to sample from in the interval.
    • object: Object to aggregate, like AbstractRasterSeries, AbstractStack, AbstractRaster or Dimension.
    • scale: the aggregation factor, which can be an integer, a tuple of integers for each dimension, or any Dimension, Selector or Int combination you can usually use in getindex. Using a Selector will determine the scale by the distance from the start of the index.

    When the aggregation scale of is larger than the array axis, the length of the axis is used.

    Keywords

    • skipmissingval: if true, any missingval will be skipped during aggregation, so that only areas of all missing values will be aggregated to missingval. If false, any aggegrated area containing a missingval will be assigned missingval.
    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.
    • progress: show a progress bar, true by default, false to hide.

    Example

    using Rasters, RasterDataSources, Statistics, Plots\nusing Rasters: Center\nst = read(RasterStack(WorldClim{Climate}; month=1))\nag = aggregate(Center(), st, (Y(20), X(20)); skipmissingval=true, progress=false)\nplot(ag)\nsavefig(\"docs/build/aggregate_example.png\"); nothing\n# output\n

    Note: currently it is faster to aggregate over memory-backed arrays. Use read on src before use where required.

    source

    # Rasters.aggregate! \u2014 Method.

    aggregate!(method, dst::AbstractRaster, src::AbstractRaster, scale; skipmissingval=false)\n

    Aggregate array src to array dst by scale, using method.

    Arguments

    • method: a function such as mean or sum that can combine the value of multiple cells to generate the aggregated cell, or a Locus like Start() or Center() that species where to sample from in the interval.
    • scale: the aggregation factor, which can be an integer, a tuple of integers for each dimension, or any Dimension, Selector or Int combination you can usually use in getindex. Using a Selector will determine the scale by the distance from the start of the index in the src array.

    When the aggregation scale of is larger than the array axis, the length of the axis is used.

    Keywords

    • progress: show a progress bar.
    • skipmissingval: if true, any missingval will be skipped during aggregation, so that only areas of all missing values will be aggregated to missingval. If false, any aggegrated area containing a missingval will be assigned missingval.

    Note: currently it is much faster to aggregate over memory-backed arrays. Use read on src before use where required.

    source

    # Rasters.boolmask \u2014 Function.

    boolmask(obj::Raster; [missingval])\nboolmask(obj; [to, res, size])\n

    Create a mask array of Bool values, from another Raster. An AbstractRasterStack or AbstractRasterSeries are also accepted, but a mask is taken of the first layer or object not all of them.

    The array returned from calling boolmask on a AbstractRaster is a Raster with the same dimensions as the original array and a missingval of false.

    Arguments

    • obj: a Raster, a GeoInterface.jl geometry, or a vector or table of geometries.

    Raster / RasterStack Keywords

    • missingval: The missing value of the source array, with default missingval(raster).

    Keywords

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.
    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.
    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • crs: a crs which will be attached to the resulting raster when to not passed or is an Extent. Otherwise the crs from to is used.
    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    • threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur.

    • progress: show a progress bar, true by default, false to hide.

    And specifically for shape=:polygon:

    • boundary: include pixels where the :center is inside the polygon, where the line :touches the pixel, or that are completely :inside inside the polygon. The default is :center.

    For tabular data, feature collections and other iterables

    • collapse: if true, collapse all geometry masks into a single mask. Otherwise return a Raster with an additional geometry dimension, so that each slice along this axis is the mask of the geometry opbject of each row of the table, feature in the feature collection, or just each geometry in the iterable.

    Example

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates\nwc = Raster(WorldClim{Climate}, :prec; month=1)\nboolmask(wc) |> plot\n\nsavefig(\"docs/build/boolmask_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.classify \u2014 Function.

    classify(x, pairs; lower=(>=), upper=(<), others=nothing)\nclassify(x, pairs...; lower, upper, others)\n

    Create a new array with values in x classified by the values in pairs.

    pairs can hold tuples fo values (2, 3), a Fix2 function e.g. <=(1), a Tuple of Fix2 e.g. (>=(4), <(7)), or an IntervalSets.jl interval, e.g. 3..9 or OpenInterval(10, 12). pairs can also be a n * 3 matrix where each row is lower bounds, upper bounds, replacement.

    If tuples or a Matrix are used, the lower and upper keywords define how the lower and upper boundaries are chosen.

    If others is set other values not covered in pairs will be set to that values.

    Arguments

    • x: a Raster or RasterStack
    • pairs: each pair contains a value and a replacement, a tuple of lower and upper range and a replacement, or a Tuple of Fix2 like (>(x), <(y).

    Keywords

    • lower: Which comparison (< or <=) to use for lower values, if Fix2 are not used.
    • upper: Which comparison (> or >=) to use for upper values, if Fix2 are not used.
    • others: A value to assign to all values not included in pairs. Passing nothing (the default) will leave them unchanged.

    Example

    using Rasters, RasterDataSources, ArchGDAL, Plots\nA = Raster(WorldClim{Climate}, :tavg; month=1)\nclasses = <=(15) => 10,\n          15..25 => 20,\n          25..35 => 30,\n          >(35) => 40\nclassified = classify(A, classes; others=0, missingval=0)\nplot(classified; c=:magma)\n\nsavefig(\"docs/build/classify_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.classify! \u2014 Method.

    classify!(x, pairs...; lower, upper, others)\nclassify!(x, pairs; lower, upper, others)\n

    Classify the values of x in-place, by the values in pairs.

    If Fix2 is not used, the lower and upper keywords

    If others is set other values not covered in pairs will be set to that values.

    Arguments

    • x: a Raster or RasterStack
    • pairs: each pair contains a value and a replacement, a tuple of lower and upper range and a replacement, or a Tuple of Fix2 like (>(x), <(y).

    Keywords

    • lower: Which comparison (< or <=) to use for lower values, if Fix2 are not used.
    • upper: Which comparison (> or >=) to use for upper values, if Fix2 are not used.
    • others: A value to assign to all values not included in pairs. Passing nothing (the default) will leave them unchanged.

    Example

    classify! to disk, with key steps:

    • copying a tempory file so we don't write over the RasterDataSources.jl version.
    • use open with write=true to open the file with disk-write permissions.
    • use Float32 like 10.0f0 for all our replacement values and other, because the file is stored as Float32. Attempting to write some other type will fail.
    using Rasters, RasterDataSources, ArchGDAL, Plots\n# Download and copy the file\nfilename = getraster(WorldClim{Climate}, :tavg; month=6)\ntempfile = tempname() * \".tif\"\ncp(filename, tempfile)\n# Define classes\nclasses = (5, 15) => 10,\n          (15, 25) => 20,\n          (25, 35) => 30,\n          >=(35) => 40\n# Open the file with write permission\nopen(Raster(tempfile); write=true) do A\n    classify!(A, classes; others=0)\nend\n# Open it again to plot the changes\nplot(Raster(tempfile); c=:magma)\n\nsavefig(\"docs/build/classify_bang_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.combine \u2014 Method.

    combine(A::Union{AbstractRaster,AbstractRasterStack,AbstracRasterSeries}, [dims]) => Raster\n

    Combine a RasterSeries along some dimension/s, creating a new Raster or RasterStack, depending on the contents of the series.

    If dims are passed, only the specified dimensions will be combined with a RasterSeries returned, unless dims is all the dims in the series.

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    <a id='Rasters.convertlookup-Tuple{Type{<:LookupArray}, AbstractDimArray}' href='#Rasters.convertlookup-Tuple{Type{<:LookupArray}, AbstractDimArray}'># Rasters.convertlookup \u2014 Method.

    convertlookup(dstlookup::Type{<:LookupArray}, x)\n

    Convert the dimension lookup between Projected and Mapped. Other dimension lookups pass through unchanged.

    This is used to e.g. save a netcdf file to GeoTiff.

    source

    # Rasters.coverage! \u2014 Method.

    coverage!(A, geom; [mode, scale])\n

    Calculate the area of a raster covered by GeoInterface.jl compatible geomtry geom, as a fraction.

    Each pixel is assigned a grid of points (by default 10 x 10) that are each checked to be inside the geometry. The sum divided by the number of points to give coverage.

    In pracice, most pixel coverage is not calculated this way - shortcuts that produce the same result are taken wherever possible.

    If geom is an AbstractVector or table, the mode keyword will determine how coverage is combined.

    Keywords

    • mode: method for combining multiple geometries - union or sum.

      • union (the default) gives the areas covered by all geometries. Usefull in spatial coverage where overlapping regions should not be counted twice. The returned raster will contain Float64 values between 0.0 and 1.0.
      • sum gives the summed total of the areas covered by all geometries, as in taking the sum of running coverage separately on all geometries. The returned values are positive Float64.

      For a single geometry, the mode keyword has no effect - the result is the same. * scale: Integer scale of pixel subdivision. The default of 10 means each pixel has 10 x 10 or 100 points that contribute to coverage. Using 100 means 10,000 points contribute. Performance will decline as scale increases. Memory use will grow by scale^2 when mode=:union. * threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur. * progress: show a progress bar, true by default, false to hide. * vebose: whether to print messages about potential problems. true by default.

    source

    # Rasters.coverage \u2014 Method.

    coverage(mode, geom; [to, res, size, scale, verbose, progress])\ncoverage(geom; [to, mode, res, size, scale, verbose, progress])\n

    Calculate the area of a raster covered by GeoInterface.jl compatible geomtry geom, as a fraction.

    Each pixel is assigned a grid of points (by default 10 x 10) that are each checked to be inside the geometry. The sum divided by the number of points to give coverage.

    In pracice, most pixel coverage is not calculated this way - shortcuts that produce the same result are taken wherever possible.

    If geom is an AbstractVector or table, the mode keyword will determine how coverage is combined.

    Keywords

    • mode: method for combining multiple geometries - union or sum.

      • union (the default) gives the areas covered by all geometries. Usefull in spatial coverage where overlapping regions should not be counted twice. The returned raster will contain Float64 values between 0.0 and 1.0.
      • sum gives the summed total of the areas covered by all geometries, as in taking the sum of running coverage separately on all geometries. The returned values are positive Float64.

      For a single geometry, the mode keyword has no effect - the result is the same. * scale: Integer scale of pixel subdivision. The default of 10 means each pixel has 10 x 10 or 100 points that contribute to coverage. Using 100 means 10,000 points contribute. Performance will decline as scale increases. Memory use will grow by scale^2 when mode=:union. * threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur. * progress: show a progress bar, true by default, false to hide. * vebose: whether to print messages about potential problems. true by default.

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.

    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.

    source

    # Rasters.crop \u2014 Function.

    crop(x; to)\ncrop(xs...; to)\n

    Crop one or multiple AbstractRaster or AbstractRasterStack x to match the size of the object to, or smallest of any dimensions that are shared.

    crop is lazy, using a view into the object rather than alocating new memory.

    Keywords

    • to: the object to crop to. If no to keyword is passed, the smallest shared area of all xs is used.
    • touches: true or false. Whether to use Touches wraper on the object extent. When lines need to be included in e.g. zonal statistics, true should be used.

    As crop is lazy, filename and suffix keywords are not used.

    Example

    Crop to another raster:

    using Rasters, RasterDataSources, Plots\nevenness = Raster(EarthEnv{HabitatHeterogeneity}, :evenness)\nrnge = Raster(EarthEnv{HabitatHeterogeneity}, :range)\n\n# Roughly cut out New Zealand from the evenness raster\nnz_bounds = X(165 .. 180), Y(-50 .. -32)\nnz_evenness = evenness[nz_bounds...]\n\n# Crop range to match evenness\nnz_range = crop(rnge; to=nz_evenness)\nplot(nz_range)\n\nsavefig(\"docs/build/nz_crop_example.png\")\nnothing\n\n# output\n

    Crop to a polygon:

    using Rasters, RasterDataSources, Plots, Dates, Shapefile, Downloads\n\n# Download a borders shapefile\nshapefile_url = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp\"\nshapefile_name = \"boundary.shp\"\nisfile(shapefile_name) || Downloads.download(shapefile_url, shapefile_name)\nshp = Shapefile.Handle(shapefile_name).shapes[6]\n\nevenness = Raster(EarthEnv{HabitatHeterogeneity}, :evenness)\nargentina_evenness = crop(evenness; to=shp)\nplot(argentina_evenness)\n\nsavefig(\"docs/build/argentina_crop_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.crs \u2014 Function.

    crs(x)\n

    Get the projected coordinate reference system of a Y or X Dimension, or of the Y/X dims of an AbstractRaster.

    For Mapped lookup this may be nothing as there may be no projected coordinate reference system at all. See setcrs to set it manually.

    source

    # Rasters.disaggregate \u2014 Function.

    disaggregate(method, object, scale; filename, progress, keys)\n

    Disaggregate array, or all arrays in a stack or series, by some scale.

    Arguments

    • method: a function such as mean or sum that can combine the value of multiple cells to generate the aggregated cell, or a Locus like Start() or Center() that species where to sample from in the interval.
    • object: Object to aggregate, like AbstractRasterSeries, AbstractStack, AbstractRaster or a Dimension.
    • scale: the aggregation factor, which can be an integer, a tuple of integers for each dimension, or any Dimension, Selector or Int combination you can usually use in getindex. Using a Selector will determine the scale by the distance from the start of the index.

    Keywords

    • progress: show a progress bar.

    Note: currently it is faster to aggregate over memory-backed arrays. Use read on src before use where required.

    source

    # Rasters.disaggregate! \u2014 Method.

    disaggregate!(method, dst::AbstractRaster, src::AbstractRaster, filename, scale)\n

    Disaggregate array src to array dst by some scale, using method.

    • method: a function such as mean or sum that can combine the value of multiple cells to generate the aggregated cell, or a Locus like Start() or Center() that species where to sample from in the interval.
    • scale: the aggregation factor, which can be an integer, a tuple of integers for each dimension, or any Dimension, Selector or Int combination you can usually use in getindex. Using a Selector will determine the scale by the distance from the start of the index in the src array.

    Note: currently it is faster to aggregate over memory-backed arrays. Use read on src before use where required.

    source

    # Rasters.extend \u2014 Function.

    extend(xs...; [to])\nextend(xs; [to])\nextend(x::Union{AbstractRaster,AbstractRasterStack}; to, kw...)\n

    Extend one or multiple AbstractRaster to match the area covered by all xs, or by the keyword argument to.

    Keywords

    • to: the Raster or dims to extend to. If no to keyword is passed, the largest shared area of all xs is used.
    • touches: true or false. Whether to use Touches wraper on the object extent. When lines need to be included in e.g. zonal statistics, true shoudle be used.
    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.
    using Rasters, RasterDataSources, Plots\nevenness = Raster(EarthEnv{HabitatHeterogeneity}, :evenness)\nrnge = Raster(EarthEnv{HabitatHeterogeneity}, :range)\n\n# Roughly cut out South America\nsa_bounds = X(-88 .. -32), Y(-57 .. 13)\nsa_evenness = evenness[sa_bounds...]\n\n# Extend range to match the whole-world raster\nsa_range = extend(sa_evenness; to=rnge)\nplot(sa_range)\n\nsavefig(\"docs/build/extend_example.png\")\nnothing\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.extract \u2014 Function.

    extract(x, geoms; atol)\n

    Extracts the value of Raster or RasterStack at given points, returning an iterable of NamedTuple with properties for :geometry and raster or stack layer values.

    Note that if objects have more dimensions than the length of the point tuples, sliced arrays or stacks will be returned instead of single values.

    Arguments

    • x: a Raster or RasterStack to extract values from.
    • geoms: GeoInterface.jl compatible geometries, or tables or iterables of geometries.

    Keywords

    • atol: a tolorerance for floating point lookup values for when the LookupArray contains Points. atol is ignored for Intervals.

    Example

    Here we extact points matching the occurrence of the Mountain Pygmy Possum, Burramis parvus. This could be used to fit a species distribution model.

    using Rasters, RasterDataSources, ArchGDAL, GBIF2, CSV\n\n# Get a stack of BioClim layers, and replace missing values with `missing`\nst = RasterStack(WorldClim{BioClim}, (1, 3, 5, 7, 12)) |> replace_missing\n\n# Download some occurrence data\nobs = GBIF2.occurrence_search(\"Burramys parvus\"; limit=5, year=\"2009\")\n\n# Convert observations to points\npnts = collect((o.decimalLongitude, o.decimalLatitude) for o in obs if !ismissing(o.decimalLongitude))\n\n# use `extract` to get values for all layers at each observation point.\n# We `collect` to get a `Vector` from the lazy iterator.\ncollect(extract(st, pnts))\n\n# output\n5-element Vector{NamedTuple{(:geometry, :bio1, :bio3, :bio5, :bio7, :bio12)}}:\n (geometry = (0.21, 40.07), bio1 = 17.077084f0, bio3 = 41.20417f0, bio5 = 30.1f0, bio7 = 24.775f0, bio12 = 446.0f0)\n (geometry = (0.03, 39.97), bio1 = 17.076923f0, bio3 = 39.7983f0, bio5 = 29.638462f0, bio7 = 24.153847f0, bio12 = 441.0f0)\n (geometry = (0.03, 39.97), bio1 = 17.076923f0, bio3 = 39.7983f0, bio5 = 29.638462f0, bio7 = 24.153847f0, bio12 = 441.0f0)\n (geometry = (0.52, 40.37), bio1 = missing, bio3 = missing, bio5 = missing, bio7 = missing, bio12 = missing)\n (geometry = (0.32, 40.24), bio1 = 16.321388f0, bio3 = 41.659454f0, bio5 = 30.029825f0, bio7 = 25.544561f0, bio12 = 480.0f0)\n

    source

    # Rasters.mappedbounds \u2014 Function.

    mappedbounds(x)\n

    Get the bounds converted to the mappedcrs value.

    Whithout ArchGDAL loaded, this is just the regular bounds.

    source

    # Rasters.mappedcrs \u2014 Function.

    mappedcrs(x)\n

    Get the mapped coordinate reference system for the Y/X dims of an array.

    In Projected lookup this is used to convert Selector values form the mappedcrs defined projection to the underlying projection, and to show plot axes in the mapped projection.

    In Mapped lookup this is the coordinate reference system of the index values. See setmappedcrs to set it manually.

    source

    # Rasters.mappedindex \u2014 Function.

    mappedindex(x)\n

    Get the index value of a dimension converted to the mappedcrs value.

    Whithout ArchGDAL loaded, this is just the regular dim value.

    source

    # Rasters.mask! \u2014 Function.

    mask!(x; with, missingval=missingval(A))\n

    Mask A by the missing values of with, or by all values outside with if it is a polygon.

    If with is a polygon, creates a new array where points falling outside the polygon have been replaced by missingval(A).

    Return a new array with values of A masked by the missing values of with, or by a polygon.

    Arguments

    • x: a Raster or RasterStack.

    Keywords

    • with: another AbstractRaster, a AbstractVector of Tuple points, or any GeoInterface.jl AbstractGeometry. The coordinate reference system of the point must match crs(A).
    • missingval: the missing value to write to A in masked areas, by default missingval(A).

    Example

    Mask an unmasked AWAP layer with a masked WorldClim layer, by first resampling the mask to match the size and projection.

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates\n\n# Load and plot the file\nawap = read(RasterStack(AWAP, (:tmin, :tmax); date=DateTime(2001, 1, 1)))\na = plot(awap; clims=(10, 45), c=:imola)\n\n# Create a mask my resampling a worldclim file\nwc = Raster(WorldClim{Climate}, :prec; month=1)\nwc_mask = resample(wc; to=awap)\n\n# Mask\nmask!(awap; with=wc_mask)\nb = plot(awap; clims=(10, 45))\n\nsavefig(a, \"docs/build/mask_bang_example_before.png\");\nsavefig(b, \"docs/build/mask_bang_example_after.png\"); nothing\n\n# output\n

    Before mask!:

    After mask!:

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.mask \u2014 Method.

    mask(A:AbstractRaster; with, missingval=missingval(A))\nmask(x; with)\n

    Return a new array with values of A masked by the missing values of with, or by the shape of with, if with is a geometric object.

    Arguments

    • x: a Raster or RasterStack

    Keywords

    • with: an AbstractRaster, or any GeoInterface.jl compatible objects or table. The coordinate reference system of the point must match crs(A).
    • missingval: the missing value to use in the returned file.
    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.

    Geometry keywords

    These can be used when with is a GeoInterface.jl compatible object:

    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    Example

    Mask an unmasked AWAP layer with a masked WorldClim layer, by first resampling the mask.

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates\n\n# Load and plot the file\nawap = read(Raster(AWAP, :tmax; date=DateTime(2001, 1, 1)))\na = plot(awap; clims=(10, 45))\n\n# Create a mask my resampling a worldclim file\nwc = Raster(WorldClim{Climate}, :prec; month=1)\nwc_mask = resample(wc; to=awap)\n\n# Mask\nawap_masked = mask(awap; with=wc_mask)\nb = plot(awap_masked; clims=(10, 45))\n\nsavefig(a, \"docs/build/mask_example_before.png\");\nsavefig(b, \"docs/build/mask_example_after.png\"); nothing\n# output\n

    Before mask:

    After mask:

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.missingmask \u2014 Method.

    missingmask(obj::Raster; kw...)\nmissingmask(obj; [to, res, size, collapse])\n

    Create a mask array of missing and true values, from another Raster. AbstractRasterStack or AbstractRasterSeries are also accepted, but a mask is taken of the first layer or object not all of them.

    For AbstractRaster the default missingval is missingval(A), but others can be chosen manually.

    The array returned from calling missingmask on a AbstractRaster is a Raster with the same size and fields as the original array.

    Keywords

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.
    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.
    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • crs: a crs which will be attached to the resulting raster when to not passed or is an Extent. Otherwise the crs from to is used.
    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    Example

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates\nwc = Raster(WorldClim{Climate}, :prec; month=1)\nmissingmask(wc) |> plot\n\nsavefig(\"docs/build/missingmask_example.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.missingval \u2014 Function.

    missingval(x)\n

    Returns the value representing missing data in the dataset

    source

    # Rasters.mosaic! \u2014 Method.

    mosaic!(f, x, regions...; missingval, atol)\nmosaic!(f, x, regions::Tuple; missingval, atol)\n

    Combine regions in x using the function f.

    Arguments

    • f a function (e.g. mean, sum, first or last) that is applied to values where regions overlap.
    • x: A Raster or RasterStack. May be a an opened disk-based Raster, the result will be written to disk. With the current algorithm, the read speed is slow.
    • regions: source objects to be joined. These should be memory-backed (use read first), or may experience poor performance. If all objects have the same extent, mosaic is simply a merge.

    Keywords

    • missingval: Fills empty areas, and defualts to the `missingval/ of the first layer.
    • atol: Absolute tolerance for comparison between index values. This is often required due to minor differences in range values due to floating point error. It is not applied to non-float dimensions. A tuple of tolerances may be passed, matching the dimension order.

    Example

    Cut out Australia and Africa stacks, then combined them into a single stack.

    using Rasters, RasterDataSources, ArchGDAL, Statistics, Plots\nst = read(RasterStack(WorldClim{Climate}; month=1))\naus = st[X=100.0 .. 160.0, Y=-50.0 .. -10.0]\nafrica = st[X=-20.0 .. 60.0, Y=-40.0 .. 35.0]\nmosaic!(first, st, aus, africa)\nplot(st)\nsavefig(\"docs/build/mosaic_bang_example.png\")\nnothing\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.mosaic \u2014 Method.

    mosaic(f, regions...; missingval, atol)\nmosaic(f, regions; missingval, atol)\n

    Combine regions into a single raster.

    Arguments

    • f: A reducing function (mean, sum, first, last etc.) for values where regions overlap.
    • regions: Iterable or splatted Raster or RasterStack.

    Keywords

    • missingval: Fills empty areas, and defualts to the missingval of the first region.
    • atol: Absolute tolerance for comparison between index values. This is often required due to minor differences in range values due to floating point error. It is not applied to non-float dimensions. A tuple of tolerances may be passed, matching the dimension order.
    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.

    If your mosaic has has apparent line errors, increase the atol value.

    Example

    Here we cut out Australia and Africa from a stack, and join them with mosaic.

    using Rasters, RasterDataSources, ArchGDAL, Plots\nst = RasterStack(WorldClim{Climate}; month=1);\n\nafrica = st[X(-20.0 .. 60.0), Y(-40.0 .. 35.0)]\na = plot(africa)\n\naus = st[X(100.0 .. 160.0), Y(-50.0 .. -10.0)]\nb = plot(aus)\n\n# Combine with mosaic\nmos = mosaic(first, aus, africa)\nc = plot(mos)\n\nsavefig(a, \"docs/build/mosaic_example_africa.png\")\nsavefig(b, \"docs/build/mosaic_example_aus.png\")\nsavefig(c, \"docs/build/mosaic_example_combined.png\")\nnothing\n# output\n

    Individual continents

    Mosaic of continents

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.points \u2014 Method.

    points(A::AbstractRaster; dims=(YDim, XDim), ignore_missing) => Array{Tuple}\n

    Returns a generator of the points in A for dimensions in dims, where points are a tuple of the values in each specified dimension index.

    Keywords

    • dims the dimensions to return points from. The first slice of other layers will be used.
    • ignore_missing: wether to ignore missing values in the array when considering points. If true, all points in the dimensions will be returned, if false only the points that are not === missingval(A) will be returned.

    The order of dims determines the order of the points.

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.rasterize \u2014 Function.

    rasterize([reducer], data; kw...)\n

    Rasterize a GeoInterface.jl compatable geometry or feature, or a Tables.jl table with a :geometry column of GeoInterface.jl objects, or X, Y points columns.

    Arguments

    • reducer: a reducing function to reduce the fill value for all geometries that cover or touch a pixel down to a single value. The default is last. Any that takes an iterable and returns a single value will work, including custom functions. However, there are optimisations for built-in methods including sum, first, last, minimum, maximum, extrema and Statistics.mean. These may be an order of magnitude or more faster than count is a special-cased as it does not need a fill value.
    • data: a GeoInterface.jl AbstractGeometry, or a nested Vector of AbstractGeometry, or a Tables.jl compatible object containing a :geometry column or points and values columns.

    Keywords

    These are detected automatically from data where possible.

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.
    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.
    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • crs: a crs which will be attached to the resulting raster when to not passed or is an Extent. Otherwise the crs from to is used.
    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    • fill: the value or values to fill a polygon with. A Symbol or tuple of Symbol will be used to retrieve properties from features or column values from table rows. An array or other iterable will be used for each geometry, in order. fill can also be a function of the current value, e.g. x -> x + 1.

    • op: A reducing function that accepts two values and returns one, like min to minimum. For common methods this will be assigned for you, or is not required. But you can use it instead of a reducer as it will usually be faster.
    • shape: force data to be treated as :polygon, :line or :point, where possible Points can't be treated as lines or polygons, and lines may not work as polygons, but an attempt will be made.
    • geometrycolumn: Symbol to manually select the column the geometries are in when data is a Tables.jl compatible table, or a tuple of Symbol for columns of point coordinates.
    • progress: show a progress bar, true by default, false to hide..
    • verbose: print information and warnings whne there are problems with the rasterisation. true by default.
    • threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur.

    • filename: a filename to write to directly, useful for large files.

    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.

    Example

    Rasterize a shapefile for China and plot, with a border.

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates, Shapefile, Downloads\nusing Rasters.LookupArrays\n\n# Download a borders shapefile\nshapefile_url = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp\"\nshapefile_name = \"country_borders.shp\"\nisfile(shapefile_name) || Downloads.download(shapefile_url, shapefile_name)\n\n# Load the shapes for china\nchina_border = Shapefile.Handle(shapefile_name).shapes[10]\n\n# Rasterize the border polygon\nchina = rasterize(last, china_border; res=0.1, missingval=0, fill=1, boundary=:touches, progress=false)\n\n# And plot\np = plot(china; color=:spring, legend=false)\nplot!(p, china_border; fillalpha=0, linewidth=0.6)\n\nsavefig(\"docs/build/china_rasterized.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.rasterize! \u2014 Function.

    rasterize!([reducer], dest, data; kw...)\n

    Rasterize the geometries in data into the Raster or RasterStack dest, using the values specified by fill.

    Arguments

    • dest: a Raster or RasterStack to rasterize into.
    • reducer: a reducing function to reduce the fill value for all geometries that cover or touch a pixel down to a single value. The default is last. Any that takes an iterable and returns a single value will work, including custom functions. However, there are optimisations for built-in methods including sum, first, last, minimum, maximum, extrema and Statistics.mean. These may be an order of magnitude or more faster than count is a special-cased as it does not need a fill value.
    • data: a GeoInterface.jl AbstractGeometry, or a nested Vector of AbstractGeometry, or a Tables.jl compatible object containing a :geometry column or points and values columns.

    Keywords

    These are detected automatically from A and data where possible.

    • fill: the value or values to fill a polygon with. A Symbol or tuple of Symbol will be used to retrieve properties from features or column values from table rows. An array or other iterable will be used for each geometry, in order. fill can also be a function of the current value, e.g. x -> x + 1.
    • op: A reducing function that accepts two values and returns one, like min to minimum. For common methods this will be assigned for you, or is not required. But you can use it instead of a reducer as it will usually be faster.
    • shape: force data to be treated as :polygon, :line or :point, where possible Points can't be treated as lines or polygons, and lines may not work as polygons, but an attempt will be made.
    • geometrycolumn: Symbol to manually select the column the geometries are in when data is a Tables.jl compatible table, or a tuple of Symbol for columns of point coordinates.
    • progress: show a progress bar, true by default, false to hide..
    • verbose: print information and warnings whne there are problems with the rasterisation. true by default.
    • threaded: run operations in parallel, false by default. In some circumstances threaded can give large speedups over single-threaded operation. This can be true for complicated geometries written into low-resolution rasters, but may not be for simple geometries with high-resolution rasters. With very large rasters threading may be counter productive due to excessing memory use. Caution should also be used: threaded should not be used in in-place functions wrinting to BitArray or other arrays where race conditions can occur.

    • to: a Raster, RasterStack, Tuple of Dimension or Extents.Extent. If no to object is provided the extent will be calculated from the geometries, Additionally, when no to object or an Extent is passed for to, the size or res keyword must also be used.

    • res: the resolution of the dimensions, a Real or Tuple{<:Real,<:Real}. Only required when to is not used or is an Extents.Extent, and size is not used.
    • size: the size of the output array, as a Tuple{Int,Int} or single Int for a square. Only required when to is not used or is an Extents.Extent, and res is not used.
    • crs: a crs which will be attached to the resulting raster when to not passed or is an Extent. Otherwise the crs from to is used.
    • shape: Force data to be treated as :polygon, :line or :point geometries. using points or lines as polygons may have unexpected results.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the polygon :touches the pixel, or that are completely :inside the polygon. The default is :center.

    Example

    using Rasters, RasterDataSources, ArchGDAL, Plots, Dates, Shapefile, GeoInterface, Downloads\nusing Rasters.LookupArrays\n\n# Download a borders shapefile\nshapefile_url = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp\"\nshapefile_name = \"country_borders.shp\"\nisfile(shapefile_name) || Downloads.download(shapefile_url, shapefile_name)\n\n# Load the shapes for indonesia\nindonesia_border = Shapefile.Handle(shapefile_name).shapes[1]\n\n# Make an empty EPSG 4326 projected Raster of the area of Indonesia\ndimz = X(Projected(90.0:0.1:145; sampling=Intervals(), crs=EPSG(4326))),\n       Y(Projected(-15.0:0.1:10.9; sampling=Intervals(), crs=EPSG(4326)))\n\nA = zeros(UInt32, dimz; missingval=UInt32(0))\n\n# Rasterize each indonesian island with a different number. The islands are\n# rings of a multi-polygon, so we use `GI.getring` to get them all separately.\nislands = collect(GeoInterface.getring(indonesia_border))\nrasterize!(last, A, islands; fill=1:length(islands), progress=false)\n\n# And plot\np = plot(Rasters.trim(A); color=:spring)\nplot!(p, indonesia_border; fillalpha=0, linewidth=0.7)\n\nsavefig(\"docs/build/indonesia_rasterized.png\"); nothing\n\n# output\n

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.replace_missing \u2014 Method.

    replace_missing(a::AbstractRaster, newmissingval)\nreplace_missing(a::AbstractRasterStack, newmissingval)\n

    Replace missing values in the array or stack with a new missing value, also updating the missingval field/s.

    Keywords

    • filename: a filename to write to directly, useful for large files.
    • suffix: a string or value to append to the filename. A tuple of suffix will be applied to stack layers. keys(stack) are the default.

    Example

    using Rasters, RasterDataSources, ArchGDAL\nA = Raster(WorldClim{Climate}, :prec; month=1) |> replace_missing\nmissingval(A)\n# output\nmissing\n

    source

    # Rasters.reproject \u2014 Method.

    reproject(source::GeoFormat, target::GeoFormat, dim::Dimension, val)\n

    reproject uses ArchGDAL.reproject, but implemented for a reprojecting a value array of values, a single dimension at a time.

    source

    # Rasters.reproject \u2014 Method.

    reproject(target::GeoFormat, x)\n

    Reproject the dimensions of x to a different crs.

    Arguments

    • target: any crs in a GeoFormatTypes.jl wrapper, e.g. EPSG, WellKnownText, ProjString.
    • x: a Dimension, Tuple of Dimension, Raster or RasterStack.

    Dimensions without an AbstractProjected lookup (such as a Ti dimension) are silently returned without modification.

    source

    # Rasters.setcrs \u2014 Method.

    setcrs(x, crs)\n

    Set the crs of a Raster, RasterStack, Tuple of Dimension, or a Dimension. The crs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type

    source

    # Rasters.setmappedcrs \u2014 Method.

    setmappedcrs(x, crs)\n

    Set the mapped crs of a Raster, a RasterStack, a Tuple of Dimension, or a Dimension. The crs is expected to be a GeoFormatTypes.jl CRS or Mixed GeoFormat type

    source

    # Rasters.slice \u2014 Method.

    slice(A::Union{AbstractRaster,AbstractRasterStack,AbstracRasterSeries}, dims) => RasterSeries\n

    Slice views along some dimension/s to obtain a RasterSeries of the slices.

    For a Raster or RasterStack this will return a RasterSeries of Raster or RasterStack that are slices along the specified dimensions.

    For a RasterSeries, the output is another series where the child objects are sliced and the series dimensions index is now of the child dimensions combined. slice on a RasterSeries with no dimensions will slice along the dimensions shared by both the series and child object.

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.trim \u2014 Method.

    trim(x; dims::Tuple, pad::Int)\n

    Trim missingval(x) from x for axes in dims, returning a view of x.

    Arguments

    • x: A Raster or RasterStack. For stacks, all layers must having missing values for a pixel for it to be trimmed.

    Keywords

    • dims: By default dims=(XDim, YDim), so that trimming keeps the area of X and Y that contains non-missing values along all other dimensions.
    • pad: The trimmed size will be padded by pad on all sides, although padding will not be added beyond the original extent of the array.

    As trim is lazy, filename and suffix keywords are not used.

    Example

    Create trimmed layers of Australian habitat heterogeneity.

    using Rasters, RasterDataSources, Plots\nlayers = (:evenness, :range, :contrast, :correlation)\nst = RasterStack(EarthEnv{HabitatHeterogeneity}, layers)\n\n# Roughly cut out australia\nausbounds = X(100 .. 160), Y(-50 .. -10)\naus = st[ausbounds...]\na = plot(aus)\n\n# Trim missing values and plot\nb = plot(trim(aus))\n\nsavefig(a, \"docs/build/trim_example_before.png\");\nsavefig(b, \"docs/build/trim_example_after.png\"); nothing\n\n# output\n

    Before trim:

    After trim:

    WARNING: This feature is experimental. It may change in future versions, and may not be 100% reliable in all cases. Please file github issues if problems occur.

    source

    # Rasters.zonal \u2014 Method.

    zonal(f, x::Union{Raster,RasterStack}; of, kw...)\n

    Calculate zonal statistics for the the zone of a Raster or RasterStack covered by the of object/s.

    Arguments

    • f: any function that reduces an iterable to a single value, such as sum or Statistics.mean
    • x: A Raster or RasterStack
    • of: A Raster, RasterStack, dim tuple, extent, GeoInterface.jl compatible geometry, Tables.jl compatible table of a :geometry column, or an AbstractVector of any of these objects..

    Keywords

    These can be used when of is a GeoInterface.jl compatible object:

    • shape: Force data to be treated as :polygon, :line or :point, where possible.
    • boundary: for polygons, include pixels where the :center is inside the polygon, where the line :touches the pixel, or that are completely :inside inside the polygon. The default is :center.
    • progress: show a progress bar, true by default, false to hide..

    Example

    ``jldoctest using Rasters, RasterDataSources, ArchGDAL, Shapefile, DataFrames, Downloads, Statistics, Dates

    Download a borders shapefile

    neurl = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10mcultural/ne10madmin0countries\" shpurl, dbfurl = neurl * \".shp\", neurl * \".dbf\" shpname, dbfname = \"countryborders.shp\", \"countryborders.dbf\" isfile(shpname) || Downloads.download(shpurl, shpname) isfile(dbfurl) || Downloads.download(dbfurl, dbfname)

    Download and read a raster stack from WorldClim

    st = RasterStack(WorldClim{Climate}; month=Jan, lazy=false)

    Load the shapes for world countries

    countries = Shapefile.Table(shp_name) |> DataFrame

    Calculate the january mean of all climate variables for all countries

    january_stats = zonal(mean, st; of=countries, boundary=:touches, progress=false) |> DataFrame

    Add the country name column (natural earth has some string errors it seems)

    insertcols!(january_stats, 1, :country => first.(split.(countries.ADMIN, r\"[^A-Za-z ]\")))

    output

    258\u00d78 DataFrame Row \u2502 country tmin tmax tavg prec \u22ef \u2502 SubStrin\u2026 Float32 Float32 Float32 Float64 \u22ef \u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 1 \u2502 Indonesia 21.5447 29.1864 25.3656 271.063 \u22ef 2 \u2502 Malaysia 21.3087 28.4291 24.8688 273.381 3 \u2502 Chile 7.24534 17.9263 12.5858 78.1287 4 \u2502 Bolivia 17.2065 27.7454 22.4759 192.542 5 \u2502 Peru 15.0273 25.5504 20.2888 180.007 \u22ef 6 \u2502 Argentina 13.6751 27.6715 20.6732 67.1837 7 \u2502 Dhekelia Sovereign Base Area 5.87126 15.8991 10.8868 76.25 8 \u2502 Cyprus 5.65921 14.6665 10.1622 97.4474 \u22ee \u2502 \u22ee \u22ee \u22ee \u22ee \u22ee \u22f1 252 \u2502 Spratly Islands 25.0 29.2 27.05 70.5 \u22ef 253 \u2502 Clipperton Island 21.5 33.2727 27.4 6.0 254 \u2502 Macao S 11.6694 17.7288 14.6988 28.0 255 \u2502 Ashmore and Cartier Islands NaN NaN NaN NaN 256 \u2502 Bajo Nuevo Bank NaN NaN NaN NaN \u22ef 257 \u2502 Serranilla Bank NaN NaN NaN NaN 258 \u2502 Scarborough Reef NaN NaN NaN NaN 3 columns and 243 rows omitted ```

    source

    "},{"location":"reference/#reference-internal-functions","title":"Reference - Internal functions","text":"

    # Rasters.AbstractProjected \u2014 Type.

    AbstractProjected <: AbstractSampled\n

    Abstract supertype for projected index lookups.

    source

    # Rasters.FileArray \u2014 Type.

    FileArray{X} <: DiskArrays.AbstractDiskArray\n

    Filearray is a DiskArrays.jl AbstractDiskArray. Instead of holding an open object, it just holds a filename string that is opened lazily when it needs to be read.

    source

    # Rasters.FileStack \u2014 Type.

    FileStack{X,K}\n\nFileStack{X,K}(filename, types, sizes, eachchunk, haschunks, write)\n

    A wrapper object that holds file pointer and size/chunking metadata for a multi-layered stack stored in a single file, typically netcdf or hdf5.

    X is a backend type like NCDsource, and K is a tuple of Symbol keys.

    source

    # Rasters.OpenStack \u2014 Type.

    OpenStack{X,K}\n\nOpenStack{X,K}(dataset)\n

    A wrapper for any stack-like opened dataset that can be indexed with Symbol keys to retrieve AbstractArray layers.

    OpenStack is usually hidden from users, wrapped in a regular RasterStack passed as the function argument in open(stack) when the stack is contained in a single file.

    X is a backend type like NCDsource, and K is a tuple of Symbol keys.

    source

    # Rasters.RasterDiskArray \u2014 Type.

    RasterDiskArray <: DiskArrays.AbstractDiskArray\n

    A basic DiskArrays.jl wrapper for objects that don't have one defined yet. When we open a FileArray it is replaced with a RasterDiskArray.

    source

    # Base.open \u2014 Method.

    open(f, A::AbstractRaster; write=false)\n

    open is used to open any lazy=true AbstractRaster and do multiple operations on it in a safe way. The write keyword opens the file in write lookup so that it can be altered on disk using e.g. a broadcast.

    f is a method that accepts a single argument - an Raster object which is just an AbstractRaster that holds an open disk-based object. Often it will be a do block:

    lazy=false (in-memory) rasters will ignore open and pass themselves to f.

    # A is an `Raster` wrapping the opened disk-based object.\nopen(Raster(filepath); write=true) do A\n    mask!(A; with=maskfile)\n    A[I...] .*= 2\n    # ...  other things you need to do with the open file\nend\n

    By using a do block to open files we ensure they are always closed again after we finish working with them.

    source

    # Base.read! \u2014 Method.

    read!(src::Union{AbstractString,AbstractRaster}, dst::AbstractRaster)\nread!(src::Union{AbstractString,AbstractRasterStack}, dst::AbstractRasterStack)\nread!(scr::AbstractRasterSeries, dst::AbstractRasterSeries)\n

    read! will copy the data from src to the object dst.

    src can be an object or a file-path String.

    source

    # Base.read \u2014 Method.

    read(A::AbstractRaster)\nread(A::AbstractRasterStack)\nread(A::AbstractRasterSeries)\n

    read will move a Rasters.jl object completely to memory.

    source

    # Base.skipmissing \u2014 Method.

    skipmissing(itr::Raster)\n

    Returns an iterable over the elements in a Raster object, skipping any values equal to either the missingval or missing.

    source

    # Base.write \u2014 Method.

    Base.write(filepath::AbstractString, s::AbstractRasterSeries; kw...)\n

    Write any AbstractRasterSeries to file, guessing the backend from the file extension.

    The lookup values of the series will be appended to the filepath (before the extension), separated by underscores.

    Keywords

    See other docs for write. All keywords are passed through to Raster and RasterStack methods.

    source

    # Base.write \u2014 Method.

    Base.write(filename::AbstractString, s::AbstractRasterStack; suffix, kw...)\n

    Write any AbstractRasterStack to file, guessing the backend from the file extension.

    Keywords

    • suffix: suffix to append to file names. By default the layer key is used.

    Other keyword arguments are passed to the write method for the backend.

    If the source can't be saved as a stack-like object, individual array layers will be saved.

    source

    # Base.write \u2014 Method.

    Base.write(filename::AbstractString, A::AbstractRaster; kw...)\n

    Write an AbstractRaster to file, guessing the backend from the file extension.

    Keyword arguments are passed to the write method for the backend.

    source

    # Base.write \u2014 Method.

    Base.write(filename::AbstractString, ::Type{GRDsource}, s::AbstractRaster; force=false)\n

    Write a Raster to a .grd file with a .gri header file. The extension of filename will be ignored.

    Returns filename.

    source

    "},{"location":"scripts/generated/basics/array_operations/","title":"Arrays operations","text":"

    Most base methods work as for regular julia Arrays, such as reverse and rotations like rotl90. Base, statistics and linear algebra methods like mean that take a dims argument can also use the dimension name.

    "},{"location":"scripts/generated/basics/array_operations/#mean-over-the-time-dimension","title":"Mean over the time dimension:","text":"
    using Rasters, Statistics, RasterDataSources\n\nA = Raster(WorldClim{BioClim}, 5)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n           89.8333  89.6667  89.5     \u2026  -89.6667  -89.8333  -90.0\n -180.0    -3.4f38  -3.4f38  -3.4f38     -15.399   -13.805   -14.046\n -179.833  -3.4f38  -3.4f38  -3.4f38     -15.9605  -14.607   -14.5545\n -179.667  -3.4f38  -3.4f38  -3.4f38     -15.971   -14.612   -14.5685\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -3.4f38  -3.4f38  -3.4f38     -18.2955  -16.7583  -16.72\n  179.667  -3.4f38  -3.4f38  -3.4f38     -18.2847  -16.7513  -16.72\n  179.833  -3.4f38  -3.4f38  -3.4f38     -17.1478  -15.4243  -15.701\n

    Then we do the meand over the X dimension

    mean(A, dims=X) # Ti if time were available would also be possible\n
    1\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} -180.0:360.0:-180.0 ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 180.0), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n          89.8333   89.6667   89.5   89.3333  \u2026  -89.6667  -89.8333  -90.0\n -180.0  -Inf      -Inf      -Inf   -Inf         -23.0768  -22.9373  -22.0094\n

    broadcast works lazily from disk when lazy=true, and is only applied when data is directly indexed. Adding a dot to any function will use broadcast over a Raster just like an Array.

    "},{"location":"scripts/generated/basics/array_operations/#broadcasting","title":"Broadcasting","text":"

    For a disk-based array A, this will only be applied when indexing occurs or when we read the array.

    A .*= 2\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n            89.8333   89.6667   89.5  \u2026  -89.6667  -89.8333  -90.0\n -180.0    -Inf      -Inf      -Inf      -30.798   -27.61    -28.092\n -179.833  -Inf      -Inf      -Inf      -31.921   -29.214   -29.109\n -179.667  -Inf      -Inf      -Inf      -31.942   -29.224   -29.137\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -Inf      -Inf      -Inf      -36.591   -33.5165  -33.44\n  179.667  -Inf      -Inf      -Inf      -36.5695  -33.5025  -33.44\n  179.833  -Inf      -Inf      -Inf      -34.2955  -30.8485  -31.402\n

    To broadcast directly to disk, we need to open the file in write mode:

    open(Raster(filename); write=true) do O\n   O .*= 2\nend\n

    To broadcast over a RasterStack use map, which applies a function to the raster layers of the stack.

    newstack = map(stack) do raster\n   raster .* 2\nend\n

    "},{"location":"scripts/generated/basics/array_operations/#modifying-object-properties","title":"Modifying object properties","text":"

    rebuild can be used to modify the fields of an object, generating a new object (but possibly holding the same arrays or files).

    If you know that a file had an incorrectly specified missing value, you can do:

    "},{"location":"scripts/generated/basics/array_operations/#rebuild","title":"rebuild","text":"
    A = Raster(WorldClim{BioClim}, 5)\nrebuild(A; missingval=-9999)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -9999crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n           89.8333  89.6667  89.5     \u2026  -89.6667  -89.8333  -90.0\n -180.0    -3.4f38  -3.4f38  -3.4f38     -15.399   -13.805   -14.046\n -179.833  -3.4f38  -3.4f38  -3.4f38     -15.9605  -14.607   -14.5545\n -179.667  -3.4f38  -3.4f38  -3.4f38     -15.971   -14.612   -14.5685\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -3.4f38  -3.4f38  -3.4f38     -18.2955  -16.7583  -16.72\n  179.667  -3.4f38  -3.4f38  -3.4f38     -18.2847  -16.7513  -16.72\n  179.833  -3.4f38  -3.4f38  -3.4f38     -17.1478  -15.4243  -15.701\n

    (replace_missing will actualy replace the current values).

    Or if you need to change the name of the layer:

    Then use rebuild as

    B = rebuild(A; name=:temperature)\nB.name\n
    :temperature\n

    "},{"location":"scripts/generated/basics/array_operations/#replace_missing","title":"replace_missing","text":"
    replace_missing(A, missingval=-9999)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -9999.0f0crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n              89.8333     89.6667     89.5  \u2026  -89.6667  -89.8333  -90.0\n -180.0    -9999.0     -9999.0     -9999.0     -15.399   -13.805   -14.046\n -179.833  -9999.0     -9999.0     -9999.0     -15.9605  -14.607   -14.5545\n -179.667  -9999.0     -9999.0     -9999.0     -15.971   -14.612   -14.5685\n    \u22ee                                       \u22f1              \u22ee       \n  179.5    -9999.0     -9999.0     -9999.0     -18.2955  -16.7583  -16.72\n  179.667  -9999.0     -9999.0     -9999.0     -18.2847  -16.7513  -16.72\n  179.833  -9999.0     -9999.0     -9999.0     -17.1478  -15.4243  -15.701\n
    "},{"location":"scripts/generated/basics/array_operations/#set","title":"set","text":"

    set can be used to modify the nested properties of an objects dimensions, that are more difficult to change with rebuild. set works on the principle that dimension properties can only be in one specific field, so we generally don't have to specify which one it is. set will also try to update anything affected by a change you make.

    This will set the X axis to specify points, instead of intervals:

    using Rasters: Points\nset(A, X => Points)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Points crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (-180.0, 179.83333333333331), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n           89.8333  89.6667  89.5     \u2026  -89.6667  -89.8333  -90.0\n -180.0    -3.4f38  -3.4f38  -3.4f38     -15.399   -13.805   -14.046\n -179.833  -3.4f38  -3.4f38  -3.4f38     -15.9605  -14.607   -14.5545\n -179.667  -3.4f38  -3.4f38  -3.4f38     -15.971   -14.612   -14.5685\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -3.4f38  -3.4f38  -3.4f38     -18.2955  -16.7583  -16.72\n  179.667  -3.4f38  -3.4f38  -3.4f38     -18.2847  -16.7513  -16.72\n  179.833  -3.4f38  -3.4f38  -3.4f38     -17.1478  -15.4243  -15.701\n

    We can also reassign dimensions, here X becomes Z:

    set(A, X => Z)\n
    2160\u00d71080 Raster{Float32,2} bio5 with dimensions: \n  Z Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(Z = (-180.0, 179.99999999999997), Y = (-90.0, 90.0))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n           89.8333  89.6667  89.5     \u2026  -89.6667  -89.8333  -90.0\n -180.0    -3.4f38  -3.4f38  -3.4f38     -15.399   -13.805   -14.046\n -179.833  -3.4f38  -3.4f38  -3.4f38     -15.9605  -14.607   -14.5545\n -179.667  -3.4f38  -3.4f38  -3.4f38     -15.971   -14.612   -14.5685\n    \u22ee                                 \u22f1              \u22ee       \n  179.5    -3.4f38  -3.4f38  -3.4f38     -18.2955  -16.7583  -16.72\n  179.667  -3.4f38  -3.4f38  -3.4f38     -18.2847  -16.7513  -16.72\n  179.833  -3.4f38  -3.4f38  -3.4f38     -17.1478  -15.4243  -15.701\n

    setcrs(A, crs) and setmappedcrs(A, crs) will set the crs value/s of an object to any GeoFormat from GeoFormatTypes.jl.

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/data_sources/","title":"Data Sources","text":""},{"location":"scripts/generated/basics/data_sources/#data-sources","title":"Data sources","text":"

    Rasters.jl uses a number of backends to load raster data. Raster, RasterStack and RasterSeries will detect which backend to use for you, automatically.

    "},{"location":"scripts/generated/basics/data_sources/#grd","title":"GRD","text":"

    R GRD files can be loaded natively, using Julias MMap - which means they are very fast, but are not compressed. They are always 3 dimensional, and have Y, X and Band dimensions.

    "},{"location":"scripts/generated/basics/data_sources/#netcdf","title":"NetCDF","text":"

    NetCDF .nc files are loaded using NCDatasets.jl. Layers from files can be loaded as Raster(\"filename.nc\"; key=:layername). Without key the first layer is used. RasterStack(\"filename.nc\") will use all netcdf variables in the file that are not dimensions as layers.

    NetCDF layers can have arbitrary dimensions. Known, common dimension names are converted to X, Y Z, and Ti, otherwise Dim{:layername} is used. Layers in the same file may also have different dimensions.

    NetCDF files still have issues loading directly from disk for some operations. Using read(ncstack) may help.

    "},{"location":"scripts/generated/basics/data_sources/#gdal","title":"GDAL","text":"

    All files GDAL can access, such as .tiff and .asc files, can be loaded, using ArchGDAL.jl. These are generally best loaded as Raster(\"filename.tif\"), but can be loaded as RasterStack(\"filename.tif\"; layersfrom=Band), taking layers from the Band dimension, which is also the default.

    "},{"location":"scripts/generated/basics/data_sources/#smap","title":"SMAP","text":"

    The Soil Moisture Active-Passive dataset provides global layers of soil moisture, temperature and other related data, in a custom HDF5 format. Layers are always 2 dimensional, with Y and X dimensions.

    These can be loaded as multi-layered RasterStack(\"filename.h5\"). Individual layers can be loaded as Raster(\"filename.h5\"; key=:layerkey), without key the first layer is used.

    # Rasters.smapseries \u2014 Function.

    smapseries(filenames::AbstractString; kw...)\nsmapseries(filenames::Vector{<:AbstractString}, dims=nothing; kw...)\n

    RasterSeries loader for SMAP files and whole folders of files, organised along the time dimension. Returns a RasterSeries.

    Arguments

    • filenames: A String path to a directory of SMAP files, or a vector of String paths to specific files.
    • dims: Tuple containing Ti dimension for the series. Automatically generated form filenames unless passed in.

    Keywords

    • kw: Passed to RasterSeries.

    source

    "},{"location":"scripts/generated/basics/data_sources/#writing-file-formats-to-disk","title":"Writing file formats to disk","text":"

    Files can be written to disk in all formats other than SMAP HDF5 using write(\"filename.ext\", A). See the docs for write. They can (with some caveats) be written to different formats than they were loaded in as, providing file-type conversion for spatial data.

    Some metadata may be lost in formats that store little metadata, or where metadata conversion has not been completely implemented.

    "},{"location":"scripts/generated/basics/data_sources/#rasterdatasourcesjl-integration","title":"RasterDataSources.jl integration","text":"

    RasterDataSources.jl standardises the download of common raster data sources, with a focus on datasets used in ecology and the environmental sciences. RasterDataSources.jl is tightly integrated into Rasters.jl, so that datsets and keywords can be used directly to download and load data as a Raster, RasterStack, or RasterSeries.

    using Rasters, CairoMakie, Dates\nusing RasterDataSources\nA = Raster(WorldClim{Climate}, :tavg; month=June)\nMakie.plot(A)\n

    See the docs for Raster, RasterStack and RasterSeries, and the docs for RasterDataSources.getraster for syntax to specify various data sources.

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/first_raster/","title":"Quick start","text":"

    Quick start

    Install the package by typing:

    ]\nadd Rasters\n

    then do

    using Rasters\n

    Using Rasters to read GeoTiff or NetCDF files will output something similar to the following toy examples. This is possible because Rasters.jl extends DimensionalData.jl so that spatial data can be indexed using named dimensions like X, Y and Ti (time) and e.g. spatial coordinates.

    using Rasters, Dates\n\nlon, lat = X(25:1:30), Y(25:1:30)\nti = Ti(DateTime(2001):Month(1):DateTime(2002))\nras = Raster(rand(lon, lat, ti)) # this generates random numbers with the dimensions given\n
    6\u00d76\u00d713 Raster{Float64,3} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2002-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2002-01-01T00:00:00\")))missingval: missingparent:\n[:, :, 1]\n     25         26         27         28         29         30\n 25   0.429008   0.93986    0.971662   0.430087   0.682266   0.535061\n 26   0.145596   0.898459   0.443608   0.443415   0.915046   0.662115\n 27   0.563926   0.831003   0.407218   0.406627   0.660327   0.0124977\n 28   0.201234   0.262332   0.399131   0.882657   0.743907   0.493154\n 29   0.202371   0.898827   0.317586   0.5708     0.307101   0.694126\n 30   0.404285   0.818468   0.917196   0.286121   0.268186   0.407958\n[and 12 more slices...]\n

    "},{"location":"scripts/generated/basics/first_raster/#getting-the-lookup-array-from-dimensions","title":"Getting the lookup array from dimensions","text":"
    lon = lookup(ras, X) # if X is longitude\nlat = lookup(ras, Y) # if Y is latitude\n
    Sampled{Int64} ForwardOrdered Regular Points\nwrapping: 25:1:30\n
    "},{"location":"scripts/generated/basics/first_raster/#select-by-index","title":"Select by index","text":"

    Selecting a time slice by index is done via

    ras[Ti(1)]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))missingval: missingparent:\n     25         26         27         28         29         30\n 25   0.429008   0.93986    0.971662   0.430087   0.682266   0.535061\n 26   0.145596   0.898459   0.443608   0.443415   0.915046   0.662115\n 27   0.563926   0.831003   0.407218   0.406627   0.660327   0.0124977\n 28   0.201234   0.262332   0.399131   0.882657   0.743907   0.493154\n 29   0.202371   0.898827   0.317586   0.5708     0.307101   0.694126\n 30   0.404285   0.818468   0.917196   0.286121   0.268186   0.407958\n

    also

    ras[Ti=1]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))missingval: missingparent:\n     25         26         27         28         29         30\n 25   0.429008   0.93986    0.971662   0.430087   0.682266   0.535061\n 26   0.145596   0.898459   0.443608   0.443415   0.915046   0.662115\n 27   0.563926   0.831003   0.407218   0.406627   0.660327   0.0124977\n 28   0.201234   0.262332   0.399131   0.882657   0.743907   0.493154\n 29   0.202371   0.898827   0.317586   0.5708     0.307101   0.694126\n 30   0.404285   0.818468   0.917196   0.286121   0.268186   0.407958\n

    or and interval of indices using the syntax =a:b or (a:b)

    ras[Ti(1:10)]\n
    6\u00d76\u00d710 Raster{Float64,3} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-10-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30), Ti = (DateTime(\"2001-01-01T00:00:00\"), DateTime(\"2001-10-01T00:00:00\")))missingval: missingparent:\n[:, :, 1]\n     25         26         27         28         29         30\n 25   0.429008   0.93986    0.971662   0.430087   0.682266   0.535061\n 26   0.145596   0.898459   0.443608   0.443415   0.915046   0.662115\n 27   0.563926   0.831003   0.407218   0.406627   0.660327   0.0124977\n 28   0.201234   0.262332   0.399131   0.882657   0.743907   0.493154\n 29   0.202371   0.898827   0.317586   0.5708     0.307101   0.694126\n 30   0.404285   0.818468   0.917196   0.286121   0.268186   0.407958\n[and 9 more slices...]\n

    "},{"location":"scripts/generated/basics/first_raster/#select-by-value","title":"Select by value","text":"
    ras[Ti=At(DateTime(2001))]\n
    6\u00d76 Raster{Float64,2} with dimensions: \n  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,\n  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points\nand reference dimensions: \n  Ti Sampled{DateTime} DateTime(\"2001-01-01T00:00:00\"):Month(1):DateTime(\"2001-01-01T00:00:00\") ForwardOrdered Regular Points\nextent: Extent(X = (25, 30), Y = (25, 30))missingval: missingparent:\n     25         26         27         28         29         30\n 25   0.429008   0.93986    0.971662   0.430087   0.682266   0.535061\n 26   0.145596   0.898459   0.443608   0.443415   0.915046   0.662115\n 27   0.563926   0.831003   0.407218   0.406627   0.660327   0.0124977\n 28   0.201234   0.262332   0.399131   0.882657   0.743907   0.493154\n 29   0.202371   0.898827   0.317586   0.5708     0.307101   0.694126\n 30   0.404285   0.818468   0.917196   0.286121   0.268186   0.407958\n

    More options are available, like Near, Contains and Where.

    Dimensions

    Rasters uses X, Y, and Z dimensions from DimensionalData to represent spatial directions like longitude, latitude and the vertical dimension, and subset data with them. Ti is used for time, and Band represent bands. Other dimensions can have arbitrary names, but will be treated generically. See DimensionalData for more details on how they work.

    Lookup Arrays

    These specify properties of the index associated with e.g. the X and Y dimension. Rasters.jl defines additional lookup arrays: Projected to handle dimensions with projections, and Mapped where the projection is mapped to another projection like EPSG(4326). Mapped is largely designed to handle NetCDF dimensions, especially with Explicit spans.

    "},{"location":"scripts/generated/basics/first_raster/#subsetting-an-object","title":"Subsetting an object","text":"

    Regular getindex (e.g. A[1:100, :]) and view work on all objects just as with an Array. view is always lazy, and reads from disk are deferred until getindex is used. DimensionalData.jl Dimensions and Selectors are the other way to subset an object, making use of the objects index to find values at e.g. certain X/Y coordinates. The available selectors are listed here:

    Selectors Description At(x) get the index exactly matching the passed in value(s). Near(x) get the closest index to the passed in value(s). Where(f::Function) filter the array axis by a function of the dimension index values. a..b/Between(a, b) get all indices between two values, excluding the high value. Contains(x) get indices where the value x falls within an interval.

    Info

    • Use the .. selector to take a view of madagascar:
    using Rasters, RasterDataSources\nconst RS = Rasters\nusing CairoMakie\nCairoMakie.activate!()\n\nA = Raster(WorldClim{BioClim}, 5)\nmadagascar = view(A, X(43.25 .. 50.48), Y(-25.61 .. -12.04))\n
    42\u00d780 Raster{Float32,2} bio5 with dimensions: \n  X Projected{Float64} LinRange{Float64}(43.3333, 50.1667, 42) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(-12.3333, -25.5, 80) ReverseOrdered Regular Intervals crs: WellKnownText\nand reference dimensions: \n  Band Categorical{Int64} 1:1 ForwardOrdered\nextent: Extent(X = (43.33333333333334, 50.333333333333336), Y = (-25.5, -12.166666666666677))missingval: -3.4f38crs: GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]\nparent:\n          -12.3333  -12.5     -12.6667  \u2026  -25.1667  -25.3333  -25.5\n 43.3333   -3.4f38   -3.4f38   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n 43.5      29.7175   30.5      -3.4f38      -3.4f38   -3.4f38   -3.4f38\n 43.6667   29.272    29.7587   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n  \u22ee                                     \u22f1              \u22ee       \n 49.8333   -3.4f38   -3.4f38   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n 50.0      -3.4f38   -3.4f38   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n 50.1667   -3.4f38   -3.4f38   -3.4f38      -3.4f38   -3.4f38   -3.4f38\n

    Note the space between .. -12

    Makie.plot(madagascar)\n

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/gbif_wflow/","title":"A basic species distribution modelling workflow","text":"

    Load occurrences for the Mountain Pygmy Possum using GBIF.jl

    "},{"location":"scripts/generated/basics/gbif_wflow/#load","title":"Load","text":"
    using Rasters, GBIF2\nusing RasterDataSources\nconst RS = Rasters\n\nrecords = GBIF2.occurrence_search(\"Burramys parvus\"; limit=300)\n
    300-element GBIF2.Table{GBIF2.Occurrence, JSON3.Array{JSON3.Object, Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}}\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u2502 decimalLongitude \u2502 decimalLatitude \u2502    year \u2502   month \u2502     day \u2502  kingdom  \u22ef\n\u2502         Float64? \u2502        Float64? \u2502  Int64? \u2502  Int64? \u2502  Int64? \u2502  String?  \u22ef\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502    2021 \u2502       1 \u2502       6 \u2502 Animalia  \u22ef\n\u2502          148.391 \u2502        -36.3036 \u2502    2015 \u2502      11 \u2502      15 \u2502 Animalia  \u22ef\n\u2502          148.333 \u2502        -36.4333 \u2502    2011 \u2502      11 \u2502      21 \u2502 Animalia  \u22ef\n\u2502          148.396 \u2502        -36.3818 \u2502    2016 \u2502      11 \u2502      15 \u2502 Animalia  \u22ef\n\u2502            147.1 \u2502           -37.0 \u2502    2008 \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          148.236 \u2502        -36.5249 \u2502    2012 \u2502      11 \u2502      23 \u2502 Animalia  \u22ef\n\u2502          147.096 \u2502        -36.9357 \u2502    2020 \u2502       2 \u2502      10 \u2502 Animalia  \u22ef\n\u2502          148.329 \u2502        -36.4317 \u2502    2016 \u2502       1 \u2502       3 \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          missing \u2502         missing \u2502 missing \u2502 missing \u2502 missing \u2502 Animalia  \u22ef\n\u2502          148.241 \u2502        -36.4001 \u2502    2011 \u2502      11 \u2502      18 \u2502 Animalia  \u22ef\n\u2502        \u22ee         \u2502        \u22ee        \u2502    \u22ee    \u2502    \u22ee    \u2502    \u22ee    \u2502    \u22ee      \u22f1\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n                                                 77 columns and 285 rows omitted\n
    "},{"location":"scripts/generated/basics/gbif_wflow/#extract-coordinates","title":"Extract coordinates","text":"

    Extract the longitude/latitude value to a Vector of points (a Tuple counts as a (x, y) point in GeoInterface.jl):

    coords = [(r.decimalLongitude, r.decimalLatitude) for r in records if !ismissing(r.decimalLatitude)]\n
    253-element Vector{Tuple{Float64, Float64}}:\n (148.391097, -36.30362)\n (148.332969, -36.433349)\n (148.396453, -36.381847)\n (147.1, -37.0)\n (148.235596, -36.524924)\n (147.096394, -36.935687)\n (148.328896, -36.431684)\n (148.240881, -36.400058)\n (148.347186, -36.504673)\n (151.250866, -33.831883)\n \u22ee\n (148.357658, -36.324288)\n (148.336891, -36.428415)\n (148.256519, -36.442973)\n (148.467196, -36.000859)\n (148.467196, -36.000859)\n (148.40889, -36.006805)\n (148.40889, -36.006805)\n (148.40889, -36.006805)\n (148.40889, -36.006805)\n

    "},{"location":"scripts/generated/basics/gbif_wflow/#get-layer-band","title":"Get layer / Band","text":"

    Get BioClim layers and subset to south-east Australia

    A = RasterStack(WorldClim{BioClim}, (1, 3, 7, 12))\nse_aus = A[X(138 .. 155), Y(-40 .. -25), RS.Band(1)]\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(138.0, 154.833, 102) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(-25.1667, -39.8333, 89) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :bio1  Float32 dims: X, Y (102\u00d789)\n  :bio3  Float32 dims: X, Y (102\u00d789)\n  :bio7  Float32 dims: X, Y (102\u00d789)\n  :bio12 Float32 dims: X, Y (102\u00d789)\n

    Plot BioClim predictors and scatter occurrence points on all subplots

    using Plots\np = plot(se_aus);\nkw = (legend=:none, opacity=0.5, markershape=:cross, markercolor=:black)\nforeach(i -> scatter!(p, coords; subplot=i, kw...), 1:4)\np\n

    Then extract predictor variables and write to CSV.

    using CSV\npredictors = collect(extract(se_aus, coords))\nCSV.write(\"burramys_parvus_predictors.csv\", predictors)\n
    \"burramys_parvus_predictors.csv\"\n

    Or convert them to a DataFrame:

    using DataFrames\ndf = DataFrame(predictors)\ndf[1:5, :]\n
    5\u00d75 DataFrame Rowgeometrybio1bio3bio7bio12Tuple\u2026Float32Float32Float32Float321(148.391, -36.3036)6.170741.119823.46451692.02(148.333, -36.4333)7.8357241.597523.50281500.03(148.396, -36.3818)6.8815842.268123.1331544.04(147.1, -37.0)9.4083540.790523.08951292.05(148.236, -36.5249)8.001641.846522.85221368.0

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/methods/","title":"Methods","text":""},{"location":"scripts/generated/basics/methods/#methods-that-change-the-resolution-or-extent-of-an-object","title":"Methods that change the resolution or extent of an object","text":"

    Click through to the function documentation for more in-depth descriptions and examples.

    Methods Description aggregate aggregate data by the same or different amounts for each axis. disaggregate similarly disaggregate data. mosaic join rasters covering different extents into a single array or file. crop shrink objects to specific dimension sizes or the extent of another object. extend extend objects to specific dimension sizes or the extent of another object. trim trims areas of missing values for arrays and across stack layers. resample resample data to a different size and projection, or snap to another object. warp use gdalwarp on any object, e.g. a multidimensional NetCDF stack.

    "},{"location":"scripts/generated/basics/methods/#methods-that-change-an-objects-values","title":"Methods that change an objects values","text":"

    Info

    Note that most regular Julia methods, such as replace, work as for a standard Array. These additional methods are commonly required in GIS applications.

    Methods Description classify classify values into categories. mask mask an object by a polygon or Raster along X/Y, or other dimensions. replace_missing replace all missing values in an object and update missingval.

    "},{"location":"scripts/generated/basics/methods/#point-polygon-and-table-operation","title":"Point, polygon and table operation","text":"Methods Description rasterize rasterize points and geometries. extract extract values from points or geometries. zonal calculate zonal statistics for an object masked by geometries."},{"location":"scripts/generated/basics/methods/#methods-to-load-write-and-modify-data-sources","title":"Methods to load, write and modify data sources","text":"Methods Description modify replace the data in objects. Useful to e.g. move objects to/from a GPU. read read data to memory if it is on disk. read! read data to predefined memory. open open the underlying data for manually reading or writing. write write objects to file.

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/plot_makie/","title":"Examples with Makie","text":""},{"location":"scripts/generated/basics/plot_makie/#plotting-in-makie","title":"Plotting in Makie","text":"

    Plotting in Makie works somewhat differently than Plots, since the recipe system is different. You can pass a 2-D raster to any surface-like function (heatmap, contour, contourf, or even surface for a 3D plot) with ease.

    "},{"location":"scripts/generated/basics/plot_makie/#2-d-rasters-in-makie","title":"2-D rasters in Makie","text":"
    using CairoMakie, Makie\nusing Rasters, RasterDataSources, ArchGDAL\nA = Raster(WorldClim{BioClim}, 5) # this is a 3D raster, so is not accepted.\n\nfig = Figure()\nplot(fig[1, 1], A)\ncontour(fig[1, 2], A)\nax = Axis(fig[2, 1]; aspect = DataAspect())\ncontourf!(ax, A)\nsurface(fig[2, 2], A) # even a 3D plot works!\nfig\n
    "},{"location":"scripts/generated/basics/plot_makie/#3-d-rasters-in-makie","title":"3-D rasters in Makie","text":"

    Warning

    This interface is experimental, and unexported for that reason. It may break at any time!

    Just as in Plots, 3D rasters are treated as a series of 2D rasters, which are tiled and plotted.

    You can use Rasters.rplot to visualize 3D rasters or RasterStacks in this way. An example is below:

    stack = RasterStack(WorldClim{Climate}; month = 1)\nRasters.rplot(stack; Axis = (aspect = DataAspect(),),)\n

    You can pass any theming keywords in, which are interpreted by Makie appropriately.

    The plots seem a little squished here. We provide a Makie theme which makes text a little smaller and has some other space-efficient attributes:

    Makie.set_theme!(Rasters.theme_rasters())\nRasters.rplot(stack)\n

    reset theme

    Makie.set_theme!()\n

    "},{"location":"scripts/generated/basics/plot_makie/#plotting-with-observables-animations","title":"Plotting with Observables, animations","text":"

    Rasters.rplot should support Observable input out of the box, but the dimensions of that input must remain the same - i.e., the element names of a RasterStack must remain the same.

    Makie.set_theme!(Rasters.theme_rasters())\n

    stack is the WorldClim climate data for January

    stack_obs = Observable(stack)\nfig = Rasters.rplot(stack_obs;\n    Colorbar=(; height=Relative(0.75), width=5)\n)\nrecord(fig, \"rplot.mp4\", 1:12; framerate = 3) do i\n    stack_obs[] = RasterStack(WorldClim{Climate}; month = i)\nend\n
    \"rplot.mp4\"\n

    Makie.set_theme!() # reset theme\n

    # Rasters.rplot \u2014 Function.

    Rasters.rplot([position::GridPosition], raster; kw...)\n

    raster may be a Raster (of 2 or 3 dimensions) or a RasterStack whose underlying rasters are 2 dimensional, or 3-dimensional with a singleton (length-1) third dimension.

    Keywords

    • plottype = Makie.Heatmap: The type of plot. Can be any Makie plot type which accepts a Raster; in practice, Heatmap, Contour, Contourf and Surface are the best bets.
    • axistype = Makie.Axis: The type of axis. This can be an Axis, Axis3, LScene, or even a GeoAxis from GeoMakie.jl.
    • X = XDim: The X dimension of the raster.
    • Y = YDim: The Y dimension of the raster.
    • Z = YDim: The Y dimension of the raster.
    • draw_colorbar = true: Whether to draw a colorbar for the axis or not.
    • colorbar_position = Makie.Right(): Indicates which side of the axis the colorbar should be placed on. Can be Makie.Top(), Makie.Bottom(), Makie.Left(), or Makie.Right().
    • colorbar_padding = Makie.automatic: The amound of padding between the colorbar and its axis. If automatic, then this is set to the width of the colorbar.
    • title = Makie.automatic: The titles of each plot. If automatic, these are set to the name of the band.
    • xlabel = Makie.automatic: The x-label for the axis. If automatic, set to the dimension name of the X-dimension of the raster.
    • ylabel = Makie.automatic: The y-label for the axis. If automatic, set to the dimension name of the Y-dimension of the raster.
    • colorbarlabel = \"\": Usually nothing, but here if you need it. Sets the label on the colorbar.
    • colormap = nothing: The colormap for the heatmap. This can be set to a vector of colormaps (symbols, strings, cgrads) if plotting a 3D raster or RasterStack.
    • colorrange = Makie.automatic: The colormap for the heatmap. This can be set to a vector of (low, high) if plotting a 3D raster or RasterStack.
    • nan_color = :transparent: The color which NaN values should take. Default to transparent.

    source

    "},{"location":"scripts/generated/basics/plot_makie/#using-vanilla-makie","title":"Using vanilla Makie","text":"
    using Rasters, RasterDataSources\n

    The data

    layers = (:evenness, :range, :contrast, :correlation)\nst = RasterStack(EarthEnv{HabitatHeterogeneity}, layers)\nausbounds = X(100 .. 160), Y(-50 .. -10) # Roughly cut out australia\naus = st[ausbounds...] |> Rasters.trim\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(113.333, 153.542, 194) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(-10.2083, -43.5417, 161) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :evenness    UInt16 dims: X, Y (194\u00d7161)\n  :range       UInt16 dims: X, Y (194\u00d7161)\n  :contrast    UInt32 dims: X, Y (194\u00d7161)\n  :correlation UInt16 dims: X, Y (194\u00d7161)\n

    The plot colorbar attributes

    colormap = :batlow\nflipaxis = false\ntickalign=1\nwidth = 13\nticksize = 13\n
    13\n

    figure

    with_theme(theme_ggplot2()) do\n    fig = Figure(resolution=(800, 600))\n    axs = [Axis(fig[i,j], xlabel = \"lon\", ylabel = \"lat\") for i in 1:2 for j in 1:2]\n    plt = [Makie.heatmap!(axs[i], aus[l]; colormap) for (i, l) in enumerate(layers)]\n    for (i, l) in enumerate(layers) axs[i].title = string(l) end\n    hidexdecorations!.(axs[1:2]; grid=false, ticks=false)\n    hideydecorations!.(axs[[2,4]]; grid=false, ticks=false)\n    Colorbar(fig[1, 0], plt[1]; flipaxis, tickalign, width, ticksize)\n    Colorbar(fig[1, 3], plt[2]; tickalign, width, ticksize)\n    Colorbar(fig[2, 0], plt[3]; flipaxis, tickalign, width, ticksize)\n    Colorbar(fig[2, 3], plt[4]; tickalign, width, ticksize)\n    colgap!(fig.layout, 5)\n    rowgap!(fig.layout, 5)\n    Label(fig[0, :], \"RasterStack of EarthEnv HabitatHeterogeneity layers, trimmed to Australia\")\n    fig\nend\nsave(\"aus_trim.png\", current_figure());\n

    This page was generated using Literate.jl.

    "},{"location":"scripts/generated/basics/plotting/","title":"Examples and Plotting","text":""},{"location":"scripts/generated/basics/plotting/#plots-simple","title":"Plots, simple","text":"

    Plots.jl and Makie.jl are fully supported by Rasters.jl, with recipes for plotting Raster and RasterStack provided. plot will plot a heatmap with axes matching dimension values. If mappedcrs is used, converted values will be shown on axes instead of the underlying crs values. contourf will similarly plot a filled contour plot.

    Pixel resolution is limited to allow loading very large files quickly. max_res specifies the maximum pixel resolution to show on the longest axis of the array. It can be set manually to change the resolution (e.g. for large or high-quality plots):

    using Rasters, RasterDataSources, ArchGDAL, Plots\nA = Raster(WorldClim{BioClim}, 5)\nplot(A; max_res=3000)\n

    For Makie, plot functions in a similar way. plot will only accept two-dimensional rasters. You can invoke contour, contourf, heatmap, surface or any Makie plotting function which supports surface-like data on a 2D raster.

    To obtain tiled plots for 3D rasters and RasterStacks, use the function Rasters.rplot([gridposition], raster; kw_args...). This is an unexported function, since we're not sure how the API will change going forward.

    "},{"location":"scripts/generated/basics/plotting/#makie-simple","title":"Makie, simple","text":"
    using CairoMakie\nCairoMakie.activate!(px_per_unit = 2)\nusing Rasters, CairoMakie, RasterDataSources, ArchGDAL\nA = Raster(WorldClim{BioClim}, 5)\nMakie.plot(A)\n
    "},{"location":"scripts/generated/basics/plotting/#loading-data","title":"Loading data","text":"

    Our first example simply loads a file from disk and plots it.

    This netcdf file only has one layer, if it has more we could use RasterStack instead.

    using Rasters, NCDatasets, Plots\nurl = \"https://www.unidata.ucar.edu/software/netcdf/examples/tos_O1_2001-2002.nc\";\nfilename = download(url, \"tos_O1_2001-2002.nc\");\nA = Raster(filename)\n
    180\u00d7170\u00d724 Raster{Union{Missing, Float32},3} tos with dimensions: \n  X Mapped{Float64} Float64[1.0, 3.0, \u2026, 357.0, 359.0] ForwardOrdered Explicit Intervals crs: EPSG mappedcrs: EPSG,\n  Y Mapped{Float64} Float64[-79.5, -78.5, \u2026, 88.5, 89.5] ForwardOrdered Explicit Intervals crs: EPSG mappedcrs: EPSG,\n  Ti Sampled{DateTime360Day} DateTime360Day[DateTime360Day(2001-01-16T00:00:00), \u2026, DateTime360Day(2002-12-16T00:00:00)] ForwardOrdered Explicit Intervals\nextent: Extent(X = (-0.0, 360.0), Y = (-80.0, 90.0), Ti = (DateTime360Day(2001-01-01T00:00:00), DateTime360Day(2003-01-01T00:00:00)))missingval: missingcrs: EPSG:4326\nmappedcrs: EPSG:4326\nparent:\n[:, :, 1]\n        -79.5       -78.5       \u2026   86.5     87.5     88.5     89.5\n   1.0     missing     missing     271.43   271.437  271.445  271.459\n   3.0     missing     missing     271.431  271.438  271.445  271.459\n   5.0     missing     missing     271.431  271.438  271.445  271.459\n   7.0     missing     missing     271.431  271.439  271.446  271.459\n   \u22ee                            \u22f1                      \u22ee      \n 351.0     missing     missing     271.43   271.435  271.445  271.459\n 353.0     missing     missing     271.43   271.436  271.445  271.459\n 355.0     missing     missing     271.43   271.436  271.445  271.459\n 357.0     missing     missing     271.43   271.437  271.445  271.459\n 359.0     missing     missing  \u2026  271.43   271.437  271.445  271.459\n[and 23 more slices...]\n

    Objects with Dimensions other than X and Y will produce multi-pane plots. Here we plot every third month in the first year in one plot:

    A[Ti=1:3:12] |> plot\n

    Now plot the ocean temperatures around the Americas in the first month of 2001. Notice we are using lat/lon coordinates and date/time instead of regular indices. The time dimension uses DateTime360Day, so we need to load CFTime.jl to index it with Near.

    using CFTime\nA[Ti(Near(DateTime360Day(2001, 01, 17))), Y(-60.0 .. 90.0), X(45.0 .. 190.0)] |> plot\n

    Now get the mean over the timespan, then save it to disk, and plot it as a filled contour.

    Other plot functions and sliced objects that have only one X/Y/Z dimension fall back to generic DimensionalData.jl plotting, which will still correctly label plot axes.

    using Statistics\n# Take the mean\nmean_tos = mean(A; dims=Ti)\n
    180\u00d7170\u00d71 Raster{Union{Missing, Float32},3} tos with dimensions: \n  X Mapped{Float64} Float64[1.0, 3.0, \u2026, 357.0, 359.0] ForwardOrdered Explicit Intervals crs: EPSG mappedcrs: EPSG,\n  Y Mapped{Float64} Float64[-79.5, -78.5, \u2026, 88.5, 89.5] ForwardOrdered Explicit Intervals crs: EPSG mappedcrs: EPSG,\n  Ti Sampled{DateTime360Day} DateTime360Day(2002-01-16T00:00:00):Millisecond(2592000000):DateTime360Day(2002-01-16T00:00:00) ForwardOrdered Explicit Intervals\nextent: Extent(X = (-0.0, 360.0), Y = (-80.0, 90.0), Ti = (DateTime360Day(2001-01-01T00:00:00), DateTime360Day(2003-01-01T00:00:00)))missingval: missingcrs: EPSG:4326\nmappedcrs: EPSG:4326\nparent:\n[:, :, 1]\n        -79.5       -78.5       \u2026   86.5     87.5     88.5     89.5\n   1.0     missing     missing     271.427  271.434  271.443  271.454\n   3.0     missing     missing     271.427  271.434  271.443  271.454\n   5.0     missing     missing     271.427  271.434  271.443  271.454\n   7.0     missing     missing     271.427  271.435  271.444  271.454\n   \u22ee                            \u22f1                      \u22ee      \n 351.0     missing     missing     271.427  271.433  271.443  271.454\n 353.0     missing     missing     271.427  271.433  271.443  271.454\n 355.0     missing     missing     271.427  271.433  271.443  271.454\n 357.0     missing     missing     271.427  271.433  271.443  271.454\n 359.0     missing     missing  \u2026  271.427  271.433  271.443  271.454\n

    "},{"location":"scripts/generated/basics/plotting/#plot-a-contour-plot","title":"Plot a contour plot","text":"
    using Plots\nPlots.contourf(mean_tos; dpi=300, size=(800, 400))\n
    "},{"location":"scripts/generated/basics/plotting/#write-to-disk","title":"write to disk","text":"

    Write the mean values to disk

    write(\"mean_tos.nc\", mean_tos)\n
    \"mean_tos.nc\"\n

    Plotting recipes in DimensionalData.jl are the fallback for Rasters.jl when the object doesn't have 2 X/Y/Z dimensions, or a non-spatial plot command is used. So (as a random example) we could plot a transect of ocean surface temperature at 20 degree latitude :

    A[Y(Near(20.0)), Ti(1)] |> plot\n

    "},{"location":"scripts/generated/basics/plotting/#polygon-masking-mosaic-and-plot","title":"Polygon masking, mosaic and plot","text":"

    In this example we will mask the Scandinavian countries with border polygons, then mosaic together to make a single plot.

    First, get the country boundary shape files using GADM.jl.

    using Rasters, RasterDataSources, ArchGDAL, Shapefile, Plots, Dates, Downloads, NCDatasets\n
    WARNING: using Downloads.download in module Main conflicts with an existing identifier.\n

    Download the shapefile

    shapefile_url = \"https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp\"\nshapefile_name = \"boundary_lines.shp\"\nDownloads.download(shapefile_url, shapefile_name)\n
    \"boundary_lines.shp\"\n

    Load using Shapefile.jl

    shapes = Shapefile.Handle(shapefile_name)\ndenmark_border = shapes.shapes[71]\nnorway_border = shapes.shapes[53]\nsweden_border = shapes.shapes[54]\n
    Polygon(4665 Points)\n

    Then load raster data. We load some worldclim layers using RasterDataSources via Rasters.jl:

    climate = RasterStack(WorldClim{Climate}, (:tmin, :tmax, :prec, :wind); month=July)\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (2160\u00d71080)\n  :tmax Float32 dims: X, Y (2160\u00d71080)\n  :prec Int16 dims: X, Y (2160\u00d71080)\n  :wind Float32 dims: X, Y (2160\u00d71080)\n

    mask Denmark, Norway and Sweden from the global dataset using their border polygon, then trim the missing values. We pad trim with a 10 pixel margin.

    mask_trim(climate, poly) = trim(mask(climate; with=poly); pad=10)\n\ndenmark = mask_trim(climate, denmark_border)\nnorway = mask_trim(climate, norway_border)\nsweden = mask_trim(climate, sweden_border)\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(9.5, 25.6667, 98) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(70.5, 53.6667, 102) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (98\u00d7102)\n  :tmax Float32 dims: X, Y (98\u00d7102)\n  :prec Int16 dims: X, Y (98\u00d7102)\n  :wind Float32 dims: X, Y (98\u00d7102)\n

    Then load raster data. We load some worldclim layers using RasterDataSources via Rasters.jl:

    climate = RasterStack(WorldClim{Climate}, (:tmin, :tmax, :prec, :wind); month=July)\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(-180.0, 179.833, 2160) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(89.8333, -90.0, 1080) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (2160\u00d71080)\n  :tmax Float32 dims: X, Y (2160\u00d71080)\n  :prec Int16 dims: X, Y (2160\u00d71080)\n  :wind Float32 dims: X, Y (2160\u00d71080)\n

    mask Denmark, Norway and Sweden from the global dataset using their border polygon, then trim the missing values. We pad trim with a 10 pixel margin.

    mask_trim(climate, poly) = trim(mask(climate; with=poly); pad=10)\n\ndenmark = mask_trim(climate, denmark_border)\nnorway = mask_trim(climate, norway_border)\nsweden = mask_trim(climate, sweden_border)\n
    RasterStack with dimensions: \n  X Projected{Float64} LinRange{Float64}(9.5, 25.6667, 98) ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} LinRange{Float64}(70.5, 53.6667, 102) ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (98\u00d7102)\n  :tmax Float32 dims: X, Y (98\u00d7102)\n  :prec Int16 dims: X, Y (98\u00d7102)\n  :wind Float32 dims: X, Y (98\u00d7102)\n

    "},{"location":"scripts/generated/basics/plotting/#plotting-with-plots","title":"Plotting with Plots","text":"

    First define a function to add borders to all subplots.

    function borders!(p, poly)\n    for i in 1:length(p)\n        Plots.plot!(p, poly; subplot=i, fillalpha=0, linewidth=0.6)\n    end\n    return p\nend\n
    borders! (generic function with 1 method)\n

    Now we can plot the individual countries.

    dp = plot(denmark)\nborders!(dp, denmark_border)\n

    and sweden

    sp = plot(sweden)\nborders!(sp, sweden_border)\n

    and norway

    np = plot(norway)\nborders!(np, norway_border)\n

    The Norway shape includes a lot of islands. Lets crop them out using .. intervals:

    norway_region = climate[X(0..40), Y(55..73)]\nplot(norway_region)\n

    And mask it with the border again:

    norway = mask_trim(norway_region, norway_border)\nnp = plot(norway)\nborders!(np, norway_border)\n

    Now we can combine the countries into a single raster using mosaic. first will take the first value if/when there is an overlap.

    scandinavia = mosaic(first, denmark, norway, sweden)\n
    RasterStack with dimensions: \n  X Projected{Float64} 3.1666666666666443:0.16666666666666666:32.49999999999998 ForwardOrdered Regular Intervals crs: WellKnownText,\n  Y Projected{Float64} 72.66666666666666:-0.16666666666666666:52.99999999999999 ReverseOrdered Regular Intervals crs: WellKnownText\nand 4 layers:\n  :tmin Float32 dims: X, Y (177\u00d7119)\n  :tmax Float32 dims: X, Y (177\u00d7119)\n  :prec Int16 dims: X, Y (177\u00d7119)\n  :wind Float32 dims: X, Y (177\u00d7119)\n

    And plot scandinavia, with all borders included:

    p = plot(scandinavia)\nborders!(p, denmark_border)\nborders!(p, norway_border)\nborders!(p, sweden_border)\np\n

    And save to netcdf - a single multi-layered file, and tif, which will write a file for each stack layer.

    write(\"scandinavia.nc\", scandinavia)\nwrite(\"scandinavia.tif\", scandinavia)\n
    (tmin = \"scandinavia_tmin.tif\", tmax = \"scandinavia_tmax.tif\", prec = \"scandinavia_prec.tif\", wind = \"scandinavia_wind.tif\")\n

    Rasters.jl provides a range of other methods that are being added to over time. Where applicable these methods read and write lazily to and from disk-based arrays of common raster file types. These methods also work for entire RasterStacks and RasterSeries using the same syntax.

    This page was generated using Literate.jl.

    "}]} \ No newline at end of file diff --git a/dev/sitemap.xml.gz b/dev/sitemap.xml.gz index 415c40dec..56afa6a3b 100644 Binary files a/dev/sitemap.xml.gz and b/dev/sitemap.xml.gz differ