Skip to content

Commit 889e8b7

Browse files
jbisitsrafaqz
authored andcommitted
Documentation updates
1 parent 17e995d commit 889e8b7

13 files changed

+109
-110
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
docs/build
55
test/data
66
Manifest.toml
7+
.vscode

docs/src/index.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ e.g. certain X/Y coordinates. The available selectors are listed here:
1616

1717
| | |
1818
| :--------------------- | :----------------------------------------------------------------- |
19-
| `At(x)` | get the index exactly matching the passed in value(s) |
20-
| `Near(x)` | get the closest index to the passed in value(s) |
19+
| `At(x)` | get the index exactly matching the passed in value(s). |
20+
| `Near(x)` | get the closest index to the passed in value(s). |
2121
| `Where(f::Function)` | filter the array axis by a function of the dimension index values. |
2222
| `a..b`/`Between(a, b)` | get all indices between two values, excluding the high value. |
23-
| `Contains(x)` | get indices where the value x falls within an interval |
23+
| `Contains(x)` | get indices where the value x falls within an interval. |
2424

2525

2626
Use the `..` selector to take a `view` of madagascar:
@@ -56,7 +56,7 @@ Note that most regular Julia methods, such as `replace`, work as for a standard
5656
| | |
5757
| :------------------------ | :--------------------------------------------------------------------------- |
5858
| [`classify`](@ref) | classify values into categories. |
59-
| [`mask`](@ref) | mask and object by a polygon or `Raster` along `X/Y`, or other dimensions. |
59+
| [`mask`](@ref) | mask an object by a polygon or `Raster` along `X/Y`, or other dimensions. |
6060
| [`replace_missing`](@ref) | replace all missing values in an object and update `missingval`. |
6161

6262

@@ -158,7 +158,7 @@ We can also reassign dimensions, here `X` becomes `Z`:
158158
set(A, X => Z)
159159
```
160160

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

164164

@@ -202,9 +202,9 @@ Here we plot every third month in the first year, just using the regular index:
202202
A[Ti=1:3:12] |> plot
203203
```
204204

205-
Now plot the ocean temperatures areound the Americas in the first month of 2001.
205+
Now plot the ocean temperatures around the Americas in the first month of 2001.
206206
Notice we are using lat/lon coordinates and date/time instead of regular
207-
indexes: The time dimension uses `DateTime360Day`, so we need to load CFTime.jl
207+
indexes. The time dimension uses `DateTime360Day`, so we need to load CFTime.jl
208208
to index it with `Near`.
209209

210210
```@example nc
@@ -269,14 +269,14 @@ Extract the longitude/latitude value to a Vector of Tuple:
269269
coords = [(r.longitude, r.latitude) for r in records if !ismissing(r.longitude)]
270270
```
271271

272-
Get BioClim layers and subset to south-east australia
272+
Get BioClim layers and subset to south-east Australia
273273

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

279-
And plot BioClim predictors and scatter occurrence points on all subplots
279+
Plot BioClim predictors and scatter occurrence points on all subplots
280280

281281
```@example sdm
282282
p = plot(SE_aus);
@@ -302,7 +302,7 @@ df[1:5, :]
302302

303303
## Polygon masking, mosaic and plot
304304

305-
In this example we wil l `mask` the scandinavian countries with border polygons,
305+
In this example we will `mask` the Scandinavian countries with border polygons,
306306
then `mosaic` together to make a single plot.
307307

308308
First, get the country boundary shape files using GADM.jl.
@@ -322,14 +322,14 @@ norway_border = shapes.shapes[53]
322322
sweden_border = shapes.shapes[54]
323323
```
324324

325-
Then load raster data. We load some worldclim layers using RasterDataSources via
325+
Then load raster data. We load some worldclim layers using `RasterDataSources` via
326326
Rasters.jl, and drop the Band dimension.
327327

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

332-
`mask` denmark, norway and sweden from the global dataset using their border polygon,
332+
`mask` Denmark, Norway and Sweden from the global dataset using their border polygon,
333333
then trim the missing values. We pad `trim` with a 10 pixel margin.
334334

335335
```@example mask
@@ -419,7 +419,7 @@ arrays of common raster file types. These methods also work for entire
419419

420420
Spatial raster data is essentially just an `Array`. But `Raster` wrappers
421421
allow treating them as an array that maintains its spatial index, crs and other
422-
metadata through all transformations. This means the can always be plotted and
422+
metadata through all transformations. This means they can always be plotted and
423423
written to disk after applying most base Julia methods, and most `broadcast`s.
424424

425425
```@docs
@@ -441,7 +441,7 @@ RasterStack(T::Type{<:RasterDataSources.RasterDataSource})
441441

