RasterDataSources.jl
RasterDataSources
— ModuleRasterDataSources.jl
RasterDataSources downloads raster data for local use or for integration into other spatial data packages, like Rasters.jl. The collection is largely focussed on datasets relevant to ecology, but will have a lot of crossover with other sciences.
Currently sources include:
Source | URL | Status |
---|---|---|
CHELSA | https://chelsa-climate.org | BioClim, BioClimPlus, and Climate |
WorldClim | https://www.worldclim.org | Climate, Weather, BioClim, and Elevation |
EarthEnv | http://www.earthenv.org | LandCover and HabitatHeterogeneity |
AWAP | http://www.bom.gov.au/jsp/awap/index.jsp | Complete |
ALWB | http://www.bom.gov.au/water/landscape/ | Complete |
SRTM | https://www2.jpl.nasa.gov/srtm/ | Complete |
MODIS | https://modis.ornl.gov | Complete (beta) |
Please open an issue if you need more datasets added, or (even better) open a pull request following the form of the other datasets where possible.
Retrieving data
Usage is generally via the getraster
method - which will download the raster data source if it isn't available locally, or simply return the path/s of the raster file/s:
julia> using RasterDataSources
julia> getraster(WorldClim{Climate}, :wind; month=1:12)
12-element Array{String,1}:
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_01.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_02.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_03.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_04.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_05.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_06.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_07.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_08.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_09.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_10.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_11.tif"
"/home/user/Data/WorldClim/Climate/wind/wc2.1_10m_wind_12.tif"
Installation and setup
Install as usual with:
] add RasterDataSources
To download data you will need to specify a folder to put it in. You can do this by assigning the environment variable RASTERDATASOURCES_PATH
:
ENV["RASTERDATASOURCES_PATH"] = "/home/user/Data/"
This can be put in your startup.jl
file or the system environment.
RasterDataSources was based on code from the SimpleSDMDataSoures.jl
package by Timothée Poisot.
getraster
RasterDataSources.jl only exports a single function, getraster
.
RasterDataSources.getraster
— Functiongetraster(T::Type, layers::Union{Tuple,Int,Symbol}; kw...)
Specific implementations are included with each source, below.
Data sources
RasterDataSources.RasterDataSource
— TypeRasterDataSource
Abstract supertype for raster data collections.
ALWB
RasterDataSources.ALWB
— TypeALWB{Union{Deciles,Values},Union{Day,Month,Year}} <: RasterDataSource
Data from the Australian Landscape Water Balance (ALWB) data source.
See: www.bom.gov.au/water/landscape
The dataset contains NetCDF files. They have a time dimension so that multiple dates are stored in each file.
The available layers are: (:rain_day, :s0_pct, :ss_pct, :sd_pct, :sm_pct, :qtot, :etot, :e0, :ma_wet, :pen_pet, :fao_pet, :asce_pet, :msl_wet, :dd)
, available in daily, monthly and annual resolutions, and as Values
or relative Deciles
.
getraster
for ALWB
must use a date
keyword to specify the date to download.
See the getraster
docs for implementation details.
RasterDataSources.getraster
— Methodgetraster(source::Type{<:ALWB{Union{Deciles,Values},Union{Day,Month,Year}}}, [layer]; date)
Download ALWB
weather data from www.bom.gov.au/water/landscape as values or deciles with timesteps of Day
, Month
or Year
.
Arguments
layer
:Symbol
orTuple
ofSymbol
from(:rain_day, :s0_pct, :ss_pct, :sd_pct, :sm_pct, :qtot, :etot, :e0, :ma_wet, :pen_pet, :fao_pet, :asce_pet, :msl_wet, :dd)
. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Keywords
date
: aDateTime
,AbstractVector
ofDateTime
or aTuple
of start and end dates. For multiple dates, aVector
of multiple filenames will be returned. ALWB is available with a daily, monthly, and yearly, timestep.
Example
This will return the file containing annual averages, including your date:
julia> getraster(ALWB{Values,Year}, :ss_pct; date=Date(2001, 2))
"/your/RASTERDATASOURCES_PATH/ALWB/values/month/ss_pct.nc"
Returns the filepath/s of the downloaded or pre-existing files.
AWAP
RasterDataSources.AWAP
— TypeAWAP <: RasterDataSource
Daily weather data from the Australian Water Availability Project, developed by CSIRO.
See: www.csiro.au/awap
The available layers are: (:solar, :rainfall, :vprpress09, :vprpress15, :tmin, :tmax)
.
RasterDataSources.getraster
— Methodgetraster(source::Type{AWAP}, [layer]; date)
Download data from the AWAP
weather dataset, from www.csiro.au/awap.
The AWAP dataset contains ASCII .grid
files.
Arguments
layer
Symbol
orTuple
ofSymbol
forlayer
s in(:solar, :rainfall, :vprpress09, :vprpress15, :tmin, :tmax)
. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Keywords
date
: aDateTime
,AbstractVector
ofDateTime
or aTuple
of start and end dates. For multiple dates, AVector
of multiple filenames will be returned. AWAP is available with a daily timestep.
Example
Download rainfall for the first month of 2001:
julia> getraster(AWAP, :rainfall; date=Date(2001, 1, 1):Day(1):Date(2001, 1, 31))
31-element Vector{String}:
"/your/path/AWAP/rainfall/totals/20010101.grid"
"/your/path/AWAP/rainfall/totals/20010102.grid"
...
"/your/path/AWAP/rainfall/totals/20010131.grid"
Returns the filepath/s of the downloaded or pre-existing files.
CHELSA
RasterDataSources.CHELSA
— TypeCHELSA{Union{BioClim,BioClimPlus,Climate,<:Future}} <: RasterDataSource
Data from CHELSA, currently implements the BioClim
BioClimPlus
, and Climate
variables for current and future conditions.
See: chelsa-climate.org for the dataset, and the getraster
docs for implementation details.
RasterDataSources.getraster
— Methodgetraster(source::Type{CHELSA{BioClim}}, [layer]; version = 2, [patch]) => Union{Tuple,String}
Download CHELSA
BioClim
data from chelsa-climate.org.
Arguments
layer
:Integer
or tuple/range ofInteger
from(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
, orSymbol
s form(:bio1, :bio2, :bio3, :bio4, :bio5, :bio6, :bio7, :bio8, :bio9, :bio10, :bio11, :bio12, :bio13, :bio14, :bio15, :bio16, :bio17, :bio18, :bio19)
. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Keyword arguments
version
:Integer
indicating the CHELSA version, currently either1
or2
.patch
:Integer
indicating the CHELSA patch number. Defaults to the latest patch (V1.2 and V2.1)
Returns the filepath/s of the downloaded or pre-existing files.
RasterDataSources.getraster
— Methodgetraster(T::Type{CHELSA{Future{Climate}}}, [layer]; date, month) => String
Download CHELSA Climate
data, choosing layers from: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
.
See the docs for Future
for model choices.
Without a layer argument, all layers will be downloaded, and a NamedTuple
of paths returned.
Keywords
date
: aDate
orDateTime
object, a Vector, or Tuple of start/end dates. Note that CHELSA CMIP5 only has two datasets, for the periods 2041-2060 and 2061-2080. CMIP6 has datasets for the periods 2011-2040, 2041-2070, and 2071-2100. Dates must fall within these ranges.month
: the month of the year, from 1 to 12, or a array or range of months like1:12
.
Example
using Dates, RasterDataSources
getraster(CHELSA{Future{Climate, CMIP6, GFDLESM4, SSP370}}, :prec; date = Date(2050), month = 1)
EarthEnv
RasterDataSources.EarthEnv
— TypeEarthEnv{Union{HabitatHeterogeneity,LandCover}} <: RasterDataSource
Data from the EarthEnv
including HabitatHeterogeneity
and LandCover
See: www.earthenv.org
RasterDataSources.getraster
— Methodgetraster(source::Type{EarthEnv{HabitatHeterogeneity}}, [layer]; res="25km")
Download EarthEnv
habitat heterogeneity data.
Arguments
layer
:Symbol
orTuple
ofSymbol
from(:cv, :evenness, :range, :shannon, :simpson, :std, :Contrast, :Correlation, :Dissimilarity, :Entropy, :Homogeneity, :Maximum, :Uniformity, :Variance)
. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Keywords
res
:String
chosen from("1km", "5km", "25km")
, defaulting to "25km".
Returns the filepath/s of the downloaded or pre-existing files.
RasterDataSources.getraster
— Methodgetraster(T::Type{EarthEnv{LandCover}}, [layer]; discover=false) => Union{Tuple,String}
Download EarthEnv
landcover data.
Arguments
layer
:Integer
or tuple/range ofInteger
from(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
, orSymbol
s from(:needleleaf_trees, :evergreen_broadleaf_trees, :deciduous_broadleaf_trees, :other_trees, :shrubs, :herbaceous, :cultivated_and_managed, :regularly_flooded, :urban_builtup, :snow_ice, :barren, :open_water)
. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Keywords
discover::Bool
: whether to download the dataset that integrates the DISCover model.
Returns the filepath/s of the downloaded or pre-existing files.
WorldClim
RasterDataSources.WorldClim
— TypeWorldClim{Union{BioClim,Climate,Weather}} <: RasterDataSource
Data from WorldClim datasets, either BioClim
, Climate
or Weather
.
See: www.worldclim.org
RasterDataSources.getraster
— Methodgetraster(T::Type{WorldClim{BioClim}}, [layer::Union{Tuple,AbstractVector,Integer}]; res::String="10m") => Union{Tuple,AbstractVector,String}
Download WorldClim
BioClim
data.
Arguments
layer
:Integer
or tuple/range ofInteger
from(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
. orSymbol
s from(:bio1, :bio2, :bio3, :bio4, :bio5, :bio6, :bio7, :bio8, :bio9, :bio10, :bio11, :bio12, :bio13, :bio14, :bio15, :bio16, :bio17, :bio18, :bio19)
. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Keywords
res
:String
chosen from ("30s", "2.5m", "5m", "10m"), "10m" by default.
Returns the filepath/s of the downloaded or pre-existing files.
RasterDataSources.getraster
— Methodgetraster(T::Type{WorldClim{Weather}}, [layer::Union{Tuple,Symbol}]; date) => Union{String,Tuple{String},Vector{String}}
Download WorldClim
Weather
data, for layer
/s in: (:tmin, :tmax, :prec)
. Without a layer argument, all layers will be downloaded, and a NamedTuple
of paths returned.
Keywords
date
: aDate
orDateTime
object, aVector
of dates, orTuple
of start/end dates. WorldClim Weather is available with a daily timestep.
Returns the filepath/s of the downloaded or pre-existing files.
RasterDataSources.getraster
— Methodgetraster(T::Type{WorldClim{Climate}}, [layer::Union{Tuple,Symbol}]; month, res::String="10m") => Vector{String}
Download WorldClim
Climate
data.
Arguments
layer
Symbol
orTuple
ofSymbol
from(:tmin, :tmax, :tavg, :prec, :srad, :wind, :vapr)
. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Keywords
month
:Integer
orAbstractArray
ofInteger
. Chosen from1:12
.res
:String
chosen from ("30s", "2.5m", "5m", "10m"), "10m" by default.
Returns the filepath/s of the downloaded or pre-existing files.
RasterDataSources.getraster
— Methodgetraster(T::Type{WorldClim{Elevation}}, [layer::Union{Tuple,Symbol}]; res::String="10m") => Union{Tuple,AbstractVector,String}
Download WorldClim
Elevation
data.
Arguments
layer
:Symbol
orTuple
ofSymbol
from(:elev,)
. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Keywords
res
:String
chosen from ("30s", "2.5m", "5m", "10m"), "10m" by default.
Returns the filepath/s of the downloaded or pre-existing files.
MODIS
RasterDataSources.MODIS
— TypeMODIS{ModisProduct} <: RasterDataSource
MODIS/VIIRS Land Product Database. Vegetation indices, surface reflectance, and more land cover data. Data from ModisProduct
s datasets.
See: modis.ornl.gov
RasterDataSources.getraster
— Methodgetraster(T::Union{Type{<:ModisProduct}, Type{MODIS{X}}}, [layer::Union{Tuple,AbstractVector,Integer, Symbol}]; kwargs...) => Union{String, AbstractVector, NamedTuple}
Download MODIS
data for a given ModisProduct
as ASCII raster(s).
Arguments
layer
:Integer
or tuple/range ofInteger
orSymbol
s. Without alayer
argument, all layers will be downloaded, and aNamedTuple
of paths returned.
Available layers for a given product can be looked up using RasterDataSources.layerkeys(T::Type{<:ModisProduct})
.
Keywords
lat
andlon
: Coordinates in decimal degrees of the approximate center of the raster. The MODIS API will try to match its pixel grid system as close as possible to those coordinates.km_ab
andkm_lr
: Half-width and half-height of the raster in kilometers (kilometers above/below and left/right). Currently onlyInteger
values are supported, up to 100.date
:String
,Date
,DateTime
,AbstractVector
of dates orTuple
of a start and end date for the request.String
s should be in format YYYY-MM-DD but can be in similar formats as long as they are comprehensible byDates.Date
. The available date interval for MODIS is 16 days, reset every first of January.
Example
Download 250m NDVI in the western part of Britanny, France, from winter to late spring, 2002:
julia> getraster(MOD13Q1, :NDVI; lat = 48.25, lon = -4, km_ab = 50, km_lr = 50, date = (Date(2002,1,1), Date(2002,6,1)))
10-element Vector{String}:
"/your/path/MODIS/MOD13Q1/250m_16_days_NDVI/47.8313_-4.5899_2002-01-01.asc"
...
"/your/path/MODIS/MOD13Q1/250m_16_days_NDVI/47.8313_-4.5899_2002-05-25.asc"
Will attempt to download several files, one for each date and layer combination, and returns the filepath/s of the downloaded or pre-existing files. Coordinates in the file names correspond to the lower-left corner of the raster.
RasterDataSources.ModisProduct
— TypeModisProduct <: RasterDataSet
Abstract supertype for MODIS
/VIIRS products.
Usage
Some commonly used products are MOD13Q1
(250m resolution MODIS vegetation indices) and VNP13A1
(500m resolution VIIRS vegetation indices). Refer to the MODIS documentation for detailed product information.
RasterDataSources.layerkeys
— Methodlayerkeys(T::Type{<:ModisProduct}) => Tuple
Tuple
of Symbol
s corresponding to the available layers for a given product. May issue a request to MODIS server to get the layers list, or might just read this information if the correctly named file is available.
Datasets
RasterDataSources.RasterDataSet
— TypeRasterDataSet
Abstract supertype for datasets that belong to a RasterDataSource
.
RasterDataSources.BioClim
— TypeBioClim <: RasterDataSet
BioClim datasets. Usually containing layers from 1:19
. These can also be accessed with :bioX
, e.g. :bio5
.
They do not usually use month
or date
keywords, but may use date
in past/future scenarios.
Currently implemented for WorldClim and CHELSA as WorldClim{BioClim}
, CHELSA{BioClim}
and CHELSA{Future{BioClim, args..}}
.
See the getraster
docs for implementation details.
RasterDataSources.Climate
— TypeClimate <: RasterDataSet
Climate datasets. These are usually months of the year, not specific dates, and use a month
keyword in getraster
. They also use date
in past/future scenarios.
Currently implemented for WorldClim and CHELSA as WorldClim{Climate}
, CHELSA{Climate}
and CHELSA{Future{Climate, args..}}
.
See the getraster
docs for implementation details.
RasterDataSources.Weather
— TypeWeather <: RasterDataSet
Weather datasets. These are usually large time-series of specific dates, and use a date
keyword in getraster
.
Currently implemented for WorldClim and CHELSA as WorldClim{Weather}
, and CHELSA{Weather}
See the getraster
docs for implementation details.
RasterDataSources.Elevation
— TypeElevation <: RasterDataSet
Elevation datasets.
Currently implemented for WorldClim as WorldClim{Elevation}
.
See the getraster
docs for implementation details.
RasterDataSources.LandCover
— TypeLandCover <: RasterDataSet
Land-cover datasets.
Currently implemented for EarthEnv as EarchEnv{LandCover}
.
See the getraster
docs for implementation details.
RasterDataSources.HabitatHeterogeneity
— TypeHabitatHeterogeneity <: RasterDataSet
Habitat heterogeneity datasets.
Currently implemented for EarchEnv as EarchEnv{HabitatHeterogeneity}
.
See the getraster
docs for implementation details.
RasterDataSources.Future
— TypeFuture{<:RasterDataSet,<:CMIPphase,<:ClimateModel,<:ClimateScenario}
Future climate datasets specified with a dataset, phase, model, and scenario.
Type Parameters
RasterDataSet
Currently BioClim
and Climate
are implemented for the CHELSA
data source.
CMIPphase
ClimateModel
Climate models can be chosen from:
`for
CMIP5`;
`for
CMIP6`;"
ClimateScenario
CMIP5 Climate scenarios are all RepresentativeConcentrationPathway
and can be chosen from: RCP26
, RCP45
, RCP60
, RCP85
CMIP6 Climate scenarios are all SharedSocioeconomicPathway
and can be chosen from: SSP126
, SSP245
, SSP370
, SSP585
However, note that not all climate scenarios are available for all models.
Example
using RasterDataSources
dataset = Future{BioClim, CMIP5, BNUESM, RCP45}
# output
Future{BioClim, CMIP5, BNUESM, RCP45}
Currently Future
is only implented for CHELSA
datasource = CHELSA{Future{BioClim, CMIP5, BNUESM, RCP45}}
Models, phases and scenarios for Future
data.
RasterDataSources.ClimateModel
— TypeClimateModel
Abstract supertype for climate models use in Future
datasets.
RasterDataSources.CMIPphase
— TypeCMIPphase
Abstract supertype for phases of the CMIP, the Coupled Model Intercomparison Project.
Subtypes are CMIP5
and CMIP6
.
RasterDataSources.CMIP5
— TypeCMIP5 <: CMIPphase
The Coupled Model Intercomparison Project, Phase 5.
RasterDataSources.CMIP6
— TypeCMIP6 <: CMIPphase
The Coupled Model Intercomparison Project, Phase 6.
RasterDataSources.ClimateScenario
— TypeClimateScenario
Abstract supertype for scenarios used in CMIPphase
models.
RasterDataSources.RepresentativeConcentrationPathway
— TypeRepresentativeConcentrationPathway
Abstract supertype for Representative Concentration Pathways (RCPs) for CMIP5
.
Subtypes are: RCP26
, RCP45
, RCP60
, RCP85
RasterDataSources.SharedSocioeconomicPathway
— TypeSharedSocioeconomicPathway
Abstract supertype for Shared Socio-economic Pathways (SSPs) for CMIP6
.
Subtypes are: SSP126
, SSP245
, SSP370, SSP585
Other
RasterDataSources.Values
— TypeValues <: DataMode
Get the dataset as regular measured values.
RasterDataSources.Deciles
— TypeDeciles <: DataMode
Get the dataset in relative deciles.
Internal interface
These methods are not exported at this stage, but are for the most part internally consistent. Any new sources added to the package should use these methods in a consistent way for readability, consistency and the potential to use them for other things later.
RasterDataSources.layerkeys
— Functionlayerkeys(T::Type{<:ModisProduct}) => Tuple
Tuple
of Symbol
s corresponding to the available layers for a given product. May issue a request to MODIS server to get the layers list, or might just read this information if the correctly named file is available.
RasterDataSources.rastername
— Functionrastername(source::Type, [layer]; kw...)
Returns the name of the file, without downloading it.
Arguments are the same as for getraster
Returns a String
or multiple Strings
.
RasterDataSources.rasterpath
— Functionrasterpath(source::Type, [layer]; kw...)
Returns the name of the file, without downloading it.
Arguments are the same as for getraster
Returns a String
or multiple Strings
.
RasterDataSources.rasterurl
— Functionrasterurl(source::Type, [layer]; kw...)
If the file has a single url, returns it without downloading.
Arguments are the same as for getraster
.
Returns a URIs.jl URI
or mulitiple URI
s.
RasterDataSources.zipname
— Functionzipname(source::Type, [layer]; kw...)
If the url is a zipped file, returns its name.
Arguments are as the same for getraster
where possible.
Returns a String
or multiple Strings
.
RasterDataSources.zippath
— Functionzippath(source::Type, [layer]; kw...)
If the url is a zipped file, returns its path when downloaded. (This may not exist after extraction with getraster
)
Arguments are the same as for getraster
where possible.
Returns a String
or multiple Strings
.
RasterDataSources.zipurl
— Functionzipurl(source::Type, [layer]; kw...)
If the url is a zipped file, returns its zip path without downloading.
Arguments are the same as for getraster
where possible.
Returns a URIs.jl URI
or mulitiple URI
s.
Internal MODIS interface
Unlike all the other currently supported data sources, MODIS data is not available online in raster file format. Building rasters out of the available information therefore requires internal functions that are not exported. They might be extended as needed if other similar sources get supported.
Requesting to server and building raster files
RasterDataSources.modis_request
— Functionmodis_request(T::Type{<:ModisProduct}, args...)
Lowest level function for requests to modis server. All arguments are assumed correct.
Arguments
layer
:String
matching the "exact" layer name (i.e. as it is written in the MODIS dataset itself) for the given product. e.g."250m_16_days_EVI"
.lat
,lon
,km_ab
,km_lr
in correct typesfrom
,to
:String
s of astronomical dates for start and end dates of downloaded data, e.g."A2002033"
for "2002-02-02"
Returns a NamedTuple
of information relevant to build a raster header, and a Vector
of Dict
s containing raster data, directly downloaded from MODIS. Those will almost always directly be passed to RasterDataSources.process_subset
RasterDataSources.process_subset
— Functionprocess_subset(T::Type{<:ModisProduct}, subset::Vector{Any}, pars::NamedTuple)
Process a raw subset and argument parameters and create several raster files. Any already existing file is not overwritten.
For each band, a separate folder is created, containing a file for each of the required dates. This is inspired by the way WorldClim{Climate} treats the problem of possibly having to download several dates AND bands.
Can theoretically be used for MODIS data that does not directly come from RasterDataSources.modis_request
, but caution is advised.
Returns the filepath/s of the created or pre-existing files.
Miscellaneous
RasterDataSources.product
— Functionproduct(T::Type{<:ModisProduct})
Extracts ModisProduct
product name as a String
RasterDataSources.sinusoidal_to_latlon
— Functionsinusoidal_to_latlon(x::Real, y::Real)
Convert x and y in sinusoidal projection to lat and lon in dec. degrees
The takes care of coordinate conversions. This is not ideal in terms of network use but guarantees that the coordinates are correct.