Skip to content

Commit 03a1c33

Browse files
committed
Update environment
1 parent e7a40a4 commit 03a1c33

14 files changed

+209
-149
lines changed

02-geoviz.qmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ In this book, we use **CairoMakie.jl**:
2424
import CairoMakie as Mke
2525
```
2626

27+
```{julia}
28+
#| echo: false
29+
#| output: false
30+
Mke.activate!(type = "png")
31+
```
32+
2733
::: {.callout-note}
2834

2935
We import the backend as `Mke` to avoid polluting the Julia

03-geoio.qmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ using GeoStats
1010
import CairoMakie as Mke
1111
```
1212

13+
```{julia}
14+
#| echo: false
15+
#| output: false
16+
Mke.activate!(type = "png")
17+
```
18+
1319
In order to disrupt existing practices and really develop
1420
something new in Julia, we had to make some hard decisions
1521
along the way. One of these decisions relates to how we are

04-geoproc.qmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ We will also assume that the Makie.jl backend is loaded:
2424
import CairoMakie as Mke
2525
```
2626

27+
```{julia}
28+
#| echo: false
29+
#| output: false
30+
Mke.activate!(type = "png")
31+
```
32+
2733
## Geometries
2834

2935
We provide a vast list of geometries, which are organized into two main classes,

05-transforms.qmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ using GeoStats
99
import CairoMakie as Mke
1010
```
1111

12+
```{julia}
13+
#| echo: false
14+
#| output: false
15+
Mke.activate!(type = "png")
16+
```
17+
1218
## Motivation
1319

1420
In **Part I** of the book, we learned that our `GeoTable` representation

06-projections.qmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ using GeoStats
99
import CairoMakie as Mke
1010
```
1111

12+
```{julia}
13+
#| echo: false
14+
#| output: false
15+
Mke.activate!(type = "png")
16+
```
17+
1218
In this chapter, we detach the concept of `Point` from its **geospatial coordinates**
1319
in a given [coordinate reference system](https://en.wikipedia.org/wiki/Spatial_reference_system)
1420
(CRS). We explain how the same point in the physical world can be represented with multiple

08-splitcombine.qmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ using GeoStats
99
import CairoMakie as Mke
1010
```
1111

12+
```{julia}
13+
#| echo: false
14+
#| output: false
15+
Mke.activate!(type = "png")
16+
```
17+
1218
In **Part II** of the book, we introduced **transform pipelines** to
1319
process the `values` and the `domain` of geotables using high-level
1420
abstractions that preserve geospatial information. In this chapter, we

09-geojoins.qmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ using GeoStats
99
import CairoMakie as Mke
1010
```
1111

12+
```{julia}
13+
#| echo: false
14+
#| output: false
15+
Mke.activate!(type = "png")
16+
```
17+
1218
Another important tool in geospatial data science is the **geospatial join**.
1319
We will introduce the concept with a practical example, and will explain how it
1420
is related to the standard [join](https://en.wikipedia.org/wiki/Join_(SQL)) of

10-correlation.qmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ using GeoStats
1010
import CairoMakie as Mke
1111
```
1212

13+
```{julia}
14+
#| echo: false
15+
#| output: false
16+
Mke.activate!(type = "png")
17+
```
18+
1319
In **Part II** and **Part III** of the book, we learned two important
1420
tools for *efficient* geospatial data science. We learned how **transform
1521
pipelines** can be used to prepare geospatial data for investigation, and

11-interpolation.qmd

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ using GeoStats
99
import CairoMakie as Mke
1010
```
1111

12+
```{julia}
13+
#| echo: false
14+
#| output: false
15+
Mke.activate!(type = "png")
16+
```
17+
1218
A very common task in geospatial data science is **geospatial interpolation**,
1319
i.e., predicting variables on geometries that lie between two or more geometries that
1420
have measurements. In this chapter, we will exploit **geospatial correlation**
@@ -60,7 +66,7 @@ With the measurements of the variable `z` in the geotable, and the domain of
6066
interpolation, we can use the `Interpolate` transform with the `IDW` model:
6167

6268
```{julia}
63-
interp = data |> Interpolate(grid, IDW())
69+
interp = data |> Interpolate(grid, model=IDW())
6470
```
6571

6672
```{julia}
@@ -90,7 +96,7 @@ increasing values of the exponent:
9096
fig = Mke.Figure()
9197
Mke.Axis(fig[1,1])
9298
for β in [1,2,3,4,5]
93-
interp = data |> Interpolate(grid, IDW(β))
99+
interp = data |> Interpolate(grid, model=IDW(β))
94100
Mke.lines!(interp[seg, "z"], label = "β=$β")
95101
end
96102
Mke.axislegend(position = :lb)
@@ -102,7 +108,7 @@ between the two locations. In addition, the IDW solution will converge
102108
to the nearest neighbor solution as $\beta \to \infty$:
103109

