Skip to content

Commit

Permalink
Breaking: Split up dependencies with package extensions (#450)
Browse files Browse the repository at this point in the history
* move everything to extentions

* more extensions

* add all the extensions

* fix imports

* only use Aqua on 1.9+

* test fixes

* reorganise RDS

* fix Requires

* update doctests for extensions

* we need to test on 1.6 now

* fix Requires for old julia versions

* test on 1.8

* add makie back

* a comma

* fix docs

* add docs deps

* bugfix netcdf

* fixes

* JET checks

* fix cleankeys

* dont test stale deps

* bugfixes

* fix docs type

* add all extensions to docs make.jl

* add HDF5 to docs deps

* add CT dep to docs

* windows cant handle it

* bugfixes

* explicitly load modules in docs

* add missing HDF5 ext in docs
  • Loading branch information
rafaqz committed Jun 3, 2023
1 parent b625068 commit 5d47171
Show file tree
Hide file tree
Showing 46 changed files with 587 additions and 384 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ jobs:
fail-fast: true
matrix:
version:
- '1.8'
- '1'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
# - windows-latest
arch:
- x64
steps:
Expand Down
25 changes: 18 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ version = "0.7.2"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
Expand All @@ -17,14 +15,11 @@ FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
Flatten = "4c728ea3-d9ee-5c9a-9642-b6f7d7dc04fa"
GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
RasterDataSources = "3cb90ccd-e1b6-4867-9617-4276c8b2ca36"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Expand Down Expand Up @@ -57,21 +52,37 @@ Setfield = "0.6, 0.7, 0.8, 1"
julia = "1.8"

[extensions]
RastersMakie = "Makie"
RastersArchGDALExt = "ArchGDAL"
RastersCoordinateTransformationsExt = "CoordinateTransformations"
RastersHDF5Ext = "HDF5"
RastersMakieExt = "Makie"
RastersNCDatasetsExt = "NCDatasets"
RastersRasterDataSourcesExt = "RasterDataSources"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
CFTime = "179af706-886a-5703-950a-314cd64e0468"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
RasterDataSources = "3cb90ccd-e1b6-4867-9617-4276c8b2ca36"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "CFTime", "DataFrames", "GeometryBasics", "Plots", "SafeTestsets", "Shapefile", "Statistics", "Test"]
test = ["Aqua", "ArchGDAL", "CFTime", "CoordinateTransformations", "DataFrames", "GeometryBasics", "HDF5", "NCDatasets", "Plots", "RasterDataSources", "SafeTestsets", "Shapefile", "Statistics", "Test"]

