diff --git a/articles/plots.html b/articles/plots.html index ef1cecd..a491ae6 100644 --- a/articles/plots.html +++ b/articles/plots.html @@ -265,7 +265,7 @@

Session info#> munsell 0.5.1 2024-04-01 [1] RSPM #> pillar 1.9.0 2023-03-22 [1] RSPM #> pkgconfig 2.0.3 2019-09-22 [1] RSPM -#> pkgdown 2.1.1 2024-09-17 [1] RSPM +#> pkgdown 2.1.1 2024-09-17 [1] any (@2.1.1) #> png 0.1-8 2022-11-29 [1] RSPM #> proxy 0.4-27 2022-06-09 [1] RSPM #> purrr 1.0.2 2023-08-10 [1] RSPM diff --git a/articles/plots_files/figure-html/unnamed-chunk-5-1.png b/articles/plots_files/figure-html/unnamed-chunk-5-1.png index c401550..76b7c79 100644 Binary files a/articles/plots_files/figure-html/unnamed-chunk-5-1.png and b/articles/plots_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/pkgdown.yml b/pkgdown.yml index 98fa8cf..335f72c 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -4,7 +4,7 @@ pkgdown_sha: ~ articles: articles/plots: plots.html rasterpic: rasterpic.html -last_built: 2024-11-28T10:29Z +last_built: 2024-11-28T12:43Z urls: reference: https://dieghernan.github.io/rasterpic/reference article: https://dieghernan.github.io/rasterpic/articles diff --git a/search.json b/search.json index f3a767d..9862bbc 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"base-plots","dir":"Articles","previous_headings":"","what":"Base plots","title":"Plotting terra rasters","text":"straightforward option use base plot() methods provided package terra (terra::plotRGB()):","code":"library(rasterpic) library(terra) # The flag of the United Kingdom img <- system.file(\"img/UK_flag.png\", package = \"rasterpic\" ) uk <- sf::st_read( system.file(\"gpkg/UK.gpkg\", package = \"rasterpic\" ), quiet = TRUE ) uk_img <- rasterpic_img(uk, img, mask = TRUE, inverse = TRUE) plotRGB(uk_img)"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"with-ggplot2-tidyterra","dir":"Articles","previous_headings":"","what":"With ggplot2 + tidyterra","title":"Plotting terra rasters","text":"tidyterra provides full support terra SpatRaster objects:","code":"library(ggplot2) library(tidyterra) ggplot() + geom_spatraster_rgb(data = uk_img)"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"with-tmap","dir":"Articles","previous_headings":"","what":"With tmap","title":"Plotting terra rasters","text":"tmap can also used create great maps:","code":"library(tmap) tm_shape(uk_img) + tm_graticules() + tm_rgb()"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"with-mapsf","dir":"Articles","previous_headings":"","what":"With mapsf","title":"Plotting terra rasters","text":"mapsf also provides functionality:","code":"library(mapsf) mf_raster(uk_img) mf_scale() mf_inset_on(x = \"worldmap\", pos = \"topright\") mf_worldmap(uk) mf_inset_off()"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"with-maptiles","dir":"Articles","previous_headings":"","what":"With maptiles","title":"Plotting terra rasters","text":"maptiles interesting package provides ability downloading map tiles different providers. also specific function plotting terra SpatRaster objects:","code":"library(maptiles) other_tile <- get_tiles(uk, crop = TRUE, zoom = 6) other_tile_crop <- terra::crop(other_tile, uk_img) plot_tiles(other_tile_crop) plot_tiles(uk_img, add = TRUE)"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Plotting terra rasters","text":"Tennekes M (2018). “tmap: Thematic Maps R.” Journal Statistical Software, 84(6), 1–39. doi:10.18637/jss.v084.i06. Giraud T (2024). mapsf: Thematic Cartography. R package version 0.12.0, https://riatelab.github.io/mapsf/. Hernangómez D (2023). “Using tidyverse terra objects: tidyterra package.” Journal Open Source Software, 8(91), 5751. ISSN 2475-9066, doi:10.21105/joss.05751, https://doi.org/10.21105/joss.05751. Hijmans R (2024). terra: Spatial Data Analysis. R package version 1.7-83, https://rspatial.github.io/terra/, https://rspatial.org/. Wickham H (2016). ggplot2: Elegant Graphics Data Analysis. Springer-Verlag New York. ISBN 978-3-319-24277-4, https://ggplot2.tidyverse.org.","code":""},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"session-info","dir":"Articles","previous_headings":"","what":"Session info","title":"Plotting terra rasters","text":"","code":"#> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.4.2 (2024-10-31 ucrt) #> os Windows Server 2022 x64 (build 20348) #> system x86_64, mingw32 #> ui RTerm #> language en #> collate English_United States.utf8 #> ctype English_United States.utf8 #> tz UTC #> date 2024-11-28 #> pandoc 3.1.11 @ C:/HOSTED~1/windows/pandoc/31F387~1.11/x64/PANDOC~1.11/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> abind 1.4-8 2024-09-12 [1] RSPM #> base64enc 0.1-3 2015-07-28 [1] RSPM #> bslib 0.8.0 2024-07-29 [1] RSPM #> cachem 1.1.0 2024-05-16 [1] RSPM #> class 7.3-22 2023-05-03 [3] CRAN (R 4.4.2) #> classInt 0.4-10 2023-09-05 [1] RSPM #> cli 3.6.3 2024-06-21 [1] RSPM #> codetools 0.2-20 2024-03-31 [3] CRAN (R 4.4.2) #> colorspace 2.1-1 2024-07-26 [1] RSPM #> crosstalk 1.2.1 2023-11-23 [1] RSPM #> curl 6.0.1 2024-11-14 [1] RSPM #> DBI 1.2.3 2024-06-02 [1] RSPM #> desc 1.4.3 2023-12-10 [1] RSPM #> dichromat 2.0-0.1 2022-05-02 [1] RSPM #> digest 0.6.37 2024-08-19 [1] RSPM #> dplyr 1.1.4 2023-11-17 [1] RSPM #> e1071 1.7-16 2024-09-16 [1] RSPM #> evaluate 1.0.1 2024-10-10 [1] RSPM #> fansi 1.0.6 2023-12-08 [1] RSPM #> farver 2.1.2 2024-05-13 [1] RSPM #> fastmap 1.2.0 2024-05-15 [1] RSPM #> fs 1.6.5 2024-10-30 [1] RSPM #> generics 0.1.3 2022-07-05 [1] RSPM #> ggplot2 * 3.5.1 2024-04-23 [1] RSPM #> glue 1.8.0 2024-09-30 [1] RSPM #> gtable 0.3.6 2024-10-25 [1] RSPM #> htmltools 0.5.8.1 2024-04-04 [1] RSPM #> htmlwidgets 1.6.4 2023-12-06 [1] RSPM #> jquerylib 0.1.4 2021-04-26 [1] RSPM #> jsonlite 1.8.9 2024-09-20 [1] RSPM #> KernSmooth 2.23-24 2024-05-17 [3] CRAN (R 4.4.2) #> knitr 1.49 2024-11-08 [1] RSPM #> lattice 0.22-6 2024-03-20 [3] CRAN (R 4.4.2) #> leafem 0.2.3 2023-09-17 [1] RSPM #> leaflet 2.2.2 2024-03-26 [1] RSPM #> leafsync 0.1.0 2019-03-05 [1] RSPM #> lifecycle 1.0.4 2023-11-07 [1] RSPM #> lwgeom 0.2-14 2024-02-21 [1] RSPM #> magrittr 2.0.3 2022-03-30 [1] RSPM #> maplegend 0.2.0 2024-11-12 [1] RSPM #> mapsf * 0.12.0 2024-10-22 [1] RSPM #> maptiles * 0.8.0 2024-10-22 [1] RSPM #> munsell 0.5.1 2024-04-01 [1] RSPM #> pillar 1.9.0 2023-03-22 [1] RSPM #> pkgconfig 2.0.3 2019-09-22 [1] RSPM #> pkgdown 2.1.1 2024-09-17 [1] RSPM #> png 0.1-8 2022-11-29 [1] RSPM #> proxy 0.4-27 2022-06-09 [1] RSPM #> purrr 1.0.2 2023-08-10 [1] RSPM #> R6 2.5.1 2021-08-19 [1] RSPM #> ragg 1.3.3 2024-09-11 [1] RSPM #> raster 3.6-30 2024-10-02 [1] RSPM #> rasterpic * 0.2.5 2024-11-28 [1] local #> RColorBrewer 1.1-3 2022-04-03 [1] RSPM #> Rcpp 1.0.13-1 2024-11-02 [1] RSPM #> rlang 1.1.4 2024-06-04 [1] RSPM #> rmarkdown 2.29 2024-11-04 [1] RSPM #> s2 1.1.7 2024-07-17 [1] RSPM #> sass 0.4.9 2024-03-15 [1] RSPM #> scales 1.3.0 2023-11-28 [1] RSPM #> sessioninfo * 1.2.2 2021-12-06 [1] any (@1.2.2) #> sf 1.0-19 2024-11-05 [1] RSPM #> slippymath 0.3.1 2019-06-28 [1] RSPM #> sp 2.1-4 2024-04-30 [1] RSPM #> stars 0.6-7 2024-11-07 [1] RSPM #> systemfonts 1.1.0 2024-05-15 [1] RSPM #> terra * 1.7-83 2024-10-14 [1] RSPM #> textshaping 0.4.0 2024-05-24 [1] RSPM #> tibble 3.2.1 2023-03-20 [1] RSPM #> tidyr 1.3.1 2024-01-24 [1] RSPM #> tidyselect 1.2.1 2024-03-11 [1] RSPM #> tidyterra * 0.6.1 2024-06-08 [1] RSPM #> tmap * 3.3-4 2023-09-12 [1] RSPM #> tmaptools 3.1-1 2021-01-19 [1] RSPM #> units 0.8-5 2023-11-28 [1] RSPM #> utf8 1.2.4 2023-10-22 [1] RSPM #> vctrs 0.6.5 2023-12-01 [1] RSPM #> viridisLite 0.4.2 2023-05-02 [1] RSPM #> withr 3.0.2 2024-10-28 [1] RSPM #> wk 0.9.4 2024-10-11 [1] RSPM #> xfun 0.49 2024-10-31 [1] RSPM #> XML 3.99-0.17 2024-06-25 [1] RSPM #> yaml 2.3.10 2024-07-26 [1] RSPM #> #> [1] D:/a/_temp/Library #> [2] C:/R/site-library #> [3] C:/R/library #> #> ──────────────────────────────────────────────────────────────────────────────"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"basic-usage","dir":"Articles","previous_headings":"","what":"Basic usage","title":"Get Started","text":"use example shape Austria:","code":"library(sf) library(terra) library(rasterpic) # Plot library(tidyterra) library(ggplot2) # Shape and image x <- read_sf(system.file(\"gpkg/austria.gpkg\", package = \"rasterpic\")) img <- system.file(\"img/vertical.png\", package = \"rasterpic\") # Create! default <- rasterpic_img(x, img) autoplot(default) + geom_sf(data = x)"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"options","dir":"Articles","previous_headings":"","what":"Options","title":"Get Started","text":"function provides several options expanding, alignment cropping.","code":""},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"expand","dir":"Articles","previous_headings":"Options","what":"Expand","title":"Get Started","text":"option image zoomed spatial object:","code":"expand <- rasterpic_img(x, img, expand = 1) autoplot(expand) + geom_sf(data = x)"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"alignment","dir":"Articles","previous_headings":"Options","what":"Alignment","title":"Get Started","text":"Decide align image:","code":"bottom <- rasterpic_img(x, img, valign = 0) autoplot(bottom) + geom_sf(data = x)"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"crop-and-mask","dir":"Articles","previous_headings":"Options","what":"Crop and mask","title":"Get Started","text":"Create impressive maps!:","code":"mask <- rasterpic_img(x, img, crop = TRUE, mask = TRUE) autoplot(mask) maskinverse <- rasterpic_img(x, img, crop = TRUE, mask = TRUE, inverse = TRUE) autoplot(maskinverse)"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"objects-admitted-for-geotagging","dir":"Articles","previous_headings":"","what":"Objects admitted for geotagging","title":"Get Started","text":"Spatial object sf package: sf, sfc, sfg bbox. Spatial objects terra package: SpatRaster, SpatVector, SpatExtent. vector coordinates form c(xmin, ymin, xmax, yman).","code":""},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"image-formats-admitted","dir":"Articles","previous_headings":"","what":"Image formats admitted","title":"Get Started","text":"rasterpic can parse following image formats: png files. jpg/jpeg files. tif/tiff files.","code":""},{"path":"https://dieghernan.github.io/rasterpic/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Diego Hernangómez. Author, maintainer, copyright holder.","code":""},{"path":"https://dieghernan.github.io/rasterpic/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Hernangómez D (2024). rasterpic: Convert Digital Images SpatRaster Objects. doi:10.32614/CRAN.package.rasterpic, https://dieghernan.github.io/rasterpic/.","code":"@Manual{R-rasterpic, title = {{rasterpic}: Convert Digital Images into {SpatRaster} Objects}, doi = {10.32614/CRAN.package.rasterpic}, author = {Diego Hernangómez}, year = {2024}, version = {0.2.5}, url = {https://dieghernan.github.io/rasterpic/}, abstract = {Generate SpatRaster objects, as defined by the terra package, from digital images, using a specified spatial object as a geographical reference.}, }"},{"path":[]},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"CONTRIBUTING","text":"Small typos grammatical errors documentation may edited directly using GitHub web interface, long changes made source file. YES ✔️: edit roxygen comment .R file R/. ❌: edit .Rd file man/.","code":""},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"prerequisites","dir":"","previous_headings":"","what":"Prerequisites","title":"CONTRIBUTING","text":"make substantial pull request, always file issue make sure someone team agrees ’s problem. ’ve found bug, create associated issue illustrate bug minimal reprex.","code":""},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"","what":"Pull request process","title":"CONTRIBUTING","text":"recommend create Git branch pull request (PR). Look R-CMD-check build status . making changes, run devtools::check() ensure new Notes, Warnings Errors appearing. recommend tidyverse style guide. also use styler package apply styles, please don’t restyle code nothing PR. use roxygen2. use testthat. Contributions test cases included easier accept. user-facing changes, add bullet top NEWS.md current development version header describing changes made followed GitHub username, links relevant issue(s)/PR(s).","code":""},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"prefer-to-email","dir":"","previous_headings":"","what":"Prefer to Email?","title":"CONTRIBUTING","text":"Email person listed maintainer DESCRIPTION file repo. Though note private discussions email don’t help others - course email totally warranted ’s sensitive problem kind.","code":""},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"thanks-for-contributing","dir":"","previous_headings":"","what":"Thanks for contributing!","title":"CONTRIBUTING","text":"contributing guide adapted tidyverse contributing guide available https://raw.githubusercontent.com/r-lib/usethis/master/inst/templates/tidy-contributing.md","code":""},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"rasterpic-","dir":"","previous_headings":"","what":"rasterpic | Convert Digital Images into SpatRaster Objects","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"rasterpic tiny package one single goal: transform image SpatRaster object (see ?terra::SpatRaster).","code":""},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"Install rasterpic CRAN: can install developing version rasterpic : Alternatively, can install rasterpic using r-universe:","code":"install.packages(\"rasterpic\") remotes::install_github(\"dieghernan/rasterpic\") # Install rasterpic in R: install.packages(\"rasterpic\", repos = c( \"https://dieghernan.r-universe.dev\", \"https://cloud.r-project.org\" ))"},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"package allows create cool maps using wide variety objects: Spatial object created sf package: sf, sfc, sfg bbox. Spatial objects created terra package: SpatRaster, SpatVector, SpatExtent. vector coordinates form c(xmin, ymin, xmax, yman) example using sf object: can also play parameters, well modifying alignment image respect object:","code":"library(rasterpic) library(sf) library(terra) # The flag of the United Kingdom img <- system.file(\"img/UK_flag.png\", package = \"rasterpic\") uk <- read_sf(system.file(\"gpkg/UK.gpkg\", package = \"rasterpic\")) class(uk) #> [1] \"sf\" \"tbl_df\" \"tbl\" \"data.frame\" # Rasterize! uk_flag <- rasterpic_img(uk, img) uk_flag #> class : SpatRaster #> dimensions : 400, 800, 3 (nrow, ncol, nlyr) #> resolution : 5398.319, 5398.319 (x, y) #> extent : -2542183, 1776472, 6430573, 8589900 (xmin, xmax, ymin, ymax) #> coord. ref. : WGS 84 / Pseudo-Mercator (EPSG:3857) #> source(s) : memory #> colors RGB : 1, 2, 3 #> names : lyr.1, lyr.2, lyr.3 #> min values : 0, 14, 35 #> max values : 255, 255, 255 # Plot it! # Using ggplot2 + tidyterra library(tidyterra) library(ggplot2) autoplot(uk_flag) + geom_sf(data = uk, color = alpha(\"blue\", 0.5)) # Align, crop and mask uk_flag2 <- rasterpic_img(uk, img, halign = 0.2, crop = TRUE, mask = TRUE) autoplot(uk_flag2) + geom_sf(data = uk, fill = NA)"},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"image-formats-admitted","dir":"","previous_headings":"","what":"Image formats admitted","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"rasterpic can parse following image formats: png files. jpg/jpeg files. tif/tiff files.","code":""},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"Hernangómez D (2024). rasterpic: Convert Digital Images SpatRaster Objects. doi:10.32614/CRAN.package.rasterpic, https://dieghernan.github.io/rasterpic/. BibTeX entry LaTeX users :","code":"@Manual{R-rasterpic, title = {{rasterpic}: Convert Digital Images into {SpatRaster} Objects}, doi = {10.32614/CRAN.package.rasterpic}, author = {Diego Hernangómez}, year = {2024}, version = {0.2.5}, url = {https://dieghernan.github.io/rasterpic/}, abstract = {Generate SpatRaster objects, as defined by the terra package, from digital images, using a specified spatial object as a geographical reference.}, }"},{"path":"https://dieghernan.github.io/rasterpic/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2022 rasterpic authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute aspect ratio of an object — asp_ratio","title":"Compute aspect ratio of an object — asp_ratio","text":"Helper function. Ratio computed width/height (col/rows).","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute aspect ratio of an object — asp_ratio","text":"","code":"asp_ratio(x)"},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute aspect ratio of an object — asp_ratio","text":"x SpatRaster object, sf/sfc object numeric vector length 4 coordinates c(xmin, ymin, xmax, ymax), created sf::st_bbox().","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compute aspect ratio of an object — asp_ratio","text":"aspect ratio","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute aspect ratio of an object — asp_ratio","text":"","code":"# \\donttest{ library(terra) #> terra 1.7.83 x <- rast(system.file(\"tiff/elev.tiff\", package = \"rasterpic\")) plot(x) asp_ratio(x) #> [1] 2.34375 # }"},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic-package.html","id":null,"dir":"Reference","previous_headings":"","what":"rasterpic: Convert Digital Images into 'SpatRaster' Objects — rasterpic-package","title":"rasterpic: Convert Digital Images into 'SpatRaster' Objects — rasterpic-package","text":"Generate 'SpatRaster' objects, defined 'terra' package, digital images, using specified spatial object geographical reference.","code":""},{"path":[]},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"rasterpic: Convert Digital Images into 'SpatRaster' Objects — rasterpic-package","text":"Maintainer: Diego Hernangómez diego.hernangomezherrero@gmail.com (ORCID) [copyright holder]","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"Geotags image based coordinates given spatial object.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"","code":"rasterpic_img( x, img, halign = 0.5, valign = 0.5, expand = 0, crop = FALSE, mask = FALSE, inverse = FALSE, crs = NULL )"},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"x R object may : object created sf class sf, sfc, sfg bbox). object created terra class SpatRaster, SpatVector SpatExtent. numeric vector length 4 extent used geotagging ( .e. c(xmin, ymin, xmax, ymax)). img image geotagged. can local file online file (e.g. \"https://.imgur.com/6yHmlwT.jpeg\"). following image extensions accepted: png. jpeg/jpg. tiff/tif. halign, valign Horizontal vertical alignment img respect x. value 0 1: halign = 0, valign = 0 assumes x bottom left corner SpatRaster. halign = 1, valign = 1 assumes x top right corner SpatRaster. default halign = .5, valign = .5 assumes x center img. See vignette(\"rasterpic\", package = \"rasterpic\") examples. expand expansion factor bounding box x. 0 means expansion added, 1 means bounding box expanded double original size. See Details. crop Logical. raster cropped (expanded) bounding box x? See Details. mask Logical, applicable x sf, sfc SpatVector object. raster masked x? See Details. inverse Logical. affects mask = TRUE. TRUE, areas raster overlap x masked. crs Character string describing coordinate reference system. parameter affect x SpatExtent, sfg, bbox vector coordinates. See CRS section.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"SpatRaster object (see terra::rast()) layer corresponds color channel img: img least 3 channels (e.g. layers), result additional property setting layers 1 3 Red, Green Blue channels. img already definition RGB values (may case tiff/tif files) result keep channel definition.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"vignette(\"rasterpic\", package = \"rasterpic\") explains examples effect parameters halign, valign, expand, crop mask.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"crs","dir":"Reference","previous_headings":"","what":"CRS","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"function preserves Coordinate Reference System x applicable. optimal results use geographic coordinates (longitude/latitude). crs can WKT format, \"authority:number\" code \"EPSG:4326\", PROJ-string format \"+proj=utm +zone=12\". can also retrieved : sf::st_crs(25830)$wkt. terra::crs(). tidyterra::pull_crs(). See Value Notes terra::crs().","code":""},{"path":[]},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"","code":"# \\donttest{ library(sf) #> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE library(terra) library(ggplot2) library(tidyterra) #> #> Attaching package: 'tidyterra' #> The following object is masked from 'package:stats': #> #> filter x_path <- system.file(\"gpkg/UK.gpkg\", package = \"rasterpic\") x <- st_read(x_path, quiet = TRUE) img <- system.file(\"img/vertical.png\", package = \"rasterpic\") # Default config ex1 <- rasterpic_img(x, img) ex1 #> class : SpatRaster #> dimensions : 333, 250, 3 (nrow, ncol, nlyr) #> resolution : 6484.467, 6484.467 (x, y) #> extent : -1193414, 427703.2, 6430573, 8589900 (xmin, xmax, ymin, ymax) #> coord. ref. : WGS 84 / Pseudo-Mercator (EPSG:3857) #> source(s) : memory #> colors RGB : 1, 2, 3 #> names : lyr.1, lyr.2, lyr.3 #> min values : 15, 8, 4 #> max values : 254, 255, 254 autoplot(ex1) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) # Expand ex2 <- rasterpic_img(x, img, expand = 0.5) autoplot(ex2) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) # Align ex3 <- rasterpic_img(x, img, halign = 0) autoplot(ex3) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) labs(title = \"Align\") #> $title #> [1] \"Align\" #> #> attr(,\"class\") #> [1] \"labels\" # Crop ex4 <- rasterpic_img(x, img, crop = TRUE) autoplot(ex4) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) + labs(title = \"Crop\") # Mask ex5 <- rasterpic_img(x, img, mask = TRUE) autoplot(ex5) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) + labs(title = \"Mask\") # Mask inverse ex6 <- rasterpic_img(x, img, mask = TRUE, inverse = TRUE) autoplot(ex6) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) + labs(title = \"Mask Inverse\") # Combine Mask inverse and crop ex7 <- rasterpic_img(x, img, crop = TRUE, mask = TRUE, inverse = TRUE) autoplot(ex7) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) + labs(title = \"Combine\") # RGB channels ------ plot(ex1) ex_rgb <- ex1 has.RGB(ex_rgb) #> [1] TRUE RGB(ex_rgb) #> [1] 1 2 3 # Modify RGB channels RGB(ex_rgb) <- c(2, 3, 1) RGB(ex_rgb) #> [1] 2 3 1 plot(ex_rgb) # Remove RGB channels RGB(ex_rgb) <- NULL has.RGB(ex_rgb) #> [1] FALSE RGB(ex_rgb) #> NULL # Note the difference with terra::plot plot(ex_rgb) # }"},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-025","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.5","title":"rasterpic 0.2.5","text":"CRAN release: 2024-04-12 Update documentation. Title Description package specific.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-024","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.4","title":"rasterpic 0.2.4","text":"CRAN release: 2024-01-18 Ensure SpatVectors always crs. image less 3 channels raster output property RGB (terra::.RGB() FALSE). expected corner case. image file (.e. tiff) already RGB definition, keep output. Update docs tests.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-023","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.3","title":"rasterpic 0.2.3","text":"CRAN release: 2023-09-08 Now asp_ratio() internal function. Improve docs tests.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-022","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.2","title":"rasterpic 0.2.2","text":"CRAN release: 2023-04-18 Remove unused dependencies Improve docs. Fix typos messages. Declares output RGB raster terra::RGB(). Add ggplot2 “Suggests”.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-021","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.1","title":"rasterpic 0.2.1","text":"CRAN release: 2022-06-10 Add tidyterra “Suggests”.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-020","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.0","title":"rasterpic 0.2.0","text":"CRAN release: 2022-02-18 terra: SpatVector, SpatExtent. sf: sfg, sf::st_bbox(). Numeric vectors c(xmin, ymin, xmax, ymax). Now img parameter rasterpic_img() accepts online images. Add article pkgdown site. Fix CRAN errors.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-010","dir":"Changelog","previous_headings":"","what":"rasterpic 0.1.0","title":"rasterpic 0.1.0","text":"CRAN release: 2022-01-27 Initial release","code":""}] +[{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"base-plots","dir":"Articles","previous_headings":"","what":"Base plots","title":"Plotting terra rasters","text":"straightforward option use base plot() methods provided package terra (terra::plotRGB()):","code":"library(rasterpic) library(terra) # The flag of the United Kingdom img <- system.file(\"img/UK_flag.png\", package = \"rasterpic\" ) uk <- sf::st_read( system.file(\"gpkg/UK.gpkg\", package = \"rasterpic\" ), quiet = TRUE ) uk_img <- rasterpic_img(uk, img, mask = TRUE, inverse = TRUE) plotRGB(uk_img)"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"with-ggplot2-tidyterra","dir":"Articles","previous_headings":"","what":"With ggplot2 + tidyterra","title":"Plotting terra rasters","text":"tidyterra provides full support terra SpatRaster objects:","code":"library(ggplot2) library(tidyterra) ggplot() + geom_spatraster_rgb(data = uk_img)"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"with-tmap","dir":"Articles","previous_headings":"","what":"With tmap","title":"Plotting terra rasters","text":"tmap can also used create great maps:","code":"library(tmap) tm_shape(uk_img) + tm_graticules() + tm_rgb()"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"with-mapsf","dir":"Articles","previous_headings":"","what":"With mapsf","title":"Plotting terra rasters","text":"mapsf also provides functionality:","code":"library(mapsf) mf_raster(uk_img) mf_scale() mf_inset_on(x = \"worldmap\", pos = \"topright\") mf_worldmap(uk) mf_inset_off()"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"with-maptiles","dir":"Articles","previous_headings":"","what":"With maptiles","title":"Plotting terra rasters","text":"maptiles interesting package provides ability downloading map tiles different providers. also specific function plotting terra SpatRaster objects:","code":"library(maptiles) other_tile <- get_tiles(uk, crop = TRUE, zoom = 6) other_tile_crop <- terra::crop(other_tile, uk_img) plot_tiles(other_tile_crop) plot_tiles(uk_img, add = TRUE)"},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Plotting terra rasters","text":"Tennekes M (2018). “tmap: Thematic Maps R.” Journal Statistical Software, 84(6), 1–39. doi:10.18637/jss.v084.i06. Giraud T (2024). mapsf: Thematic Cartography. R package version 0.12.0, https://riatelab.github.io/mapsf/. Hernangómez D (2023). “Using tidyverse terra objects: tidyterra package.” Journal Open Source Software, 8(91), 5751. ISSN 2475-9066, doi:10.21105/joss.05751, https://doi.org/10.21105/joss.05751. Hijmans R (2024). terra: Spatial Data Analysis. R package version 1.7-83, https://rspatial.github.io/terra/, https://rspatial.org/. Wickham H (2016). ggplot2: Elegant Graphics Data Analysis. Springer-Verlag New York. ISBN 978-3-319-24277-4, https://ggplot2.tidyverse.org.","code":""},{"path":"https://dieghernan.github.io/rasterpic/articles/plots.html","id":"session-info","dir":"Articles","previous_headings":"","what":"Session info","title":"Plotting terra rasters","text":"","code":"#> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.4.2 (2024-10-31 ucrt) #> os Windows Server 2022 x64 (build 20348) #> system x86_64, mingw32 #> ui RTerm #> language en #> collate English_United States.utf8 #> ctype English_United States.utf8 #> tz UTC #> date 2024-11-28 #> pandoc 3.1.11 @ C:/HOSTED~1/windows/pandoc/31F387~1.11/x64/PANDOC~1.11/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> abind 1.4-8 2024-09-12 [1] RSPM #> base64enc 0.1-3 2015-07-28 [1] RSPM #> bslib 0.8.0 2024-07-29 [1] RSPM #> cachem 1.1.0 2024-05-16 [1] RSPM #> class 7.3-22 2023-05-03 [3] CRAN (R 4.4.2) #> classInt 0.4-10 2023-09-05 [1] RSPM #> cli 3.6.3 2024-06-21 [1] RSPM #> codetools 0.2-20 2024-03-31 [3] CRAN (R 4.4.2) #> colorspace 2.1-1 2024-07-26 [1] RSPM #> crosstalk 1.2.1 2023-11-23 [1] RSPM #> curl 6.0.1 2024-11-14 [1] RSPM #> DBI 1.2.3 2024-06-02 [1] RSPM #> desc 1.4.3 2023-12-10 [1] RSPM #> dichromat 2.0-0.1 2022-05-02 [1] RSPM #> digest 0.6.37 2024-08-19 [1] RSPM #> dplyr 1.1.4 2023-11-17 [1] RSPM #> e1071 1.7-16 2024-09-16 [1] RSPM #> evaluate 1.0.1 2024-10-10 [1] RSPM #> fansi 1.0.6 2023-12-08 [1] RSPM #> farver 2.1.2 2024-05-13 [1] RSPM #> fastmap 1.2.0 2024-05-15 [1] RSPM #> fs 1.6.5 2024-10-30 [1] RSPM #> generics 0.1.3 2022-07-05 [1] RSPM #> ggplot2 * 3.5.1 2024-04-23 [1] RSPM #> glue 1.8.0 2024-09-30 [1] RSPM #> gtable 0.3.6 2024-10-25 [1] RSPM #> htmltools 0.5.8.1 2024-04-04 [1] RSPM #> htmlwidgets 1.6.4 2023-12-06 [1] RSPM #> jquerylib 0.1.4 2021-04-26 [1] RSPM #> jsonlite 1.8.9 2024-09-20 [1] RSPM #> KernSmooth 2.23-24 2024-05-17 [3] CRAN (R 4.4.2) #> knitr 1.49 2024-11-08 [1] RSPM #> lattice 0.22-6 2024-03-20 [3] CRAN (R 4.4.2) #> leafem 0.2.3 2023-09-17 [1] RSPM #> leaflet 2.2.2 2024-03-26 [1] RSPM #> leafsync 0.1.0 2019-03-05 [1] RSPM #> lifecycle 1.0.4 2023-11-07 [1] RSPM #> lwgeom 0.2-14 2024-02-21 [1] RSPM #> magrittr 2.0.3 2022-03-30 [1] RSPM #> maplegend 0.2.0 2024-11-12 [1] RSPM #> mapsf * 0.12.0 2024-10-22 [1] RSPM #> maptiles * 0.8.0 2024-10-22 [1] RSPM #> munsell 0.5.1 2024-04-01 [1] RSPM #> pillar 1.9.0 2023-03-22 [1] RSPM #> pkgconfig 2.0.3 2019-09-22 [1] RSPM #> pkgdown 2.1.1 2024-09-17 [1] any (@2.1.1) #> png 0.1-8 2022-11-29 [1] RSPM #> proxy 0.4-27 2022-06-09 [1] RSPM #> purrr 1.0.2 2023-08-10 [1] RSPM #> R6 2.5.1 2021-08-19 [1] RSPM #> ragg 1.3.3 2024-09-11 [1] RSPM #> raster 3.6-30 2024-10-02 [1] RSPM #> rasterpic * 0.2.5 2024-11-28 [1] local #> RColorBrewer 1.1-3 2022-04-03 [1] RSPM #> Rcpp 1.0.13-1 2024-11-02 [1] RSPM #> rlang 1.1.4 2024-06-04 [1] RSPM #> rmarkdown 2.29 2024-11-04 [1] RSPM #> s2 1.1.7 2024-07-17 [1] RSPM #> sass 0.4.9 2024-03-15 [1] RSPM #> scales 1.3.0 2023-11-28 [1] RSPM #> sessioninfo * 1.2.2 2021-12-06 [1] any (@1.2.2) #> sf 1.0-19 2024-11-05 [1] RSPM #> slippymath 0.3.1 2019-06-28 [1] RSPM #> sp 2.1-4 2024-04-30 [1] RSPM #> stars 0.6-7 2024-11-07 [1] RSPM #> systemfonts 1.1.0 2024-05-15 [1] RSPM #> terra * 1.7-83 2024-10-14 [1] RSPM #> textshaping 0.4.0 2024-05-24 [1] RSPM #> tibble 3.2.1 2023-03-20 [1] RSPM #> tidyr 1.3.1 2024-01-24 [1] RSPM #> tidyselect 1.2.1 2024-03-11 [1] RSPM #> tidyterra * 0.6.1 2024-06-08 [1] RSPM #> tmap * 3.3-4 2023-09-12 [1] RSPM #> tmaptools 3.1-1 2021-01-19 [1] RSPM #> units 0.8-5 2023-11-28 [1] RSPM #> utf8 1.2.4 2023-10-22 [1] RSPM #> vctrs 0.6.5 2023-12-01 [1] RSPM #> viridisLite 0.4.2 2023-05-02 [1] RSPM #> withr 3.0.2 2024-10-28 [1] RSPM #> wk 0.9.4 2024-10-11 [1] RSPM #> xfun 0.49 2024-10-31 [1] RSPM #> XML 3.99-0.17 2024-06-25 [1] RSPM #> yaml 2.3.10 2024-07-26 [1] RSPM #> #> [1] D:/a/_temp/Library #> [2] C:/R/site-library #> [3] C:/R/library #> #> ──────────────────────────────────────────────────────────────────────────────"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"basic-usage","dir":"Articles","previous_headings":"","what":"Basic usage","title":"Get Started","text":"use example shape Austria:","code":"library(sf) library(terra) library(rasterpic) # Plot library(tidyterra) library(ggplot2) # Shape and image x <- read_sf(system.file(\"gpkg/austria.gpkg\", package = \"rasterpic\")) img <- system.file(\"img/vertical.png\", package = \"rasterpic\") # Create! default <- rasterpic_img(x, img) autoplot(default) + geom_sf(data = x)"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"options","dir":"Articles","previous_headings":"","what":"Options","title":"Get Started","text":"function provides several options expanding, alignment cropping.","code":""},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"expand","dir":"Articles","previous_headings":"Options","what":"Expand","title":"Get Started","text":"option image zoomed spatial object:","code":"expand <- rasterpic_img(x, img, expand = 1) autoplot(expand) + geom_sf(data = x)"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"alignment","dir":"Articles","previous_headings":"Options","what":"Alignment","title":"Get Started","text":"Decide align image:","code":"bottom <- rasterpic_img(x, img, valign = 0) autoplot(bottom) + geom_sf(data = x)"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"crop-and-mask","dir":"Articles","previous_headings":"Options","what":"Crop and mask","title":"Get Started","text":"Create impressive maps!:","code":"mask <- rasterpic_img(x, img, crop = TRUE, mask = TRUE) autoplot(mask) maskinverse <- rasterpic_img(x, img, crop = TRUE, mask = TRUE, inverse = TRUE) autoplot(maskinverse)"},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"objects-admitted-for-geotagging","dir":"Articles","previous_headings":"","what":"Objects admitted for geotagging","title":"Get Started","text":"Spatial object sf package: sf, sfc, sfg bbox. Spatial objects terra package: SpatRaster, SpatVector, SpatExtent. vector coordinates form c(xmin, ymin, xmax, yman).","code":""},{"path":"https://dieghernan.github.io/rasterpic/articles/rasterpic.html","id":"image-formats-admitted","dir":"Articles","previous_headings":"","what":"Image formats admitted","title":"Get Started","text":"rasterpic can parse following image formats: png files. jpg/jpeg files. tif/tiff files.","code":""},{"path":"https://dieghernan.github.io/rasterpic/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Diego Hernangómez. Author, maintainer, copyright holder.","code":""},{"path":"https://dieghernan.github.io/rasterpic/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Hernangómez D (2024). rasterpic: Convert Digital Images SpatRaster Objects. doi:10.32614/CRAN.package.rasterpic, https://dieghernan.github.io/rasterpic/.","code":"@Manual{R-rasterpic, title = {{rasterpic}: Convert Digital Images into {SpatRaster} Objects}, doi = {10.32614/CRAN.package.rasterpic}, author = {Diego Hernangómez}, year = {2024}, version = {0.2.5}, url = {https://dieghernan.github.io/rasterpic/}, abstract = {Generate SpatRaster objects, as defined by the terra package, from digital images, using a specified spatial object as a geographical reference.}, }"},{"path":[]},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"CONTRIBUTING","text":"Small typos grammatical errors documentation may edited directly using GitHub web interface, long changes made source file. YES ✔️: edit roxygen comment .R file R/. ❌: edit .Rd file man/.","code":""},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"prerequisites","dir":"","previous_headings":"","what":"Prerequisites","title":"CONTRIBUTING","text":"make substantial pull request, always file issue make sure someone team agrees ’s problem. ’ve found bug, create associated issue illustrate bug minimal reprex.","code":""},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"","what":"Pull request process","title":"CONTRIBUTING","text":"recommend create Git branch pull request (PR). Look R-CMD-check build status . making changes, run devtools::check() ensure new Notes, Warnings Errors appearing. recommend tidyverse style guide. also use styler package apply styles, please don’t restyle code nothing PR. use roxygen2. use testthat. Contributions test cases included easier accept. user-facing changes, add bullet top NEWS.md current development version header describing changes made followed GitHub username, links relevant issue(s)/PR(s).","code":""},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"prefer-to-email","dir":"","previous_headings":"","what":"Prefer to Email?","title":"CONTRIBUTING","text":"Email person listed maintainer DESCRIPTION file repo. Though note private discussions email don’t help others - course email totally warranted ’s sensitive problem kind.","code":""},{"path":"https://dieghernan.github.io/rasterpic/CONTRIBUTING.html","id":"thanks-for-contributing","dir":"","previous_headings":"","what":"Thanks for contributing!","title":"CONTRIBUTING","text":"contributing guide adapted tidyverse contributing guide available https://raw.githubusercontent.com/r-lib/usethis/master/inst/templates/tidy-contributing.md","code":""},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"rasterpic-","dir":"","previous_headings":"","what":"rasterpic | Convert Digital Images into SpatRaster Objects","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"rasterpic tiny package one single goal: transform image SpatRaster object (see ?terra::SpatRaster).","code":""},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"Install rasterpic CRAN: can install developing version rasterpic : Alternatively, can install rasterpic using r-universe:","code":"install.packages(\"rasterpic\") remotes::install_github(\"dieghernan/rasterpic\") # Install rasterpic in R: install.packages(\"rasterpic\", repos = c( \"https://dieghernan.r-universe.dev\", \"https://cloud.r-project.org\" ))"},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"package allows create cool maps using wide variety objects: Spatial object created sf package: sf, sfc, sfg bbox. Spatial objects created terra package: SpatRaster, SpatVector, SpatExtent. vector coordinates form c(xmin, ymin, xmax, yman) example using sf object: can also play parameters, well modifying alignment image respect object:","code":"library(rasterpic) library(sf) library(terra) # The flag of the United Kingdom img <- system.file(\"img/UK_flag.png\", package = \"rasterpic\") uk <- read_sf(system.file(\"gpkg/UK.gpkg\", package = \"rasterpic\")) class(uk) #> [1] \"sf\" \"tbl_df\" \"tbl\" \"data.frame\" # Rasterize! uk_flag <- rasterpic_img(uk, img) uk_flag #> class : SpatRaster #> dimensions : 400, 800, 3 (nrow, ncol, nlyr) #> resolution : 5398.319, 5398.319 (x, y) #> extent : -2542183, 1776472, 6430573, 8589900 (xmin, xmax, ymin, ymax) #> coord. ref. : WGS 84 / Pseudo-Mercator (EPSG:3857) #> source(s) : memory #> colors RGB : 1, 2, 3 #> names : lyr.1, lyr.2, lyr.3 #> min values : 0, 14, 35 #> max values : 255, 255, 255 # Plot it! # Using ggplot2 + tidyterra library(tidyterra) library(ggplot2) autoplot(uk_flag) + geom_sf(data = uk, color = alpha(\"blue\", 0.5)) # Align, crop and mask uk_flag2 <- rasterpic_img(uk, img, halign = 0.2, crop = TRUE, mask = TRUE) autoplot(uk_flag2) + geom_sf(data = uk, fill = NA)"},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"image-formats-admitted","dir":"","previous_headings":"","what":"Image formats admitted","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"rasterpic can parse following image formats: png files. jpg/jpeg files. tif/tiff files.","code":""},{"path":"https://dieghernan.github.io/rasterpic/index.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"rasterpic | Convert Digital Images into SpatRaster Objects","text":"Hernangómez D (2024). rasterpic: Convert Digital Images SpatRaster Objects. doi:10.32614/CRAN.package.rasterpic, https://dieghernan.github.io/rasterpic/. BibTeX entry LaTeX users :","code":"@Manual{R-rasterpic, title = {{rasterpic}: Convert Digital Images into {SpatRaster} Objects}, doi = {10.32614/CRAN.package.rasterpic}, author = {Diego Hernangómez}, year = {2024}, version = {0.2.5}, url = {https://dieghernan.github.io/rasterpic/}, abstract = {Generate SpatRaster objects, as defined by the terra package, from digital images, using a specified spatial object as a geographical reference.}, }"},{"path":"https://dieghernan.github.io/rasterpic/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2022 rasterpic authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":null,"dir":"Reference","previous_headings":"","what":"Compute aspect ratio of an object — asp_ratio","title":"Compute aspect ratio of an object — asp_ratio","text":"Helper function. Ratio computed width/height (col/rows).","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Compute aspect ratio of an object — asp_ratio","text":"","code":"asp_ratio(x)"},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Compute aspect ratio of an object — asp_ratio","text":"x SpatRaster object, sf/sfc object numeric vector length 4 coordinates c(xmin, ymin, xmax, ymax), created sf::st_bbox().","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Compute aspect ratio of an object — asp_ratio","text":"aspect ratio","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/asp_ratio.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Compute aspect ratio of an object — asp_ratio","text":"","code":"# \\donttest{ library(terra) #> terra 1.7.83 x <- rast(system.file(\"tiff/elev.tiff\", package = \"rasterpic\")) plot(x) asp_ratio(x) #> [1] 2.34375 # }"},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic-package.html","id":null,"dir":"Reference","previous_headings":"","what":"rasterpic: Convert Digital Images into 'SpatRaster' Objects — rasterpic-package","title":"rasterpic: Convert Digital Images into 'SpatRaster' Objects — rasterpic-package","text":"Generate 'SpatRaster' objects, defined 'terra' package, digital images, using specified spatial object geographical reference.","code":""},{"path":[]},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"rasterpic: Convert Digital Images into 'SpatRaster' Objects — rasterpic-package","text":"Maintainer: Diego Hernangómez diego.hernangomezherrero@gmail.com (ORCID) [copyright holder]","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"Geotags image based coordinates given spatial object.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"","code":"rasterpic_img( x, img, halign = 0.5, valign = 0.5, expand = 0, crop = FALSE, mask = FALSE, inverse = FALSE, crs = NULL )"},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"x R object may : object created sf class sf, sfc, sfg bbox). object created terra class SpatRaster, SpatVector SpatExtent. numeric vector length 4 extent used geotagging ( .e. c(xmin, ymin, xmax, ymax)). img image geotagged. can local file online file (e.g. \"https://.imgur.com/6yHmlwT.jpeg\"). following image extensions accepted: png. jpeg/jpg. tiff/tif. halign, valign Horizontal vertical alignment img respect x. value 0 1: halign = 0, valign = 0 assumes x bottom left corner SpatRaster. halign = 1, valign = 1 assumes x top right corner SpatRaster. default halign = .5, valign = .5 assumes x center img. See vignette(\"rasterpic\", package = \"rasterpic\") examples. expand expansion factor bounding box x. 0 means expansion added, 1 means bounding box expanded double original size. See Details. crop Logical. raster cropped (expanded) bounding box x? See Details. mask Logical, applicable x sf, sfc SpatVector object. raster masked x? See Details. inverse Logical. affects mask = TRUE. TRUE, areas raster overlap x masked. crs Character string describing coordinate reference system. parameter affect x SpatExtent, sfg, bbox vector coordinates. See CRS section.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"SpatRaster object (see terra::rast()) layer corresponds color channel img: img least 3 channels (e.g. layers), result additional property setting layers 1 3 Red, Green Blue channels. img already definition RGB values (may case tiff/tif files) result keep channel definition.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"vignette(\"rasterpic\", package = \"rasterpic\") explains examples effect parameters halign, valign, expand, crop mask.","code":""},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"crs","dir":"Reference","previous_headings":"","what":"CRS","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"function preserves Coordinate Reference System x applicable. optimal results use geographic coordinates (longitude/latitude). crs can WKT format, \"authority:number\" code \"EPSG:4326\", PROJ-string format \"+proj=utm +zone=12\". can also retrieved : sf::st_crs(25830)$wkt. terra::crs(). tidyterra::pull_crs(). See Value Notes terra::crs().","code":""},{"path":[]},{"path":"https://dieghernan.github.io/rasterpic/reference/rasterpic_img.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert an image to a geo-tagged SpatRaster — rasterpic_img","text":"","code":"# \\donttest{ library(sf) #> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE library(terra) library(ggplot2) library(tidyterra) #> #> Attaching package: 'tidyterra' #> The following object is masked from 'package:stats': #> #> filter x_path <- system.file(\"gpkg/UK.gpkg\", package = \"rasterpic\") x <- st_read(x_path, quiet = TRUE) img <- system.file(\"img/vertical.png\", package = \"rasterpic\") # Default config ex1 <- rasterpic_img(x, img) ex1 #> class : SpatRaster #> dimensions : 333, 250, 3 (nrow, ncol, nlyr) #> resolution : 6484.467, 6484.467 (x, y) #> extent : -1193414, 427703.2, 6430573, 8589900 (xmin, xmax, ymin, ymax) #> coord. ref. : WGS 84 / Pseudo-Mercator (EPSG:3857) #> source(s) : memory #> colors RGB : 1, 2, 3 #> names : lyr.1, lyr.2, lyr.3 #> min values : 15, 8, 4 #> max values : 254, 255, 254 autoplot(ex1) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) # Expand ex2 <- rasterpic_img(x, img, expand = 0.5) autoplot(ex2) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) # Align ex3 <- rasterpic_img(x, img, halign = 0) autoplot(ex3) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) labs(title = \"Align\") #> $title #> [1] \"Align\" #> #> attr(,\"class\") #> [1] \"labels\" # Crop ex4 <- rasterpic_img(x, img, crop = TRUE) autoplot(ex4) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) + labs(title = \"Crop\") # Mask ex5 <- rasterpic_img(x, img, mask = TRUE) autoplot(ex5) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) + labs(title = \"Mask\") # Mask inverse ex6 <- rasterpic_img(x, img, mask = TRUE, inverse = TRUE) autoplot(ex6) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) + labs(title = \"Mask Inverse\") # Combine Mask inverse and crop ex7 <- rasterpic_img(x, img, crop = TRUE, mask = TRUE, inverse = TRUE) autoplot(ex7) + geom_sf(data = x, fill = NA, color = \"white\", linewidth = .5) + labs(title = \"Combine\") # RGB channels ------ plot(ex1) ex_rgb <- ex1 has.RGB(ex_rgb) #> [1] TRUE RGB(ex_rgb) #> [1] 1 2 3 # Modify RGB channels RGB(ex_rgb) <- c(2, 3, 1) RGB(ex_rgb) #> [1] 2 3 1 plot(ex_rgb) # Remove RGB channels RGB(ex_rgb) <- NULL has.RGB(ex_rgb) #> [1] FALSE RGB(ex_rgb) #> NULL # Note the difference with terra::plot plot(ex_rgb) # }"},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-025","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.5","title":"rasterpic 0.2.5","text":"CRAN release: 2024-04-12 Update documentation. Title Description package specific.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-024","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.4","title":"rasterpic 0.2.4","text":"CRAN release: 2024-01-18 Ensure SpatVectors always crs. image less 3 channels raster output property RGB (terra::.RGB() FALSE). expected corner case. image file (.e. tiff) already RGB definition, keep output. Update docs tests.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-023","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.3","title":"rasterpic 0.2.3","text":"CRAN release: 2023-09-08 Now asp_ratio() internal function. Improve docs tests.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-022","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.2","title":"rasterpic 0.2.2","text":"CRAN release: 2023-04-18 Remove unused dependencies Improve docs. Fix typos messages. Declares output RGB raster terra::RGB(). Add ggplot2 “Suggests”.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-021","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.1","title":"rasterpic 0.2.1","text":"CRAN release: 2022-06-10 Add tidyterra “Suggests”.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-020","dir":"Changelog","previous_headings":"","what":"rasterpic 0.2.0","title":"rasterpic 0.2.0","text":"CRAN release: 2022-02-18 terra: SpatVector, SpatExtent. sf: sfg, sf::st_bbox(). Numeric vectors c(xmin, ymin, xmax, ymax). Now img parameter rasterpic_img() accepts online images. Add article pkgdown site. Fix CRAN errors.","code":""},{"path":"https://dieghernan.github.io/rasterpic/news/index.html","id":"rasterpic-010","dir":"Changelog","previous_headings":"","what":"rasterpic 0.1.0","title":"rasterpic 0.1.0","text":"CRAN release: 2022-01-27 Initial release","code":""}]