104110
```{julia}
105-
data |> Interpolate(grid, IDW(100)) |> viewer
111+
data |> Interpolate(grid, model=IDW(100)) |> viewer
106112
```
107113

108114
Custom distances from [Distances.jl](https://github.com/JuliaStats/Distances.jl)
@@ -152,7 +158,7 @@ to improvements in the estimates:
152158
```{julia}
153159
γ = GaussianVariogram(range=30.0)
154160
155-
data |> Interpolate(grid, Kriging(γ)) |> viewer
161+
data |> Interpolate(grid, model=Kriging(γ)) |> viewer
156162
```
157163

158164
In the previous chapter, we learned how the **range** of the variogram determines
@@ -164,7 +170,7 @@ fig = Mke.Figure()
164170
Mke.Axis(fig[1,1])
165171
for r in [10,20,30,40,50]
166172
γ = GaussianVariogram(range=r)
167-
interp = data |> Interpolate(grid, Kriging(γ))
173+
interp = data |> Interpolate(grid, model=Kriging(γ))
168174
Mke.lines!(interp[seg, "z"], label = "range=$r")
169175
end
170176
Mke.axislegend(position = :lb)
@@ -252,7 +258,7 @@ fit the `Kriging` model with a maximum number of neighbors with the
252258
`InterpolateNeighbors` transform:
253259

254260
```{julia}
255-
interp = samples |> InterpolateNeighbors(img.geometry, Kriging(γ))
261+
interp = samples |> InterpolateNeighbors(img.geometry, model=Kriging(γ))
256262
```
257263

258264
```{julia}

12-mining.qmd

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ We perform the interpolation of the `z` coordinate on the projected centroids of
230230
```{julia}
231231
centroids = unique(shadow.(centroid.(blocks)))
232232
233-
ztable = ztable |> Select("z") |> Interpolate(centroids, IDW())
233+
ztable = ztable |> Select("z") |> Interpolate(centroids, model=IDW())
234234
```
235235

236236
```{julia}
@@ -307,9 +307,9 @@ up to a given maximum lag:
307307
```{julia}
308308
maxlag = 300.0u"m"
309309
310-
ns = setdiff(names(samples), ["geometry"])
310+
vs = setdiff(names(samples), ["geometry"])
311311
312-
gs = [EmpiricalVariogram(samples, n, maxlag = maxlag) for n in ns]
312+
gs = [EmpiricalVariogram(samples, v, maxlag = maxlag) for v in vs]
313313
314314
γs = [GeoStatsFunctions.fit(Variogram, g, h -> 1 / h^2) for g in gs]
315315
```
@@ -330,19 +330,19 @@ function gammaplot(n, g, γ)
330330
Mke.current_figure()
331331
end
332332
333-
gammaplot(ns[1], gs[1], γs[1])
333+
gammaplot(vs[1], gs[1], γs[1])
334334
```
335335

336336
```{julia}
337-
gammaplot(ns[2], gs[2], γs[2])
337+
gammaplot(vs[2], gs[2], γs[2])
338338
```
339339

340340
```{julia}
341-
gammaplot(ns[3], gs[3], γs[3])
341+
gammaplot(vs[3], gs[3], γs[3])
342342
```
343343

344344
```{julia}
345-
gammaplot(ns[4], gs[4], γs[4])
345+
gammaplot(vs[4], gs[4], γs[4])
346346
```
347347

348348
Assuming that the variogram models are adequate, we can proceed to interpolation.
@@ -353,9 +353,11 @@ Given the domain of interpolation, the samples and the variogram models, we
353353
can perform interpolation with `InterpolateNeighbors`:
354354

355355
```{julia}
356-
models = [n => Kriging(γ) for (n, γ) in zip(ns, γs)]
356+
interps = map(vs, γs) do v, γ
357+
samples |> Select(v) |> InterpolateNeighbors(blocks, model=Kriging(γ))
358+
end
357359
358-
interp = samples |> InterpolateNeighbors(blocks, models...)
360+
interp = reduce(hcat, interps)
359361
```
360362

361363
Let's confirm that the interpolated values follow the same standard normal distribution:

0 commit comments

Comments
 (0)