From e4e665f21fe0e3385d2681b74f720dbb537b27b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Hoffimann?= Date: Wed, 19 Jun 2024 14:47:41 -0300 Subject: [PATCH] Updates for latest release --- 01-geodata.qmd | 9 --------- 08-splitcombine.qmd | 29 +++++++++++++++++++++-------- 12-mining.qmd | 27 +++++++++++++-------------- Manifest.toml | 26 ++++++++++++++++---------- Project.toml | 1 - data/table.csv | 6 ------ preface.qmd | 3 +-- 7 files changed, 51 insertions(+), 50 deletions(-) delete mode 100644 data/table.csv diff --git a/01-geodata.qmd b/01-geodata.qmd index 73fee36..e7e27e7 100644 --- a/01-geodata.qmd +++ b/01-geodata.qmd @@ -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 diff --git a/08-splitcombine.qmd b/08-splitcombine.qmd index b6292c6..b95b10f 100644 --- a/08-splitcombine.qmd +++ b/08-splitcombine.qmd @@ -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), @@ -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: diff --git a/12-mining.qmd b/12-mining.qmd index 1f67691..0c4d83c 100644 --- a/12-mining.qmd +++ b/12-mining.qmd @@ -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:** @@ -25,7 +25,7 @@ economic assessment of a real mineral deposit. using GeoStats # IO modules -using CSV +using GeoIO # viz modules using PairPlots @@ -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 ``` @@ -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) ``` @@ -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) ``` @@ -226,7 +225,7 @@ 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 ``` @@ -234,7 +233,7 @@ 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()) ``` @@ -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) diff --git a/Manifest.toml b/Manifest.toml index 81373fa..f06f071 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -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"] @@ -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"] @@ -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"] @@ -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" @@ -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"] diff --git a/Project.toml b/Project.toml index 3058cf2..8fabd34 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/data/table.csv b/data/table.csv deleted file mode 100644 index f691ff7..0000000 --- a/data/table.csv +++ /dev/null @@ -1,6 +0,0 @@ -NAME,AGE,HEIGHT,GENDER -John,34,1.78,male -Mary,12,1.56,female -Paul,23,1.70,male -Anne,39,1.80,female -Kate,28,1.72,female \ No newline at end of file diff --git a/preface.qmd b/preface.qmd index e4aff56..8fb0399 100644 --- a/preface.qmd +++ b/preface.qmd @@ -118,7 +118,7 @@ pkg"activate @GDSJL" pkg"add GeoStats@0.59.0" # install IO module -pkg"add GeoIO@1.13.3" +pkg"add GeoIO@1.13.4" # install artifacts pkg"add GeoArtifacts@0.6.2" @@ -129,7 +129,6 @@ pkg"add PairPlots@2.7.3" # install other modules pkg"add DataFrames@1.6.1" -pkg"add CSV@0.10.14" ``` If you need to reproduce the exact same environment with