Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Jan 15, 2024
1 parent 9451423 commit 75d9737
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ VignetteBuilder:
knitr
Config/Needs/coverage: covr
Config/Needs/website: ragg, reactable, rnaturalearth, tidyverse,
ropenspain/rostemplate, ropensci/rnaturalearthhires
ropenspain/rostemplate, ropensci/rnaturalearthhires, devtools
Config/testthat/edition: 3
Config/testthat/parallel: true
Copyright: © EuroGeographics for the administrative boundaries. Atlas
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"applicationCategory": "cartography",
"isPartOf": "https://ropenspain.es/",
"keywords": ["rOpenSpain", "tiles", "r", "maps", "spatial", "rstats", "r-package", "municipalities", "Spain", "gisco", "provinces", "ign", "administrative-boundaries", "ccaa", "static-tiles", "spain", "cran", "ropenspain", "ggplot2", "gis"],
"fileSize": "2716.503KB",
"fileSize": "2716.435KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
11 changes: 7 additions & 4 deletions tests/testthat/test-esp_getTiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,14 @@ test_that("Custom WMTS", {
expect_s4_class(tile2, "SpatRaster")

# With another extension
stamen_water <- list(
id = "Stamen_Water",
q = "https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg"
esri_wsm <- list(
id = "ESRI_WorldStreetMap",
q = paste0(
"https://server.arcgisonline.com/ArcGIS/rest/services/",
"World_Street_Map/MapServer/tile/{z}/{y}/{x}.jpg"
)
)

tile3 <- esp_getTiles(segovia, type = stamen_water)
tile3 <- esp_getTiles(segovia, type = esri_wsm)
expect_s4_class(tile3, "SpatRaster")
})
16 changes: 5 additions & 11 deletions vignettes/mapSpain.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -202,27 +202,21 @@ used).
# Population density of Spain

library(sf)
#> Error in value[[3L]](cond): Package 'sf' version 1.0.14 cannot be unloaded:
#> Error in unloadNamespace(package) : namespace 'sf' is imported by 'mapSpain' so cannot be unloaded

pop <- mapSpain::pobmun19
munic <- esp_get_munic()

# Get area (km2) - Use LAEA projection
municarea <- as.double(st_area(st_transform(munic, 3035)) / 1000000)
#> Error in st_area(st_transform(munic, 3035)): could not find function "st_area"
munic$area <- municarea
#> Error in eval(expr, envir, enclos): object 'municarea' not found

munic.pop <- merge(munic, pop, all.x = TRUE, by = c("cpro", "cmun"))
munic.pop$dens <- munic.pop$pob19 / munic.pop$area
#> Error in `[[<-.data.frame`(`*tmp*`, i, value = numeric(0)): replacement has 0 rows, data has 8131

br <- c(-Inf, 10, 25, 100, 200, 500, 1000, 5000, 10000, Inf)


munic.pop$cuts <- cut(munic.pop$dens, br)
#> Error in cut.default(munic.pop$dens, br): 'x' must be numeric

ggplot(munic.pop) +
geom_sf(aes(fill = cuts), color = NA, linewidth = 0) +
Expand All @@ -246,13 +240,13 @@ ggplot(munic.pop) +
text = element_text(colour = "white"),
legend.position = "bottom"
)
#> Error in `geom_sf()`:
#> ! Problem while computing aesthetics.
#> ℹ Error occurred in the 1st layer.
#> Caused by error:
#> ! object 'cuts' not found
```

<div class="figure">
<img src="./thematic-1.png" alt="Population density in Spain (2019)" width="100%" />
<p class="caption">Population density in Spain (2019)</p>
</div>

## mapSpain and giscoR

If you need to plot Spain along with another countries, consider using
Expand Down
Binary file modified vignettes/thematic-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 75d9737

Please sign in to comment.