442442
### RasterSeries
443443

444-
A series is an meta-array that holds other files/data that is distributed over
444+
A series is a meta-array that holds other files/data that is distributed over
445445
some dimension, often time. These files/data can be `Raster`s or `RasterStack`s.
446446

447447
```@docs
@@ -529,7 +529,7 @@ smapseries
529529

530530
Files can be written to disk in all formats other than SMAP HDF5 using
531531
`write("filename.ext", A)`. See the docs for [`write`](@ref). They can (with
532-
some caveats) be written to different formats than they were loaded in,
532+
some caveats) be written to different formats than they were loaded in as,
533533
providing file-type conversion for spatial data.
534534

535535
Some metadata may be lost in formats that store little metadata, or where
@@ -603,7 +603,7 @@ zonal
603603

604604
### File operations
605605

606-
These Base and DimensionalData methods have specific Rasters.jl versions:
606+
These `Base` and `DimensionalData` methods have specific Rasters.jl versions:
607607

608608
```@docs
609609
modify

src/lookup.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ end
101101
Mapped(; order=AutoOrder(), span=AutoSpan(), sampling=AutoSampling(), crs=nothing, mappedcrs)
102102
103103
An [`AbstractSampled`]($DDabssampleddocs) `LookupArray`, where the dimension index has
104-
been mapped to another projection, usually lat/lon or `EPSG(4326)`.
104+
been mapped to another projection, usually lat/lon or `EPSG(4326)`.
105105
`Mapped` matches the dimension format commonly used in netcdf files.
106106
107107
Fields and behaviours are identical to [`Sampled`]($DDsampleddocs) with the addition of
@@ -144,7 +144,7 @@ struct AffineProjected{T,F,A<:AbstractVector{T},M,C,MC} <: LA.Unaligned{T,1}
144144
crs::C
145145
mappedcrs::MC
146146
end
147-
function AffineProjected(f;
147+
function AffineProjected(f;
148148
data=AutoIndex(), metadata=NoMetadata(), crs=nothing, mappedcrs=nothing, dim=AutoDim()
149149
)
150150
AffineProjected(f, data, metadata, crs, mappedcrs)
@@ -154,7 +154,7 @@ crs(lookup::AffineProjected) = lookup.crs
154154
mappedcrs(lookup::AffineProjected) = lookup.mappedcrs
155155

156156
DD.metadata(lookup::AffineProjected) = lookup.metadata
157-
function DD.rebuild(l::AffineProjected;
157+
function DD.rebuild(l::AffineProjected;
158158
affinemap=l.affinemap, data=l.data, metadata=metadata(l),
159159
crs=crs(l), mappedcrs=mappedcrs(l), dim=dims(l), args...
160160
)
@@ -174,12 +174,12 @@ function Dimensions.sliceunalligneddims(
174174
I = map((ud1, ud2), I) do d, i
175175
i isa Colon ? parent(lookup(d)) : i
176176
end
177-
177+
178178
af = lookup(ud1).affinemap
179179
# New resolution for step size changes
180180
M = af.linear * [step(I[1]) 0; 0 step(I[2])]
181181
# New of origin for slice
182-
v = af(collect(first.(I) .- 1))
182+
v = af(collect(first.(I) .- 1))
183183
# Create a new affine map
184184
affinemap = CoordinateTransformations.AffineMap(M, v)
185185
# Build new lookups with the affine map. Probably should define `set` to do this.
@@ -204,7 +204,7 @@ Other dimension lookups pass through unchanged.
204204
205205
This is used to e.g. save a netcdf file to GeoTiff.
206206
"""
207-
convertlookup(T::Type{<:LookupArray}, A::AbstractDimArray) =
207+
convertlookup(T::Type{<:LookupArray}, A::AbstractDimArray) =
208208
rebuild(A; dims=convertlookup(T, dims(A)))
209209
convertlookup(T::Type{<:LookupArray}, dims::Tuple) = map(d -> convertlookup(T, d), dims)
210210
convertlookup(T::Type{<:LookupArray}, d::Dimension) = rebuild(d, convertlookup(T, lookup(d)))
@@ -257,7 +257,7 @@ end
257257
"""
258258
setcrs(x, crs)
259259
260-
Set the crs of a `Raster`, `RasterStack`, `Tuple` of `Dimension`,or a `Dimension`.
260+
Set the crs of a `Raster`, `RasterStack`, `Tuple` of `Dimension`, or a `Dimension`.
261261
"""
262262
setcrs(dims::DimTuple, crs) = map(d -> setcrs(d, crs), dims)
263263
function setcrs(dim::Dimension, crs)

src/methods/aggregate.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct DisAg end
88
"""
99
aggregate(method, object, scale; filename, progress, skipmissing)
1010
11-
Aggregate a Raster, or all arrays in a RasterStack or RasterSeries, by `scale` using
11+
Aggregate a `Raster`, or all arrays in a `RasterStack` or `RasterSeries`, by `scale` using
1212
`method`.
1313
1414
# Arguments
@@ -28,7 +28,7 @@ When the aggregation `scale` of is larger than the array axis, the length of the
2828
# Keywords
2929
3030
- `progress`: show a progress bar.
31-
- `skipmissingval`: if `true`, any `missingval` will be skipped during aggregation, so that
31+
- `skipmissingval`: if `true`, any `missingval` will be skipped during aggregation, so that
3232
only areas of all missing values will be aggregated to `missingval`. If `false`, any
3333
aggegrated area containing a `missingval` will be assigned `missingval`.
3434
- `filename`: a filename to write to directly, useful for large files.
@@ -39,18 +39,18 @@ When the aggregation `scale` of is larger than the array axis, the length of the
3939
4040
```jldoctest
4141
using Rasters, Statistics, Plots
42-
using Rasters: Center
42+
using Rasters: Center
4343
st = read(RasterStack(WorldClim{Climate}; month=1))
4444
ag = aggregate(Center(), st, (Y(20), X(20)); skipmissingval=true, progress=false)
4545
plot(ag)
46-
savefig("build/aggregate_example.png")
46+
savefig("build/aggregate_example.png")
4747
# output
4848
4949
```
5050
5151
![aggregate](aggregate_example.png)
5252
53-
Note: currently it is faster to aggregate over memory-backed arrays.
53+
Note: currently it is faster to aggregate over memory-backed arrays.
5454
Use [`read`](@ref) on `src` before use where required.
5555
"""
5656
function aggregate end
@@ -120,11 +120,11 @@ When the aggregation `scale` of is larger than the array axis, the length of the
120120
# Keywords
121121
122122
- `progress`: show a progress bar.
123-
- `skipmissingval`: if `true`, any `missingval` will be skipped during aggregation, so that
123+
- `skipmissingval`: if `true`, any `missingval` will be skipped during aggregation, so that
124124
only areas of all missing values will be aggregated to `missingval`. If `false`, any
125125
aggegrated area containing a `missingval` will be assigned `missingval`.
126126
127-
Note: currently it is _much_ faster to aggregate over memory-backed arrays.
127+
Note: currently it is _much_ faster to aggregate over memory-backed arrays.
128128
Use [`read`](@ref) on `src` before use where required.
129129
"""
130130
function aggregate!(locus::Locus, dst::AbstractRaster, src, scale; kw...)
@@ -190,7 +190,7 @@ Disaggregate array, or all arrays in a stack or series, by some scale.
190190
191191
- `progress`: show a progress bar.
192192
193-
Note: currently it is faster to aggregate over memory-backed arrays.
193+
Note: currently it is faster to aggregate over memory-backed arrays.
194194
Use [`read`](@ref) on `src` before use where required.
195195
196196
"""
@@ -257,7 +257,7 @@ Disaggregate array `src` to array `dst` by some scale, using `method`.
257257
usually use in `getindex`. Using a `Selector` will determine the scale by the
258258
distance from the start of the index in the `src` array.
259259
260-
Note: currently it is faster to aggregate over memory-backed arrays.
260+
Note: currently it is faster to aggregate over memory-backed arrays.
261261
Use [`read`](@ref) on `src` before use where required.
262262
"""
263263
function disaggregate!(locus::Locus, dst::AbstractRaster, src, scale)
@@ -310,7 +310,7 @@ end
310310

311311
# Handle how methods like `mean` can change the type
312312
ag_eltype(method::Tuple{<:Locus,Vararg}, A) = eltype(A)
313-
function ag_eltype(method::Tuple{<:Any}, A)
313+
function ag_eltype(method::Tuple{<:Any}, A)
314314
method_returntype = typeof(method[1](zero(eltype(A))))
315315
promote_type(eltype(A), method_returntype)
316316
end

src/methods/classify.jl

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Create a new array with values in `x` classified by the values in `pairs`.
88
of `Fix2` e.g. `(>=(4), <(7))`, or an IntervalSets.jl interval, e.g. `3..9` or `OpenInterval(10, 12)`.
99
`pairs` can also be a `n * 3` matrix where each row is lower bounds, upper bounds, replacement.
1010
11-
If if tuples or a `Matrix` are used, the `lower` and `upper` keywords define
11+
If tuples or a `Matrix` are used, the `lower` and `upper` keywords define
1212
how the lower and upper boundaries are chosen.
1313
1414
If `others` is set other values not covered in `pairs` will be set to that values.
@@ -137,7 +137,7 @@ savefig("build/classify_bang_example.png")
137137
138138
$EXPERIMENTAL
139139
"""
140-
classify!(A::AbstractRaster, p1::Pair, pairs::Pair...; kw...) =
140+
classify!(A::AbstractRaster, p1::Pair, pairs::Pair...; kw...) =
141141
classify!(A, (p1, pairs...); kw...)
142142
function classify!(A::AbstractRaster, pairs;
143143
lower=(>=), upper=(<), others=nothing, missingval=missingval(A)
@@ -211,5 +211,3 @@ _compare(find::Base.Fix2, x, lower, upper) = find(x)
211211
_compare((l, u)::Tuple, x, lower, upper) = lower(x, l) && upper(x, u)
212212
_compare((l, u)::Tuple{<:Base.Fix2,<:Base.Fix2}, x, lower, upper) = l(x) && u(x)
213213
_compare(interval::LA.IntervalSets.Interval, x, lower, upper) = x in interval
214-
215-

src/methods/crop_extend.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ As `crop` is lazy, `filename` and `suffix` keywords don't apply.
1919
2020
# Example
2121
22-
Cropt to another raster:
22+
Crop to another raster:
2323
2424
```jldoctest
2525
using Rasters, Plots
@@ -34,7 +34,7 @@ nz_evenness = evenness[nz_bounds...]
3434
nz_range = crop(rnge; to=nz_evenness)
3535
plot(nz_range)
3636
37-
savefig("build/crop_example.png")
37+
savefig("build/nz_crop_example.png")
3838
# output
3939
```
4040
@@ -77,8 +77,8 @@ crop(x::RasterStackOrArray; to, kw...) = _crop_to(x, to; kw...)
7777
# crop `A` to values of dims of `to`
7878
function _crop_to(x, to; kw...)
7979
ext = _extent(to)
80-
if isnothing(ext)
81-
if isnothing(dims(to))
80+
if isnothing(ext)
81+
if isnothing(dims(to))
8282
throw(ArgumentError("No dims or extent available on `to` object of type $(typeof(to))"))
8383
else
8484
return _crop_to(x, dims(to); kw...)
@@ -90,7 +90,7 @@ end
9090
_crop_to(A, to::RasterStackOrArray; kw...) = _crop_to(A, dims(to); kw...)
9191
function _crop_to(x, to::DimTuple; atol=maybe_eps(to))
9292
# We can only crop to sampled dims (e.g. not categorical dims like Band)
93-
sampled = reduce(to; init=()) do acc, d
93+
sampled = reduce(to; init=()) do acc, d
9494
lookup(d) isa AbstractSampled ? (acc..., d) : acc
9595
end
9696
return _crop_to(x, Extents.extent(to))
@@ -247,7 +247,7 @@ _choosebounds((f1, f2), (a,)::Tuple{<:Dimension}, b::Tuple{<:Dimension}) = _choo
247247
_choosebounds((f1, f2), ::Tuple{}, ::Tuple{}) = ()
248248
_choosebounds((f1, f2), ::Tuple{}, (b,)::DimTuple) = bounds(b)
249249
_choosebounds((f1, f2), a::Tuple, ::Tuple{}) = a
250-
function _choosebounds((f1, f2), (a1, a2)::Tuple{<:Any,<:Any}, (b,)::Tuple{<:Dimension})
250+
function _choosebounds((f1, f2), (a1, a2)::Tuple{<:Any,<:Any}, (b,)::Tuple{<:Dimension})
251251
b1, b2 = bounds(b)
252252
return f1(a1, b1), f2(a2, b2)
253253
end

0 commit comments

Comments
 (0)