[weakdeps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
RasterDataSources = "3cb90ccd-e1b6-4867-9617-4276c8b2ca36"
6 changes: 5 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
CFTime = "179af706-886a-5703-950a-314cd64e0468"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GBIF2 = "dedd4f52-e074-43bf-924d-d6bce14ad628"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
RasterDataSources = "3cb90ccd-e1b6-4867-9617-4276c8b2ca36"
Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4"
14 changes: 12 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Documenter, Rasters, Plots, Logging, Statistics, Dates
using Documenter, Rasters, Plots, Logging, Statistics, Dates,
RasterDataSources, ArchGDAL, NCDatasets, HDF5, CoordinateTransformations
import Makie, CairoMakie

using Rasters.LookupArrays, Rasters.Dimensions
Expand All @@ -20,8 +21,17 @@ flush_info_and_warnings()
Logging.disable_logging(Logging.Warn)

# Make the docs, without running the tests again
# We need to explicitly add all the extensions here
makedocs(
modules = [Rasters],
modules = [
Rasters,
Base.get_extension(Rasters, :RastersArchGDALExt),
Base.get_extension(Rasters, :RastersCoordinateTransformationsExt),
Base.get_extension(Rasters, :RastersHDF5Ext),
Base.get_extension(Rasters, :RastersMakieExt),
Base.get_extension(Rasters, :RastersNCDatasetsExt),
Base.get_extension(Rasters, :RastersRasterDataSourcesExt),
],
sitename = "Rasters.jl",
strict = true,
clean = false,
Expand Down
33 changes: 16 additions & 17 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ e.g. certain X/Y coordinates. The available selectors are listed here:
Use the `..` selector to take a `view` of madagascar:

```@example
using Rasters, Plots
using Rasters, RasterDataSources, ArchGDAL, Plots
A = Raster(WorldClim{BioClim}, 5)
madagascar = view(A, X(43.25 .. 50.48), Y(-25.61 .. -12.04)) # Note the space between .. -12
plot(madagascar)
Expand Down Expand Up @@ -177,7 +177,7 @@ 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):

```julia
using Rasters, Plots
using Rasters, RasterDataSources, ArchGDAL, Plots
A = Raster(WorldClim{BioClim}, 5)
plot(A; max_res=3000)
```
Expand All @@ -190,7 +190,7 @@ To obtain tiled plots for 3D rasters and RasterStacks, use the function `Rasters
```@example makie
using CairoMakie # hide
CairoMakie.activate!(px_per_unit = 2) # hide
using Rasters, CairoMakie
using Rasters, CairoMakie, RasterDataSources, ArchGDAL
A = Raster(WorldClim{BioClim}, 5)
Makie.plot(A)
```
Expand All @@ -203,7 +203,7 @@ This netcdf file only has one layer, if it has more we could use `RasterStack`
instead.

```@example nc
using Rasters, Plots
using Rasters, NCDatasets, Plots
url = "https://www.unidata.ucar.edu/software/netcdf/examples/tos_O1_2001-2002.nc";
filename = download(url, "tos_O1_2001-2002.nc");
A = Raster(filename)
Expand Down Expand Up @@ -265,7 +265,7 @@ A[Y(Near(20.0)), Ti(1)] |> plot
Load occurrences for the Mountain Pygmy Possum using GBIF.jl

```@example sdm
using Rasters, GBIF2, Plots
using Rasters, RasterDataSources, ArchGDAL, GBIF2, Plots
records = GBIF2.occurrence_search("Burramys parvus"; limit=300)
```

Expand All @@ -280,7 +280,7 @@ Get BioClim layers and subset to south-east Australia

```@example sdm
A = RasterStack(WorldClim{BioClim}, (1, 3, 7, 12))
se_aus = A[X(138 .. 155), Y(-40 .. -25), Band(1)]
se_aus = A[X(138 .. 155), Y(-40 .. -25)]
```

Plot BioClim predictors and scatter occurrence points on all subplots
Expand Down Expand Up @@ -316,7 +316,7 @@ then `mosaic` together to make a single plot.
First, get the country boundary shape files using GADM.jl.

```@example mask
using Rasters, Shapefile, Plots, Dates, Downloads
using Rasters, RasterDataSources, ArchGDAL, Shapefile, Plots, Dates, Downloads, NCDatasets
# Download the shapefile
shapefile_url = "https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp"
Expand All @@ -330,11 +330,10 @@ norway_border = shapes.shapes[53]
sweden_border = shapes.shapes[54]
```

Then load raster data. We load some worldclim layers using `RasterDataSources` via
Rasters.jl, and drop the Band dimension.
Then load raster data. We load some worldclim layers using `RasterDataSources` via Rasters.jl:

```@example mask
climate = RasterStack(WorldClim{Climate}, (:tmin, :tmax, :prec, :wind); month=July)[Band(1)]
climate = RasterStack(WorldClim{Climate}, (:tmin, :tmax, :prec, :wind); month=July)
```

`mask` Denmark, Norway and Sweden from the global dataset using their border polygon,
Expand Down Expand Up @@ -425,13 +424,13 @@ arrays of common raster file types. These methods also work for entire

### 2-D rasters in Makie

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.
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.

```@example makie
using CairoMakie # hide
using CairoMakie, Makie
CairoMakie.activate!(px_per_unit = 2) # hide
using Makie # hide
using Rasters, CairoMakie
using Rasters, RasterDataSources, ArchGDAL
A = Raster(WorldClim{BioClim}, 5) # this is a 3D raster, so is not accepted.
B = A[:, :, 1] # this converts to a 2D raster which Makie accepts!
figure = Figure()
Expand Down Expand Up @@ -461,15 +460,15 @@ You can pass any theming keywords in, which are interpreted by Makie appropriate

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:


```@example makie
CairoMakie.set_theme!(Rasters.theme_rasters())
Rasters.rplot(stack)
```

### Plotting with `Observable`s

`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.
`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.

```@example makie
stack_obs = Observable(stack)
Expand Down Expand Up @@ -621,7 +620,7 @@ 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`.

```@example
using Rasters, Plots, Dates
using Rasters, RasterDataSources, ArchGDAL, Plots, Dates
A = Raster(WorldClim{Climate}, :tavg; month=June)
plot(A)
```
Expand Down
36 changes: 36 additions & 0 deletions ext/RastersArchGDALExt/RastersArchGDALExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module RastersArchGDALExt

@static if isdefined(Base, :get_extension) # julia < 1.9
using Rasters, ArchGDAL
else
using ..Rasters, ..ArchGDAL
end

import DiskArrays,
Extents,
Missings

using DimensionalData,
GeoFormatTypes,
GeoInterface

using Rasters.LookupArrays
using Rasters.Dimensions
using Rasters: GDALsource, AbstractProjected, RasterStackOrArray, FileArray,
RES_KEYWORD, SIZE_KEYWORD, CRS_KEYWORD, EXPERIMENTAL, GDAL_EMPTY_TRANSFORM,
GDAL_TOPLEFT_X, GDAL_WE_RES, GDAL_ROT1, GDAL_TOPLEFT_Y, GDAL_ROT2, GDAL_NS_RES

import Rasters: reproject, resample, warp

const RA = Rasters
const DD = DimensionalData
const DA = DiskArrays
const GI = GeoInterface
const LA = LookupArrays

include("gdal_source.jl")
include("reproject.jl")
include("resample.jl")
include("warp.jl")

end
Loading

0 comments on commit 5d47171

Please sign in to comment.