Skip to content

Commit

Permalink
Deploy commit: improves style 144b77c
Browse files Browse the repository at this point in the history
  • Loading branch information
Nowosad committed Aug 26, 2023
1 parent 64819d8 commit 7a2aa22
Show file tree
Hide file tree
Showing 35 changed files with 563 additions and 666 deletions.
11 changes: 2 additions & 9 deletions 02-spatial-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ install.packages("spData")
install.packages("spDataLarge", repos = "https://nowosad.r-universe.dev")
```

<!-- toDo: explain (maybe also move tmapv4 to main) -->


```r
remotes::install_github("r-tmap/tmap@v4")
Expand Down Expand Up @@ -888,15 +890,6 @@ india_buffer_without_s2 = st_buffer(india, 1)
#> dist is assumed to be in decimal degrees (arc_degrees).
```


```
#>
#> Attaching package: 'tmap'
#> The following object is masked from 'package:datasets':
#>
#> rivers
```

<div class="figure" style="text-align: center">
<img src="02-spatial-data_files/figure-html/s2example-1.png" alt="Example of the consequences of turning off the S2 geometry engine. Both representations of a buffer around India were created with the same command but the purple polygon object was created with S2 switched on, resulting in a buffer of 1 m. The larger light green polygon was created with S2 switched off, resulting in a buffer with inaccurate units of degrees longitude/latitude." width="100%" />
<p class="caption">(\#fig:s2example)Example of the consequences of turning off the S2 geometry engine. Both representations of a buffer around India were created with the same command but the purple polygon object was created with S2 switched on, resulting in a buffer of 1 m. The larger light green polygon was created with S2 switched off, resulting in a buffer with inaccurate units of degrees longitude/latitude.</p>
Expand Down
Binary file modified 02-spatial-data_files/figure-html/s2example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions 03-attribute-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ library(dplyr) # tidyverse package for data frame manipulation

```r
library(spData) # spatial data package introduced in Chapter 2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
```

- Also ensure you have installed the **tidyr** package, or the **tidyverse** of which it is a part, if you want to run data 'tidying' operations in Section \@ref(vec-attr-creation).
Expand Down
1 change: 0 additions & 1 deletion 05-geometry-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ Therefore, the first step is to project the data into some adequate projected CR

```r
us_states2163 = st_transform(us_states, "EPSG:2163")
us_states2163 = us_states2163
```

`st_simplify()` works equally well with projected polygons:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 05-geometry-operations_files/figure-html/points-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 05-geometry-operations_files/figure-html/seine-simp-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 05-geometry-operations_files/figure-html/us-regions-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 11 additions & 16 deletions 09-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ This figure shows four ways of coloring regions in New Zealand depending on medi
```r
tm_shape(nz) + tm_polygons(fill = "Median_income")
tm_shape(nz) + tm_polygons(fill = "Median_income",
fill.scale = tm_scale(breaks = c(0, 30000, 40000, 50000)))
fill.scale = tm_scale(breaks = c(0, 30000, 40000, 50000)))
tm_shape(nz) + tm_polygons(fill = "Median_income",
fill.scale = tm_scale(n = 10))
tm_shape(nz) + tm_polygons(fill = "Median_income",
Expand Down Expand Up @@ -378,8 +378,10 @@ Sequential palettes can be single (`greens` goes from light to dark blue, for ex


```r
tm_shape(nz) + tm_polygons("Median_income", fill.scale = tm_scale(values = "greens"))
tm_shape(nz) + tm_polygons("Median_income", fill.scale = tm_scale(values = "yl_gn_bu"))
tm_shape(nz) +
tm_polygons("Median_income", fill.scale = tm_scale(values = "greens"))
tm_shape(nz) +
tm_polygons("Median_income", fill.scale = tm_scale(values = "yl_gn_bu"))
```

The third group, diverging palettes, typically range between three distinct colors (purple-white-green in Figure \@ref(fig:colpal)) and are usually created by joining two single-color sequential palettes with the darker colors at each end.
Expand All @@ -390,7 +392,8 @@ The reference point's value can be adjusted in **tmap** using the `midpoint` arg
```r
tm_shape(nz) +
tm_polygons("Median_income",
fill.scale = tm_scale_continuous(values = "pu_gn_div", midpoint = 28000))
fill.scale = tm_scale_continuous(values = "pu_gn_div",
midpoint = 28000))
```

<div class="figure" style="text-align: center">
Expand Down Expand Up @@ -433,9 +436,10 @@ Other than that, we can also customize the location of the legend using the `pos

```r
map_nza2 = tm_shape(nz) +
tm_polygons(fill = "Land_area", fill.legend = tm_legend(title = legend_title,
orientation = "landscape",
position = tm_pos_out("center", "bottom")))
tm_polygons(fill = "Land_area",
fill.legend = tm_legend(title = legend_title,
orientation = "landscape",
position = tm_pos_out("center", "bottom")))
```

The legend position (and also the position of several other map elements in **tmap**) can be customized using one of a few functions.
Expand Down Expand Up @@ -1206,15 +1210,6 @@ nz_carto = cartogram_cont(nz, "Median_income", itermax = 5)
tm_shape(nz_carto) + tm_polygons("Median_income")
```


```
#> Warning: Some legend items or map compoments do not fit well (e.g. due to the
#> specified font size).
#> Warning: Some legend items or map compoments do not fit well (e.g. due to the
#> specified font size).
```

<div class="figure" style="text-align: center">
<img src="09-mapping_files/figure-html/cartomap1-1.png" alt="Comparison of standard map (left) and continuous area cartogram (right)." width="100%" />
<p class="caption">(\#fig:cartomap1)Comparison of standard map (left) and continuous area cartogram (right).</p>
Expand Down
66 changes: 19 additions & 47 deletions 10-gis.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,28 +163,12 @@ Both polygon datasets are available in the **spData** package, and for both we w


```r

data("incongruent", "aggregating_zones", package = "spData")
incongr_wgs = st_transform(incongruent, "EPSG:4326")
aggzone_wgs = st_transform(aggregating_zones, "EPSG:4326")
```


```
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#>
#> Attaching package: 'tmap'
#> The following object is masked from 'package:datasets':
#>
#> rivers
```

<div class="figure" style="text-align: center">
<img src="10-gis_files/figure-html/uniondata-1.png" alt="Illustration of two areal units: incongruent (black lines) and aggregating zones (red borders)." width="100%" />
<p class="caption">(\#fig:uniondata)Illustration of two areal units: incongruent (black lines) and aggregating zones (red borders).</p>
Expand Down Expand Up @@ -938,11 +922,9 @@ library(rstac)
# and search for images intersecting our AOI
s = stac("https://earth-search.aws.element84.com/v0")
items = s |>
stac_search(
collections = "sentinel-s2-l2a-cogs",
bbox = c(7.1, 51.8, 7.2, 52.8),
datetime = "2020-01-01/2020-12-31"
) |>
stac_search(collections = "sentinel-s2-l2a-cogs",
bbox = c(7.1, 51.8, 7.2, 52.8),
datetime = "2020-01-01/2020-12-31") |>
post_request() |>
items_fetch()
```
Expand Down Expand Up @@ -1011,36 +993,26 @@ p = processes() # load available processes
collections = list_collections() # load available collections
formats = list_file_formats() # load available output formats
# Load Sentinel-2 collection
s2 = p$load_collection(
id = "SENTINEL2_L2A",
spatial_extent = list(
west = 7.5, east = 8.5,
north = 51.1, south = 50.1
),
temporal_extent = list("2021-01-01", "2021-01-31"),
bands = list("B04", "B08")
)
s2 = p$load_collection(id = "SENTINEL2_L2A",
spatial_extent = list(west = 7.5, east = 8.5,
north = 51.1, south = 50.1),
temporal_extent = list("2021-01-01", "2021-01-31"),
bands = list("B04", "B08"))
# Compute NDVI vegetation index
compute_ndvi = p$reduce_dimension(
data = s2, dimension = "bands",
reducer = function(data, context) {
(data[2] - data[1]) / (data[2] + data[1])
}
)
compute_ndvi = p$reduce_dimension(data = s2, dimension = "bands",
reducer = function(data, context) {
(data[2] - data[1]) / (data[2] + data[1])
})
# Compute maximum over time
reduce_max = p$reduce_dimension(
data = compute_ndvi, dimension = "t",
reducer = function(x, y) {
max(x)
}
)
reduce_max = p$reduce_dimension(data = compute_ndvi, dimension = "t",
reducer = function(x, y) {
max(x)
})
# Export as GeoTIFF
result = p$save_result(reduce_max, formats$output$GTiff)
# Login, see https://docs.openeo.cloud/getting-started/r/#authentication
login(
login_type = "oidc", provider = "egi",
config = list(client_id = "...", secret = "...")
)
login(login_type = "oidc", provider = "egi",
config = list(client_id = "...", secret = "..."))
# Execute processes
compute_result(graph = result, output_file = tempfile(fileext = ".tif"))
```
Expand Down
8 changes: 0 additions & 8 deletions 16-synthesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ The code chunk below illustrates this by using three functions, covered in Chapt

```r
library(spData)
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
nz_u1 = sf::st_union(nz)
nz_u2 = aggregate(nz["Population"], list(rep(1, nrow(nz))), sum)
nz_u3 = dplyr::summarise(nz, t = sum(Population))
Expand Down
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h2>Note: Second Edition is under construction 🏗</h2>
<footer class="bg-primary text-light mt-5"><div class="container"><div class="row">

<div class="col-12 col-md-6 mt-3">
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2023-08-25.</p>
<p>"<strong>Geocomputation with R</strong>" was written by Robin Lovelace, Jakub Nowosad, Jannes Muenchow. It was last built on 2023-08-26.</p>
</div>

<div class="col-12 col-md-6 mt-3">
Expand Down
Loading

0 comments on commit 7a2aa22

Please sign in to comment.