Skip to content

Commit

Permalink
more orga
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarusA committed Dec 29, 2024
1 parent 1bc01c9 commit 6e91cb9
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 221 deletions.
6 changes: 6 additions & 0 deletions docs/src/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const navTemp = {
{ text: 'Manual',
items: [
{ text: 'Methods', link: '/manual/methods' },
{ text: 'cellarea', link: '/manual/cellarea' },
{ text: 'Array Operations', link: '/manual/array_operations' },
{ text: 'Data Sources', link: '/manual/data_sources' },
{ text: 'Plots',
Expand All @@ -31,6 +32,8 @@ const navTemp = {
},
{ text: 'Tutorials',
items: [
{ text: 'Spatial mean', link: '/tutorials/spatial_mean' },
{ text: 'Reprojection and resampling', link: '/tutorials/resample_warp'},
{ text: 'Species Distribution Modelling', link: '/tutorials/gbif_wflow' },
]
},
Expand Down Expand Up @@ -99,6 +102,7 @@ export default defineConfig({
{ text: 'Manual',
items: [
{ text: 'Methods', link: '/manual/methods' },
{ text: 'cellarea', link: '/manual/cellarea' },
{ text: 'Array Operations', link: '/manual/array_operations' },
{ text: 'Data Sources', link: '/manual/data_sources' },
{ text: 'Plots',
Expand All @@ -111,6 +115,8 @@ export default defineConfig({
},
{ text: 'Tutorials',
items: [
{ text: 'Spatial mean', link: '/tutorials/spatial_mean' },
{ text: 'Reprojection and resampling', link: '/tutorials/resample_warp'},
{ text: 'Species Distribution Modelling', link: '/tutorials/gbif_wflow' },
]
},
Expand Down
38 changes: 17 additions & 21 deletions docs/src/manual/cellarea.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,59 @@ CollapsedDocStrings=true
cellarea
```

`cellarea` computes the area of each cell in a raster.
This is useful for a number of reasons - if you have a variable like
Computing the area of each cell in a raster is useful for a number of reasons - if you have a variable like
population per cell, or elevation ([spatially extensive variables](https://r-spatial.org/book/05-Attributes.html#sec-extensiveintensive)),
you'll want to account for the fact that different cells have different areas.

`cellarea` returns a Raster with the same x and y dimensions as the input,
where each value in the raster encodes the area of the cell (in meters by default).

You can specify whether you want to compute the area in the plane of your projection
(`Planar()`), on a sphere of some radius (`Spherical(; radius=...)`).
<!-- or on an ellipsoid
(`Geodetic()`), using the first argument.-->

Let's construct a raster and see what this looks like! We'll keep it in memory.

The spherical <!-- and geodetic --> method relies on the [Proj.jl](https://github.com/JuliaGeo/Proj.jl) package to perform coordinate transformation, so that has to be loaded explicitly.
The spherical method relies on the [Proj.jl](https://github.com/JuliaGeo/Proj.jl) package to perform coordinate transformation, so that has to be loaded explicitly.

````@example cella
````@example cellarea
using Rasters, Proj
````

To construct a raster, we'll need to specify the x and y dimensions. These are called "lookups" in Rasters.jl.
To construct a raster, we'll need to specify the `x` and `y` dimensions. These are called `lookups` in `Rasters.jl.`

````@example cellarea
using Rasters.Lookups
````

We can now construct the x and y lookups. Here we'll use a start-at-one, step-by-five grid.
Note that we're specifying that the "sampling", i.e., what the coordinates actually mean,
is `Intervals(Start())`, meaning that the coordinates are the starting point of each interval.

This is in contrast to `Points()` sampling, where each index in the raster represents the value at a sampling point;
here, each index represents a grid cell, which is defined by the coordinate being at the start.

````@example cella
````@example cellarea
x = X(1:5:30; sampling = Intervals(Start()), crs = EPSG(4326))
y = Y(50:5:80; sampling = Intervals(Start()), crs = EPSG(4326))
y = Y(50:5:80; sampling = Intervals(Start()), crs = EPSG(4326));
nothing # hide
````

I have chosen the y-range here specifically so we can show the difference between spherical and planar `cellarea`.

````@example cella
````@ansi cellarea
ras = Raster(ones(x, y); crs = EPSG(4326))
````

We can just call `cellarea` on this raster, which returns cell areas in meters, on Earth, assuming it's a sphere:

````@example cella
````@ansi cellarea
cellarea(ras)
````

and if we plot it, you can see the difference in cell area as we go from the equator to the poles:

````@example cella
using Makie, CairoMakie# , GeoMakie
heatmap(ras; axis = (; aspect = DataAspect()))
````@example cellarea
using CairoMakie
heatmap(cellarea(ras); axis = (; aspect = DataAspect()))
````

We can also try this using the planar method, which simply computes the area of the rectangle using `area = x_side_length * y_side_length`:

````@example cella
````@ansi cellarea
cellarea(Planar(), ras)
````

Expand Down
4 changes: 0 additions & 4 deletions docs/src/manual/data_sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ They are always 3 dimensional, and have `Y`, `X` and [`Band`](@ref) dimensions.
using Rasters
````

````@docs
smapseries
````

## Writing file formats to disk

Files can be written to disk with ArchGDAL.jl and NCDatasets.jl backends using
Expand Down
67 changes: 0 additions & 67 deletions docs/src/manual/resample_warp.md

This file was deleted.

126 changes: 0 additions & 126 deletions docs/src/resample_proj.md

This file was deleted.

Loading

0 comments on commit 6e91cb9

Please sign in to comment.