Skip to content

Commit

Permalink
Update environment
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Jan 27, 2025
1 parent e7a40a4 commit 03a1c33
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 149 deletions.
6 changes: 6 additions & 0 deletions 02-geoviz.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ In this book, we use **CairoMakie.jl**:
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

::: {.callout-note}

We import the backend as `Mke` to avoid polluting the Julia
Expand Down
6 changes: 6 additions & 0 deletions 03-geoio.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ using GeoStats
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

In order to disrupt existing practices and really develop
something new in Julia, we had to make some hard decisions
along the way. One of these decisions relates to how we are
Expand Down
6 changes: 6 additions & 0 deletions 04-geoproc.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ We will also assume that the Makie.jl backend is loaded:
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

## Geometries

We provide a vast list of geometries, which are organized into two main classes,
Expand Down
6 changes: 6 additions & 0 deletions 05-transforms.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ using GeoStats
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

## Motivation

In **Part I** of the book, we learned that our `GeoTable` representation
Expand Down
6 changes: 6 additions & 0 deletions 06-projections.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ using GeoStats
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

In this chapter, we detach the concept of `Point` from its **geospatial coordinates**
in a given [coordinate reference system](https://en.wikipedia.org/wiki/Spatial_reference_system)
(CRS). We explain how the same point in the physical world can be represented with multiple
Expand Down
6 changes: 6 additions & 0 deletions 08-splitcombine.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ using GeoStats
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

In **Part II** of the book, we introduced **transform pipelines** to
process the `values` and the `domain` of geotables using high-level
abstractions that preserve geospatial information. In this chapter, we
Expand Down
6 changes: 6 additions & 0 deletions 09-geojoins.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ using GeoStats
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

Another important tool in geospatial data science is the **geospatial join**.
We will introduce the concept with a practical example, and will explain how it
is related to the standard [join](https://en.wikipedia.org/wiki/Join_(SQL)) of
Expand Down
6 changes: 6 additions & 0 deletions 10-correlation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ using GeoStats
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

In **Part II** and **Part III** of the book, we learned two important
tools for *efficient* geospatial data science. We learned how **transform
pipelines** can be used to prepare geospatial data for investigation, and
Expand Down
18 changes: 12 additions & 6 deletions 11-interpolation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ using GeoStats
import CairoMakie as Mke
```

```{julia}
#| echo: false
#| output: false
Mke.activate!(type = "png")
```

A very common task in geospatial data science is **geospatial interpolation**,
i.e., predicting variables on geometries that lie between two or more geometries that
have measurements. In this chapter, we will exploit **geospatial correlation**
Expand Down Expand Up @@ -60,7 +66,7 @@ With the measurements of the variable `z` in the geotable, and the domain of
interpolation, we can use the `Interpolate` transform with the `IDW` model:

```{julia}
interp = data |> Interpolate(grid, IDW())
interp = data |> Interpolate(grid, model=IDW())
```

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

```{julia}
data |> Interpolate(grid, IDW(100)) |> viewer
data |> Interpolate(grid, model=IDW(100)) |> viewer
```

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

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

```{julia}
interp = samples |> InterpolateNeighbors(img.geometry, Kriging(γ))
interp = samples |> InterpolateNeighbors(img.geometry, model=Kriging(γ))
```

```{julia}
Expand Down
20 changes: 11 additions & 9 deletions 12-mining.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ We perform the interpolation of the `z` coordinate on the projected centroids of
```{julia}
centroids = unique(shadow.(centroid.(blocks)))
ztable = ztable |> Select("z") |> Interpolate(centroids, IDW())
ztable = ztable |> Select("z") |> Interpolate(centroids, model=IDW())
```

```{julia}
Expand Down Expand Up @@ -307,9 +307,9 @@ up to a given maximum lag:
```{julia}
maxlag = 300.0u"m"
ns = setdiff(names(samples), ["geometry"])
vs = setdiff(names(samples), ["geometry"])
gs = [EmpiricalVariogram(samples, n, maxlag = maxlag) for n in ns]
gs = [EmpiricalVariogram(samples, v, maxlag = maxlag) for v in vs]
γs = [GeoStatsFunctions.fit(Variogram, g, h -> 1 / h^2) for g in gs]
```
Expand All @@ -330,19 +330,19 @@ function gammaplot(n, g, γ)
Mke.current_figure()
end
gammaplot(ns[1], gs[1], γs[1])
gammaplot(vs[1], gs[1], γs[1])
```

```{julia}
gammaplot(ns[2], gs[2], γs[2])
gammaplot(vs[2], gs[2], γs[2])
```

```{julia}
gammaplot(ns[3], gs[3], γs[3])
gammaplot(vs[3], gs[3], γs[3])
```

```{julia}
gammaplot(ns[4], gs[4], γs[4])
gammaplot(vs[4], gs[4], γs[4])
```

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

```{julia}
models = [n => Kriging(γ) for (n, γ) in zip(ns, γs)]
interps = map(vs, γs) do v, γ
samples |> Select(v) |> InterpolateNeighbors(blocks, model=Kriging(γ))
end
interp = samples |> InterpolateNeighbors(blocks, models...)
interp = reduce(hcat, interps)
```

Let's confirm that the interpolated values follow the same standard normal distribution:
Expand Down
Loading

0 comments on commit 03a1c33

Please sign in to comment.