Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Created February 6, 2025 06:03
Show Gist options
  • Select an option

  • Save mdsumner/b585e7fec63acb1e228c45f77af74830 to your computer and use it in GitHub Desktop.

Select an option

Save mdsumner/b585e7fec63acb1e228c45f77af74830 to your computer and use it in GitHub Desktop.
library(nert)
r <- read_smips(day = "2024-01-01")

## sources() finds the actual DSN (data source name, description) of the source data but this includes your TERN API key so we can't show that
library(terra)
par(mfrow = c(1, 5))
## get different zoom levels
for (overview in  -1:3) {  ## the first overview 0 is one-level coarser than native (-1 is native)
  plot(rast(sprintf("vrt://%s?ovr=%i", sources(r), overview)), main = sprintf("overview: %i", overview))
}

image

@mdsumner
Copy link
Copy Markdown
Author

mdsumner commented Feb 6, 2025

this plot shows where the points are that are out of range of the minmax of the valid data

library(nert)
r <- read_smips(day = "2024-01-01")

## sources() finds the actual DSN (data source name, description) of the source data but this includes your TERN API key so we can't show that
library(terra)

mm <- terra::minmax(r)
mm
par(mfrow = c(1, 5))
## get different zoom levels
for (overview in  -1:3) {  ## the first overview 0 is one-level coarser than native (-1 is native)
  rr <- rast(sprintf("vrt://%s?ovr=%i", sources(r), overview))
  plot(rr, range = mm, main = sprintf("overview: %i", overview))
  bad <- values(rr)[,1] < mm[1] | values(rr)[,1] > mm[2]
  points(xyFromCell(rr, which(bad)), col = "red", pch = "+", cex = .8)
}


image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment