Skip to content

Commit

Permalink
Updates for latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Jun 19, 2024
1 parent 470e16c commit e4e665f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 50 deletions.
9 changes: 0 additions & 9 deletions 01-geodata.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,6 @@ with specific file formats:
- `XLSX.Worksheet` from [XLSX.jl](https://github.com/felipenoris/XLSX.jl)
- Databases from [JuliaDatabases](https://github.com/JuliaDatabases)

As an example, we consider the table representation of a `table.csv` file
stored on disk:

```{julia}
using CSV
CSV.File("data/table.csv")
```

The choice of table representation is a function of the application.

### Domain
Expand Down
29 changes: 21 additions & 8 deletions 08-splitcombine.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ We will use the `Bonnie` data set to illustrate our geospatial split-apply-combi
> It is issued under the Creative Commons Attribution-ShareAlike 4.0 International Public License.
```{julia}
using CSV
using GeoIO
gt = georef(CSV.File("data/bonnie.csv"), (:EAST, :NORTH, :RL))
gt = GeoIO.load("data/bonnie.csv", coords = ("EAST", "NORTH", "RL"))
```

It represents a 3D mineral deposit with grades in parts per million (ppm),
Expand All @@ -72,20 +72,33 @@ gt |> viewer
```

Let's clean the geotable using what we learned in previous chapters.
We will reject the column with sulfur, will drop missing values, and
will rename the variables for greater readability:
We will reject the column with sulfur, will rename the variables for
greater readability, and will drop missing values. We will also add
units to some of the variables using bracket notation:

```{julia}
clean = Reject("Sper") →
Rename("Agppm" => "Ag [ppm]",
"Auppm" => "Au [ppm]",
"Asppm" => "As [ppm]",
"Cuppm" => "Cu [ppm]",
"ISBD" => "ρ [Mg/m^3]",
"CODE" => "geo",
"OX" => "litho") →
DropMissing() →
Rename("Auppm" => "Au", "Agppm" => "Ag",
"Cuppm" => "Cu", "Asppm" => "As",
"CODE" => "geo", "OX" => "litho",
"ISBD" => "ρ")
Unitify()
gt = gt |> clean
```

::: {.callout-note}

The `Unitify` transform recognizes unit bracket notation in column names.
It adds the units specified within brackets to the values of the columns,
and removes the brackets from the column names.

:::

That is a lot better! Let's assume that we want to answer the following
business question:

Expand Down
27 changes: 13 additions & 14 deletions 12-mining.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ In this chapter, we will cover simple steps for resource estimation and
economic assessment of a real mineral deposit.

**TOOLS COVERED:** `@groupby`, `@transform`, `@combine`, `CLR`, `ProjectionPursuit`,
`EmpiricalVariogram`, `Kriging`, `Interpolate`, `InterpolateNeighbors`, `Map`, `Filter`,
`boundingbox`, `convexhull`, `viewer`
`EmpiricalVariogram`, `Kriging`, `Interpolate`, `InterpolateNeighbors`, `Shadow`,
`Map`, `Filter`, `boundingbox`, `convexhull`, `viewer`

**MODULES:**

Expand All @@ -25,7 +25,7 @@ economic assessment of a real mineral deposit.
using GeoStats
# IO modules
using CSV
using GeoIO
# viz modules
using PairPlots
Expand Down Expand Up @@ -60,7 +60,9 @@ of the centroids of the cylinders were stored:
```{julia}
url = "https://zenodo.org/record/7051975/files/drillholes.csv?download=1"
dtable = georef(CSV.File(download(url)), ("X", "Y", "Z"))
csv = download(url, tempname()*".csv")
dtable = GeoIO.load(csv, coords = ("X", "Y", "Z"))
dtable |> Select("Cu ppm") |> viewer
```
Expand Down Expand Up @@ -191,15 +193,12 @@ viz!(grid, alpha = 0.2)
Mke.current_figure()
```

Second, let's compute the `convexhull` of points projected on the horizontal plane:
Second, let's compute the `convexhull` of the `Shadow` of all points on the xy plane:

```{julia}
function proj(point)
x, y, z = to(point)
Point(x, y)
end
shadow(point) = point |> Shadow("xy")
points = proj.(dtable.geometry)
points = shadow.(dtable.geometry)
chull = convexhull(points)
```
Expand All @@ -214,7 +213,7 @@ We can filter the grid to retain `Hexahedron`s for which the projected centroid
is inside the `convexhull`:

```{julia}
active = findall(h -> proj(centroid(h)) ∈ chull, grid)
active = findall(h -> shadow(centroid(h)) ∈ chull, grid)
blocks = view(grid, active)
```
Expand All @@ -226,15 +225,15 @@ Let's create a simple terrain elevation model by interpolating the vertical
```{julia}
ztable = @chain dtable begin
@groupby(:HOLEID)
@transform(:Z = last(to(:geometry)), :geometry = proj(:geometry))
@transform(:Z = last(to(:geometry)), :geometry = shadow(:geometry))
@combine(:Z = first(:Z), :geometry = first(:geometry))
end
```

We perform the interpolation of the "Z" coordinate on the projected centroids of the blocks:

```{julia}
centroids = unique(proj.(centroid.(blocks)))
centroids = unique(shadow.(centroid.(blocks)))
ztable = ztable |> Select("Z") |> Interpolate(centroids, IDW())
```
Expand All @@ -246,7 +245,7 @@ ztable |> viewer
Finally, we can filter the blocks for which the "Z" coordinate is below the terrain:

```{julia}
p(h) = proj(centroid(h))
p(h) = shadow(centroid(h))
Z(h) = last(to(centroid(h)))
zdict = Dict(ztable.geometry .=> ztable.Z)
Expand Down
26 changes: 16 additions & 10 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.3"
julia_version = "1.10.4"
manifest_format = "2.0"
project_hash = "fd5683c081b6d9795d83d72d8cb6b8bf6e1482e8"
project_hash = "01ea7963ef90015f9a8a3384bfe71e594e2e87e0"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -877,9 +877,9 @@ version = "0.4.2"

[[deps.GeoIO]]
deps = ["ArchGDAL", "CSV", "Colors", "CommonDataModel", "FileIO", "Format", "GRIBDatasets", "GeoInterface", "GeoJSON", "GeoParquet", "GeoTables", "GslibIO", "ImageIO", "Meshes", "NCDatasets", "PlyIO", "PrecompileTools", "PrettyTables", "ReadVTK", "Shapefile", "StaticArrays", "Tables", "TransformsBase", "Unitful", "VTKBase", "WriteVTK"]
git-tree-sha1 = "ff9991c2ab560bd20d967c40fa02fde53ee93a2f"
git-tree-sha1 = "7a60e047155a8b57e6fe70be769609388aa4372d"
uuid = "f5a160d5-e41d-4189-8b61-d57781c419e3"
version = "1.13.3"
version = "1.13.4"

[[deps.GeoInterface]]
deps = ["Extents"]
Expand Down Expand Up @@ -1151,9 +1151,15 @@ version = "0.3.1"

[[deps.InlineStrings]]
deps = ["Parsers"]
git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461"
git-tree-sha1 = "86356004f30f8e737eff143d57d41bd580e437aa"
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
version = "1.4.0"
version = "1.4.1"

[deps.InlineStrings.extensions]
ArrowTypesExt = "ArrowTypes"

[deps.InlineStrings.weakdeps]
ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd"

[[deps.IntelOpenMP_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
Expand Down Expand Up @@ -1652,9 +1658,9 @@ version = "0.1.0"

[[deps.NearestNeighbors]]
deps = ["Distances", "StaticArrays"]
git-tree-sha1 = "e4a9d37f0ee694da969def1f0dd4654642dfb51c"
git-tree-sha1 = "91a67b4d73842da90b526011fa85c5c4c9343fe0"
uuid = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
version = "0.4.17"
version = "0.4.18"

[[deps.NelderMead]]
git-tree-sha1 = "25abc2f9b1c752e69229f37909461befa7c1f85d"
Expand Down Expand Up @@ -2316,9 +2322,9 @@ version = "1.0.1"

[[deps.TableTransforms]]
deps = ["AbstractTrees", "CategoricalArrays", "CoDa", "ColumnSelectors", "DataScienceTraits", "Distributions", "InverseFunctions", "LinearAlgebra", "NelderMead", "PrettyTables", "Random", "Statistics", "StatsBase", "Tables", "Transducers", "TransformsBase", "Unitful"]
git-tree-sha1 = "2404c9860c305b86deb818564ef7f4e732837626"
git-tree-sha1 = "6ad8c3cc51d7390b9fe9e709154a9f995a416c0e"
uuid = "0d432bfd-3ee1-4ac1-886a-39f05cc69a3e"
version = "1.31.2"
version = "1.31.3"

[[deps.Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits"]
Expand Down
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Cairo_jll = "83423d85-b0ee-5818-9007-b63ccbeb887a"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
6 changes: 0 additions & 6 deletions data/table.csv

This file was deleted.

3 changes: 1 addition & 2 deletions preface.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pkg"activate @GDSJL"
pkg"add [email protected]"

# install IO module
pkg"add [email protected].3"
pkg"add [email protected].4"

# install artifacts
pkg"add [email protected]"
Expand All @@ -129,7 +129,6 @@ pkg"add [email protected]"

# install other modules
pkg"add [email protected]"
pkg"add [email protected]"
```

If you need to reproduce the exact same environment with
Expand Down

0 comments on commit e4e665f

Please sign in to comment.