Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/dev-sf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ jobs:

steps:
- name: Checkout Project
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Build book
run: |
Rscript -e 'install.packages("geocompkg", repos = c("https://geocompr.r-universe.dev", "https://cloud.r-project.org"), dependencies = TRUE, force = TRUE)'
Rscript -e 'remotes::install_github("r-spatial/sf")'
Rscript -e 'remotes::install_github("r-spatial/stars")'
Rscript -e 'remotes::install_github("rspatial/terra")'
#Rscript -e 'remotes::install_github("geocompx/geocompkg", dependencies = TRUE, force = TRUE)'
Rscript -e 'if (!requireNamespace("pak", quietly = TRUE)) install.packages("pak", repos = "https://cloud.r-project.org")'
Rscript -e 'pak::pak(c("r-spatial/sf", "r-spatial/stars", "rspatial/terra"))'
Rscript -e 'bookdown::render_book("index.Rmd")'
18 changes: 18 additions & 0 deletions .github/workflows/scheduled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Scheduled
on:
schedule:
- cron: '0 6 * * 1' # every Monday at 06:00 UTC
workflow_dispatch:
jobs:
bookdown:
name: Render-Book
runs-on: ubuntu-latest
permissions:
contents: read
container: ghcr.io/geocompx/suggests:latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Render Book
run: Rscript -e 'bookdown::render_book("index.Rmd")'
5 changes: 3 additions & 2 deletions 08-read-write-plot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ multilayer_rast = rast(multilayer_filepath)
All of the previous examples read spatial information from files stored on your hard drive.
However, GDAL also allows reading data directly from online resources, such as HTTP/HTTPS/FTP web resources.
The only thing we need to do is to add a `/vsicurl/` prefix before the path to the file.
This tells GDAL to use its virtual file system for network resources, which uses **HTTP Range requests** to fetch only the specific byte ranges needed for an operation rather than downloading the entire file.
Let's try it by connecting to the global monthly snow probability at 500-m resolution for the period 2000-2012.
Snow probability for December is stored as a Cloud Optimized GeoTIFF (COG) file (see Section \@ref(file-formats)) at [zenodo.org](https://zenodo.org/record/5774954/files/clm_snow.prob_esacci.dec_p.90_500m_s0..0cm_2000..2012_v2.0.tif).
To read an online file, we just need to provide its URL together with the `/vsicurl/` prefix.
Expand All @@ -304,8 +305,8 @@ snow
```

\index{COG}
Due to the fact that the input data is COG, we are actually not reading this file to our RAM, but rather creating a connection to it without obtaining any values.
Its values will be read if we apply any value-based operation (e.g., `crop()` or `extract()`).
When combined with the `/vsicurl/` prefix, COG files enable highly efficient remote data access.
Instead of reading the whole file into RAM, GDAL creates a connection that **selectively fetches** only the byte ranges needed for subsequent operations (e.g., `crop()` or `extract()`), making it possible to work with multi-gigabyte files over the internet almost as if they were local.
This allows us also to just read a tiny portion of the data without downloading the entire file.
For example, we can get the snow probability for December in Reykjavik (70%) by specifying its coordinates and applying the `extract()` function:

Expand Down
Loading