Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning message: attribute variables are assumed to be spatially constant throughout all geometries | This not making graphs #4

Open
Adil19K opened this issue Mar 28, 2024 · 0 comments

Comments

@Adil19K
Copy link

Adil19K commented Mar 28, 2024

Hi Milos, I am very new to geomapping in R so, I have taken your code and used it in R studio, here is the code and the warnings

###################################################

Mapping river basins with R

Milos Popovic

2023/07/07

###################################################
libs <- c(

  • "tidyverse", "sf",
    
  • "giscoR", "magick"
    
  • )

installed_libraries <- libs %in% rownames(

  • installed.packages()
    
  • )

if (any(installed_libraries == F)) {

  • install.packages(
    
  •     libs[!installed_libraries]
    
  • )
    
  • }
    WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing packages into ‘C:/Users/Adil/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
also installing the dependencies ‘fastmap’, ‘colorspace’, ‘sys’, ‘bit’, ‘ps’, ‘base64enc’, ‘sass’, ‘digest’, ‘cachem’, ‘farver’, ‘labeling’, ‘munsell’, ‘RColorBrewer’, ‘viridisLite’, ‘rematch’, ‘askpass’, ‘bit64’, ‘prettyunits’, ‘processx’, ‘evaluate’, ‘highr’, ‘xfun’, ‘yaml’, ‘bslib’, ‘fontawesome’, ‘htmltools’, ‘jquerylib’, ‘tinytex’, ‘proxy’, ‘backports’, ‘ellipsis’, ‘generics’, ‘glue’, ‘lifecycle’, ‘memoise’, ‘blob’, ‘R6’, ‘tidyselect’, ‘vctrs’, ‘withr’, ‘data.table’, ‘gtable’, ‘isoband’, ‘scales’, ‘gargle’, ‘uuid’, ‘cellranger’, ‘ids’, ‘rematch2’, ‘cpp11’, ‘pkgconfig’, ‘mime’, ‘openssl’, ‘timechange’, ‘fansi’, ‘utf8’, ‘systemfonts’, ‘textshaping’, ‘clipr’, ‘crayon’, ‘vroom’, ‘tzdb’, ‘progress’, ‘callr’, ‘fs’, ‘knitr’, ‘rmarkdown’, ‘selectr’, ‘stringi’, ‘e1071’, ‘wk’, ‘geometries’, ‘jsonify’, ‘rapidjsonr’, ‘sfheaders’, ‘broom’, ‘conflicted’, ‘cli’, ‘dbplyr’, ‘dplyr’, ‘dtplyr’, ‘forcats’, ‘ggplot2’, ‘googledrive’, ‘googlesheets4’, ‘haven’, ‘hms’, ‘httr’, ‘lubridate’, ‘magrittr’, ‘modelr’, ‘pillar’, ‘purrr’, ‘ragg’, ‘readr’, ‘readxl’, ‘reprex’, ‘rlang’, ‘rstudioapi’, ‘rvest’, ‘stringr’, ‘tibble’, ‘tidyr’, ‘xml2’, ‘classInt’, ‘DBI’, ‘s2’, ‘units’, ‘countrycode’, ‘geojsonsf’, ‘rappdirs’, ‘curl’

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/fastmap_1.1.1.zip'
Content type 'application/zip' length 132938 bytes (129 KB)
downloaded 129 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/colorspace_2.1-0.zip'
Content type 'application/zip' length 2629428 bytes (2.5 MB)
downloaded 2.5 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/sys_3.4.2.zip'
Content type 'application/zip' length 47080 bytes (45 KB)
downloaded 45 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/bit_4.0.5.zip'
Content type 'application/zip' length 1136288 bytes (1.1 MB)
downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/ps_1.7.6.zip'
Content type 'application/zip' length 553436 bytes (540 KB)
downloaded 540 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/base64enc_0.1-3.zip'
Content type 'application/zip' length 32648 bytes (31 KB)
downloaded 31 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/sass_0.4.9.zip'
Content type 'application/zip' length 2608422 bytes (2.5 MB)
downloaded 2.5 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/digest_0.6.35.zip'
Content type 'application/zip' length 217676 bytes (212 KB)
downloaded 212 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/cachem_1.0.8.zip'
Content type 'application/zip' length 72540 bytes (70 KB)
downloaded 70 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/farver_2.1.1.zip'
Content type 'application/zip' length 1505734 bytes (1.4 MB)
downloaded 1.4 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/labeling_0.4.3.zip'
Content type 'application/zip' length 62568 bytes (61 KB)
downloaded 61 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/munsell_0.5.0.zip'
Content type 'application/zip' length 244896 bytes (239 KB)
downloaded 239 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/RColorBrewer_1.1-3.zip'
Content type 'application/zip' length 56066 bytes (54 KB)
downloaded 54 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/viridisLite_0.4.2.zip'
Content type 'application/zip' length 1300106 bytes (1.2 MB)
downloaded 1.2 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/rematch_2.0.0.zip'
Content type 'application/zip' length 19061 bytes (18 KB)
downloaded 18 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/askpass_1.2.0.zip'
Content type 'application/zip' length 74961 bytes (73 KB)
downloaded 73 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/bit64_4.0.5.zip'
Content type 'application/zip' length 494655 bytes (483 KB)
downloaded 483 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/prettyunits_1.2.0.zip'
Content type 'application/zip' length 157712 bytes (154 KB)
downloaded 154 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/processx_3.8.4.zip'
Content type 'application/zip' length 686741 bytes (670 KB)
downloaded 670 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/evaluate_0.23.zip'
Content type 'application/zip' length 84079 bytes (82 KB)
downloaded 82 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/highr_0.10.zip'
Content type 'application/zip' length 46569 bytes (45 KB)
downloaded 45 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/xfun_0.43.zip'
Content type 'application/zip' length 486331 bytes (474 KB)
downloaded 474 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/yaml_2.3.8.zip'
Content type 'application/zip' length 118097 bytes (115 KB)
downloaded 115 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/bslib_0.6.2.zip'
Content type 'application/zip' length 6482393 bytes (6.2 MB)
downloaded 6.2 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/fontawesome_0.5.2.zip'
Content type 'application/zip' length 1358182 bytes (1.3 MB)
downloaded 1.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/htmltools_0.5.8.zip'
Content type 'application/zip' length 358261 bytes (349 KB)
downloaded 349 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/jquerylib_0.1.4.zip'
Content type 'application/zip' length 525996 bytes (513 KB)
downloaded 513 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/tinytex_0.50.zip'
Content type 'application/zip' length 140713 bytes (137 KB)
downloaded 137 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/proxy_0.4-27.zip'
Content type 'application/zip' length 180058 bytes (175 KB)
downloaded 175 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/backports_1.4.1.zip'
Content type 'application/zip' length 101330 bytes (98 KB)
downloaded 98 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/ellipsis_0.3.2.zip'
Content type 'application/zip' length 40466 bytes (39 KB)
downloaded 39 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/generics_0.1.3.zip'
Content type 'application/zip' length 79979 bytes (78 KB)
downloaded 78 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/glue_1.7.0.zip'
Content type 'application/zip' length 161264 bytes (157 KB)
downloaded 157 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/lifecycle_1.0.4.zip'
Content type 'application/zip' length 139682 bytes (136 KB)
downloaded 136 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/memoise_2.0.1.zip'
Content type 'application/zip' length 49978 bytes (48 KB)
downloaded 48 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/blob_1.2.4.zip'
Content type 'application/zip' length 48395 bytes (47 KB)
downloaded 47 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/R6_2.5.1.zip'
Content type 'application/zip' length 84304 bytes (82 KB)
downloaded 82 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/tidyselect_1.2.1.zip'
Content type 'application/zip' length 225094 bytes (219 KB)
downloaded 219 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/vctrs_0.6.5.zip'
Content type 'application/zip' length 1336890 bytes (1.3 MB)
downloaded 1.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/withr_3.0.0.zip'
Content type 'application/zip' length 245993 bytes (240 KB)
downloaded 240 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/data.table_1.15.2.zip'
Content type 'application/zip' length 2387873 bytes (2.3 MB)
downloaded 2.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/gtable_0.3.4.zip'
Content type 'application/zip' length 225769 bytes (220 KB)
downloaded 220 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/isoband_0.2.7.zip'
Content type 'application/zip' length 1968378 bytes (1.9 MB)
downloaded 1.9 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/scales_1.3.0.zip'
Content type 'application/zip' length 704137 bytes (687 KB)
downloaded 687 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/gargle_1.5.2.zip'
Content type 'application/zip' length 792550 bytes (773 KB)
downloaded 773 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/uuid_1.2-0.zip'
Content type 'application/zip' length 52294 bytes (51 KB)
downloaded 51 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/cellranger_1.1.0.zip'
Content type 'application/zip' length 103984 bytes (101 KB)
downloaded 101 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/ids_1.0.1.zip'
Content type 'application/zip' length 123894 bytes (120 KB)
downloaded 120 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/rematch2_2.1.2.zip'
Content type 'application/zip' length 47593 bytes (46 KB)
downloaded 46 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/cpp11_0.4.7.zip'
Content type 'application/zip' length 304066 bytes (296 KB)
downloaded 296 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/pkgconfig_2.0.3.zip'
Content type 'application/zip' length 22468 bytes (21 KB)
downloaded 21 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/mime_0.12.zip'
Content type 'application/zip' length 40827 bytes (39 KB)
downloaded 39 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/openssl_2.1.1.zip'
Content type 'application/zip' length 3186538 bytes (3.0 MB)
downloaded 3.0 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/timechange_0.3.0.zip'
Content type 'application/zip' length 507769 bytes (495 KB)
downloaded 495 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/fansi_1.0.6.zip'
Content type 'application/zip' length 314029 bytes (306 KB)
downloaded 306 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/utf8_1.2.4.zip'
Content type 'application/zip' length 149810 bytes (146 KB)
downloaded 146 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/systemfonts_1.0.6.zip'
Content type 'application/zip' length 1554591 bytes (1.5 MB)
downloaded 1.5 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/textshaping_0.3.7.zip'
Content type 'application/zip' length 1190343 bytes (1.1 MB)
downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/clipr_0.8.0.zip'
Content type 'application/zip' length 54698 bytes (53 KB)
downloaded 53 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/crayon_1.5.2.zip'
Content type 'application/zip' length 162274 bytes (158 KB)
downloaded 158 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/vroom_1.6.5.zip'
Content type 'application/zip' length 1331336 bytes (1.3 MB)
downloaded 1.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/tzdb_0.4.0.zip'
Content type 'application/zip' length 1032575 bytes (1008 KB)
downloaded 1008 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/progress_1.2.3.zip'
Content type 'application/zip' length 87776 bytes (85 KB)
downloaded 85 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/callr_3.7.6.zip'
Content type 'application/zip' length 460288 bytes (449 KB)
downloaded 449 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/fs_1.6.3.zip'
Content type 'application/zip' length 394091 bytes (384 KB)
downloaded 384 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/knitr_1.45.zip'
Content type 'application/zip' length 1520892 bytes (1.5 MB)
downloaded 1.5 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/rmarkdown_2.26.zip'
Content type 'application/zip' length 2681131 bytes (2.6 MB)
downloaded 2.6 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/selectr_0.4-2.zip'
Content type 'application/zip' length 492358 bytes (480 KB)
downloaded 480 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/stringi_1.8.3.zip'
Content type 'application/zip' length 14998651 bytes (14.3 MB)
downloaded 14.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/e1071_1.7-14.zip'
Content type 'application/zip' length 665252 bytes (649 KB)
downloaded 649 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/wk_0.9.1.zip'
Content type 'application/zip' length 2056345 bytes (2.0 MB)
downloaded 2.0 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/geometries_0.2.4.zip'
Content type 'application/zip' length 631354 bytes (616 KB)
downloaded 616 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/jsonify_1.2.2.zip'
Content type 'application/zip' length 989032 bytes (965 KB)
downloaded 965 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/rapidjsonr_1.2.0.zip'
Content type 'application/zip' length 161762 bytes (157 KB)
downloaded 157 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/sfheaders_0.4.4.zip'
Content type 'application/zip' length 820941 bytes (801 KB)
downloaded 801 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/broom_1.0.5.zip'
Content type 'application/zip' length 1864133 bytes (1.8 MB)
downloaded 1.8 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/conflicted_1.2.0.zip'
Content type 'application/zip' length 57419 bytes (56 KB)
downloaded 56 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/cli_3.6.2.zip'
Content type 'application/zip' length 1339681 bytes (1.3 MB)
downloaded 1.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/dbplyr_2.5.0.zip'
Content type 'application/zip' length 1251002 bytes (1.2 MB)
downloaded 1.2 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/dplyr_1.1.4.zip'
Content type 'application/zip' length 1558956 bytes (1.5 MB)
downloaded 1.5 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/dtplyr_1.3.1.zip'
Content type 'application/zip' length 353985 bytes (345 KB)
downloaded 345 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/forcats_1.0.0.zip'
Content type 'application/zip' length 427590 bytes (417 KB)
downloaded 417 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/ggplot2_3.5.0.zip'
Content type 'application/zip' length 4822465 bytes (4.6 MB)
downloaded 4.6 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/googledrive_2.1.1.zip'
Content type 'application/zip' length 1896336 bytes (1.8 MB)
downloaded 1.8 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/googlesheets4_1.1.1.zip'
Content type 'application/zip' length 513853 bytes (501 KB)
downloaded 501 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/haven_2.5.4.zip'
Content type 'application/zip' length 765051 bytes (747 KB)
downloaded 747 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/hms_1.1.3.zip'
Content type 'application/zip' length 104261 bytes (101 KB)
downloaded 101 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/httr_1.4.7.zip'
Content type 'application/zip' length 485808 bytes (474 KB)
downloaded 474 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/lubridate_1.9.3.zip'
Content type 'application/zip' length 984779 bytes (961 KB)
downloaded 961 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/magrittr_2.0.3.zip'
Content type 'application/zip' length 226955 bytes (221 KB)
downloaded 221 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/modelr_0.1.11.zip'
Content type 'application/zip' length 202767 bytes (198 KB)
downloaded 198 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/pillar_1.9.0.zip'
Content type 'application/zip' length 659324 bytes (643 KB)
downloaded 643 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/purrr_1.0.2.zip'
Content type 'application/zip' length 499653 bytes (487 KB)
downloaded 487 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/ragg_1.3.0.zip'
Content type 'application/zip' length 1950458 bytes (1.9 MB)
downloaded 1.9 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/readr_2.1.5.zip'
Content type 'application/zip' length 1172378 bytes (1.1 MB)
downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/readxl_1.4.3.zip'
Content type 'application/zip' length 1197169 bytes (1.1 MB)
downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/reprex_2.1.0.zip'
Content type 'application/zip' length 502461 bytes (490 KB)
downloaded 490 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/rlang_1.1.3.zip'
Content type 'application/zip' length 1573512 bytes (1.5 MB)
downloaded 1.5 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/rstudioapi_0.16.0.zip'
Content type 'application/zip' length 328156 bytes (320 KB)
downloaded 320 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/rvest_1.0.4.zip'
Content type 'application/zip' length 304882 bytes (297 KB)
downloaded 297 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/stringr_1.5.1.zip'
Content type 'application/zip' length 319212 bytes (311 KB)
downloaded 311 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/tibble_3.2.1.zip'
Content type 'application/zip' length 691031 bytes (674 KB)
downloaded 674 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/tidyr_1.3.1.zip'
Content type 'application/zip' length 1267035 bytes (1.2 MB)
downloaded 1.2 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/xml2_1.3.6.zip'
Content type 'application/zip' length 1608003 bytes (1.5 MB)
downloaded 1.5 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/classInt_0.4-10.zip'
Content type 'application/zip' length 503828 bytes (492 KB)
downloaded 492 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/DBI_1.2.2.zip'
Content type 'application/zip' length 910660 bytes (889 KB)
downloaded 889 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/s2_1.1.6.zip'
Content type 'application/zip' length 3504497 bytes (3.3 MB)
downloaded 3.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/units_0.8-5.zip'
Content type 'application/zip' length 800620 bytes (781 KB)
downloaded 781 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/countrycode_1.6.0.zip'
Content type 'application/zip' length 1267449 bytes (1.2 MB)
downloaded 1.2 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/geojsonsf_2.0.3.zip'
Content type 'application/zip' length 2044848 bytes (2.0 MB)
downloaded 2.0 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/rappdirs_0.3.3.zip'
Content type 'application/zip' length 51441 bytes (50 KB)
downloaded 50 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/curl_5.2.1.zip'
Content type 'application/zip' length 3217972 bytes (3.1 MB)
downloaded 3.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/tidyverse_2.0.0.zip'
Content type 'application/zip' length 430920 bytes (420 KB)
downloaded 420 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/sf_1.0-16.zip'
Content type 'application/zip' length 39221690 bytes (37.4 MB)
downloaded 37.4 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/giscoR_0.4.2.zip'
Content type 'application/zip' length 1867306 bytes (1.8 MB)
downloaded 1.8 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/magick_2.8.3.zip'
Content type 'application/zip' length 24761087 bytes (23.6 MB)
downloaded 23.6 MB

package ‘fastmap’ successfully unpacked and MD5 sums checked
package ‘colorspace’ successfully unpacked and MD5 sums checked
package ‘sys’ successfully unpacked and MD5 sums checked
package ‘bit’ successfully unpacked and MD5 sums checked
package ‘ps’ successfully unpacked and MD5 sums checked
package ‘base64enc’ successfully unpacked and MD5 sums checked
package ‘sass’ successfully unpacked and MD5 sums checked
package ‘digest’ successfully unpacked and MD5 sums checked
package ‘cachem’ successfully unpacked and MD5 sums checked
package ‘farver’ successfully unpacked and MD5 sums checked
package ‘labeling’ successfully unpacked and MD5 sums checked
package ‘munsell’ successfully unpacked and MD5 sums checked
package ‘RColorBrewer’ successfully unpacked and MD5 sums checked
package ‘viridisLite’ successfully unpacked and MD5 sums checked
package ‘rematch’ successfully unpacked and MD5 sums checked
package ‘askpass’ successfully unpacked and MD5 sums checked
package ‘bit64’ successfully unpacked and MD5 sums checked
package ‘prettyunits’ successfully unpacked and MD5 sums checked
package ‘processx’ successfully unpacked and MD5 sums checked
package ‘evaluate’ successfully unpacked and MD5 sums checked
package ‘highr’ successfully unpacked and MD5 sums checked
package ‘xfun’ successfully unpacked and MD5 sums checked
package ‘yaml’ successfully unpacked and MD5 sums checked
package ‘bslib’ successfully unpacked and MD5 sums checked
package ‘fontawesome’ successfully unpacked and MD5 sums checked
package ‘htmltools’ successfully unpacked and MD5 sums checked
package ‘jquerylib’ successfully unpacked and MD5 sums checked
package ‘tinytex’ successfully unpacked and MD5 sums checked
package ‘proxy’ successfully unpacked and MD5 sums checked
package ‘backports’ successfully unpacked and MD5 sums checked
package ‘ellipsis’ successfully unpacked and MD5 sums checked
package ‘generics’ successfully unpacked and MD5 sums checked
package ‘glue’ successfully unpacked and MD5 sums checked
package ‘lifecycle’ successfully unpacked and MD5 sums checked
package ‘memoise’ successfully unpacked and MD5 sums checked
package ‘blob’ successfully unpacked and MD5 sums checked
package ‘R6’ successfully unpacked and MD5 sums checked
package ‘tidyselect’ successfully unpacked and MD5 sums checked
package ‘vctrs’ successfully unpacked and MD5 sums checked
package ‘withr’ successfully unpacked and MD5 sums checked
package ‘data.table’ successfully unpacked and MD5 sums checked
package ‘gtable’ successfully unpacked and MD5 sums checked
package ‘isoband’ successfully unpacked and MD5 sums checked
package ‘scales’ successfully unpacked and MD5 sums checked
package ‘gargle’ successfully unpacked and MD5 sums checked
package ‘uuid’ successfully unpacked and MD5 sums checked
package ‘cellranger’ successfully unpacked and MD5 sums checked
package ‘ids’ successfully unpacked and MD5 sums checked
package ‘rematch2’ successfully unpacked and MD5 sums checked
package ‘cpp11’ successfully unpacked and MD5 sums checked
package ‘pkgconfig’ successfully unpacked and MD5 sums checked
package ‘mime’ successfully unpacked and MD5 sums checked
package ‘openssl’ successfully unpacked and MD5 sums checked
package ‘timechange’ successfully unpacked and MD5 sums checked
package ‘fansi’ successfully unpacked and MD5 sums checked
package ‘utf8’ successfully unpacked and MD5 sums checked
package ‘systemfonts’ successfully unpacked and MD5 sums checked
package ‘textshaping’ successfully unpacked and MD5 sums checked
package ‘clipr’ successfully unpacked and MD5 sums checked
package ‘crayon’ successfully unpacked and MD5 sums checked
package ‘vroom’ successfully unpacked and MD5 sums checked
package ‘tzdb’ successfully unpacked and MD5 sums checked
package ‘progress’ successfully unpacked and MD5 sums checked
package ‘callr’ successfully unpacked and MD5 sums checked
package ‘fs’ successfully unpacked and MD5 sums checked
package ‘knitr’ successfully unpacked and MD5 sums checked
package ‘rmarkdown’ successfully unpacked and MD5 sums checked
package ‘selectr’ successfully unpacked and MD5 sums checked
package ‘stringi’ successfully unpacked and MD5 sums checked
package ‘e1071’ successfully unpacked and MD5 sums checked
package ‘wk’ successfully unpacked and MD5 sums checked
package ‘geometries’ successfully unpacked and MD5 sums checked
package ‘jsonify’ successfully unpacked and MD5 sums checked
package ‘rapidjsonr’ successfully unpacked and MD5 sums checked
package ‘sfheaders’ successfully unpacked and MD5 sums checked
package ‘broom’ successfully unpacked and MD5 sums checked
package ‘conflicted’ successfully unpacked and MD5 sums checked
package ‘cli’ successfully unpacked and MD5 sums checked
package ‘dbplyr’ successfully unpacked and MD5 sums checked
package ‘dplyr’ successfully unpacked and MD5 sums checked
package ‘dtplyr’ successfully unpacked and MD5 sums checked
package ‘forcats’ successfully unpacked and MD5 sums checked
package ‘ggplot2’ successfully unpacked and MD5 sums checked
package ‘googledrive’ successfully unpacked and MD5 sums checked
package ‘googlesheets4’ successfully unpacked and MD5 sums checked
package ‘haven’ successfully unpacked and MD5 sums checked
package ‘hms’ successfully unpacked and MD5 sums checked
package ‘httr’ successfully unpacked and MD5 sums checked
package ‘lubridate’ successfully unpacked and MD5 sums checked
package ‘magrittr’ successfully unpacked and MD5 sums checked
package ‘modelr’ successfully unpacked and MD5 sums checked
package ‘pillar’ successfully unpacked and MD5 sums checked
package ‘purrr’ successfully unpacked and MD5 sums checked
package ‘ragg’ successfully unpacked and MD5 sums checked
package ‘readr’ successfully unpacked and MD5 sums checked
package ‘readxl’ successfully unpacked and MD5 sums checked
package ‘reprex’ successfully unpacked and MD5 sums checked
package ‘rlang’ successfully unpacked and MD5 sums checked
package ‘rstudioapi’ successfully unpacked and MD5 sums checked
package ‘rvest’ successfully unpacked and MD5 sums checked
package ‘stringr’ successfully unpacked and MD5 sums checked
package ‘tibble’ successfully unpacked and MD5 sums checked
package ‘tidyr’ successfully unpacked and MD5 sums checked
package ‘xml2’ successfully unpacked and MD5 sums checked
package ‘classInt’ successfully unpacked and MD5 sums checked
package ‘DBI’ successfully unpacked and MD5 sums checked
package ‘s2’ successfully unpacked and MD5 sums checked
package ‘units’ successfully unpacked and MD5 sums checked
package ‘countrycode’ successfully unpacked and MD5 sums checked
package ‘geojsonsf’ successfully unpacked and MD5 sums checked
package ‘rappdirs’ successfully unpacked and MD5 sums checked
package ‘curl’ successfully unpacked and MD5 sums checked
package ‘tidyverse’ successfully unpacked and MD5 sums checked
package ‘sf’ successfully unpacked and MD5 sums checked
package ‘giscoR’ successfully unpacked and MD5 sums checked
package ‘magick’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Adil\AppData\Local\Temp\RtmpMBQ68t\downloaded_packages

invisible(

  • lapply(
    
  •     libs, library,
    
  •     character.only = T
    
  • )
    
  • )
    ── Attaching core tidyverse packages ────────────────────────────────────────────────── tidyverse 2.0.0 ──
    ✔ dplyr 1.1.4 ✔ readr 2.1.5
    ✔ forcats 1.0.0 ✔ stringr 1.5.1
    ✔ ggplot2 3.5.0 ✔ tibble 3.2.1
    ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
    ✔ purrr 1.0.2
    ── Conflicts ──────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
    ✖ dplyr::filter() masks stats::filter()
    ✖ dplyr::lag() masks stats::lag()
    ℹ Use the conflicted package to force all conflicts to become errors
    Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
    Linking to ImageMagick 6.9.12.98
    Enabled features: cairo, freetype, fftw, ghostscript, heic, lcms, pango, raw, rsvg, webp
    Disabled features: fontconfig, x11
    There were 13 warnings (use warnings() to see them)

1. GET COUNTRY BORDERS

#-----------------------
print("GET COUNTRY BORDERS")
[1] "GET COUNTRY BORDERS"
get_country_borders <- function() {

  • country_borders <- giscoR::gisco_get_countries(
    
  •     resolution = "3",
    
  •     country = "US"
    
  • )
    
  • return(country_borders)
    
  • }

country_borders <- get_country_borders()

2. GET BASINS

#---------------
print("GET BASINS")
[1] "GET BASINS"

https://data.hydrosheds.org/file/HydroBASINS/standard/hybas_sa_lev03_v1c.zip

get_basins <- function() {

  • url <- "https://data.hydrosheds.org/file/HydroBASINS/standard/hybas_na_lev03_v1c.zip"
    
  • file_name <- "hybas_na_lev03_v1c.zip"
    
  • download.file(
    
  •     url = url,
    
  •     destfile = file_name,
    
  •     mode = "wb"
    
  • )
    
  • unzip(file_name)
    
  • }

get_basins()
trying URL 'https://data.hydrosheds.org/file/HydroBASINS/standard/hybas_na_lev03_v1c.zip'
Content type 'application/zip' length 3728058 bytes (3.6 MB)
downloaded 3.6 MB

print("basin downloaded")
[1] "basin downloaded"

list.files()
[1] "hybas_na_lev03_v1c.dbf" "hybas_na_lev03_v1c.prj" "hybas_na_lev03_v1c.sbn"
[4] "hybas_na_lev03_v1c.sbx" "hybas_na_lev03_v1c.shp" "hybas_na_lev03_v1c.shp.xml"
[7] "hybas_na_lev03_v1c.shx" "hybas_na_lev03_v1c.zip" "HydroBASINS_TechDoc_v1c.pdf"
[10] "Test_RiverBasin.Rproj"

print("load basin")
[1] "load basin"
load_basins <- function() {

  • print("loading filenames")
    
  • filenames <- list.files(
    
  •     pattern = ".shp$",
    
  •     full.names = TRUE
    
  • )
    
  • print(filenames)
    
  • namerica_basin <- sf::st_read(
    
  •     filenames
    
  • )
    
  • return(namerica_basin)
    
  • }

namerica_basin <- load_basins()
[1] "loading filenames"
[1] "./hybas_na_lev03_v1c.shp"
Reading layer hybas_na_lev03_v1c' from data source C:\Users\Adil\Documents\Test_RiverBasin\hybas_na_lev03_v1c.shp' using driver `ESRI Shapefile'
Simple feature collection with 29 features and 13 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -137.9625 ymin: 5.495833 xmax: -52.61605 ymax: 62.74232
Geodetic CRS: WGS 84
print("basin loaded")
[1] "basin loaded"

print("Intersect Basin with only the wanted Country Boundary.")
[1] "Intersect Basin with only the wanted Country Boundary."
sf::sf_use_s2(F)
Spherical geometry (s2) switched off

brazil_basin <- namerica_basin |>

  • sf::st_intersection(
    
  •     country_borders
    
  • ) |>
    
  • dplyr::select(
    
  •     HYBAS_ID
    
  • )
    

although coordinates are longitude/latitude, st_intersection assumes that they are planar
Warning message:
attribute variables are assumed to be spatially constant throughout all geometries

3. GET RIVERS DATA

#-------------------
print("Get Rivers")
[1] "Get Rivers"

https://data.hydrosheds.org/file/HydroRIVERS/HydroRIVERS_v10_sa_shp.zip

get_rivers <- function() {

  • url <- "https://data.hydrosheds.org/file/HydroRIVERS/HydroRIVERS_v10_na_shp.zip"
    
  • file_name <- "na-rivers.zip"
    
  • download.file(
    
  •     url = url,
    
  •     destfile = file_name,
    
  •     mode = "wb"
    
  • )
    
  • unzip(file_name)
    
  • }

get_rivers()
trying URL 'https://data.hydrosheds.org/file/HydroRIVERS/HydroRIVERS_v10_na_shp.zip'
Content type 'application/zip' length 66335898 bytes (63.3 MB)
downloaded 63.3 MB

print("Getting Rivers")
[1] "Getting Rivers"
list.files()
[1] "hybas_na_lev03_v1c.dbf" "hybas_na_lev03_v1c.prj" "hybas_na_lev03_v1c.sbn"
[4] "hybas_na_lev03_v1c.sbx" "hybas_na_lev03_v1c.shp" "hybas_na_lev03_v1c.shp.xml"
[7] "hybas_na_lev03_v1c.shx" "hybas_na_lev03_v1c.zip" "HydroBASINS_TechDoc_v1c.pdf"
[10] "HydroRIVERS_TechDoc_v10.pdf" "HydroRIVERS_v10_na_shp" "na-rivers.zip"
[13] "Test_RiverBasin.Rproj"

load_rivers <- function() {

  • filenames <- list.files(
    
  •     path = "HydroRIVERS_v10_na_shp",
    
  •     pattern = ".shp$",
    
  •     full.names = T
    
  • )
    
  • print(filenames)
    
  • namerica_rivers <- sf::st_read(
    
  •     filenames
    
  • )
    
  • return(namerica_rivers)
    
  • }

namerica_rivers <- load_rivers()
[1] "HydroRIVERS_v10_na_shp/HydroRIVERS_v10_na.shp"
Reading layer HydroRIVERS_v10_na' from data source C:\Users\Adil\Documents\Test_RiverBasin\HydroRIVERS_v10_na_shp\HydroRIVERS_v10_na.shp'
using driver `ESRI Shapefile'
Simple feature collection with 986463 features and 14 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: -137.9354 ymin: 5.510417 xmax: -52.66458 ymax: 62.67292
Geodetic CRS: WGS 84

brazil_rivers <- namerica_rivers |>

  • dplyr::select(
    
  •     ORD_FLOW
    
  • ) |>
    
  • sf::st_intersection(
    
  •     country_borders
    
  • )
    

although coordinates are longitude/latitude, st_intersection assumes that they are planar
Warning message:
attribute variables are assumed to be spatially constant throughout all geometries

4. DETERMINE BASIN FOR EVERY RIVER

#-----------------------------------

brazil_river_basin <- sf::st_intersection(

  • brazil_rivers,
    
  • brazil_basin
    
  • )
    although coordinates are longitude/latitude, st_intersection assumes that they are planar
    Warning message:
    attribute variables are assumed to be spatially constant throughout all geometries

5. RIVER WIDTH

#---------------

unique(brazil_river_basin$ORD_FLOW)
[1] 8 9 7 10 6 5 4 3 2

brazil_river_basin_width <- brazil_river_basin |>

  • dplyr::mutate(
    
  •     width = as.numeric(
    
  •         ORD_FLOW
    
  •     ),
    
  •     width = dplyr::case_when(
    
  •         width == 1 ~ .8,
    
  •         width == 2 ~ .7,
    
  •         width == 3 ~ .6,
    
  •         width == 4 ~ .45,
    
  •         width == 5 ~ .35,
    
  •         width == 6 ~ .25,
    
  •         width == 7 ~ .2,
    
  •         width == 8 ~ .15,
    
  •         width == 9 ~ .1,
    
  •         TRUE ~ 0
    
  •     )
    
  • ) |>
    
  • sf::st_as_sf()
    

6. PLOT

#--------

unique(

  • brazil_river_basin_width$HYBAS_ID
    
  • )
    [1] 7030000010 7030008710 7030008720 7030014250 7030014930 7030014940 7030022240 7030034520 7030034530
    [10] 7030038340 7030042040 7030046750 7030047060 7030047070 7030047840 7030049270 7030073620

hcl.pals("qualitative")
[1] "Pastel 1" "Dark 2" "Dark 3" "Set 2" "Set 3" "Warm" "Cold" "Harmonic" "Dynamic"

p <- ggplot() +

  • geom_sf(
    
  •     data = brazil_river_basin_width,
    
  •     aes(
    
  •         color = factor(
    
  •             HYBAS_ID
    
  •         ),
    
  •         size = width,
    
  •         alpha = width
    
  •     )
    
  • ) +
    
  • scale_color_manual(
    
  •     name = "",
    
  •     values = hcl.colors(
    
  •         17, "Dark 3",
    
  •         alpha = 1
    
  •     )
    
  • ) +
    
  • scale_size(
    
  •     range = c(.1, .7)
    
  • ) +
    
  • scale_alpha(
    
  •     range = c(.01, .7)
    
  • ) +
    
  • theme_void() +
    
  • theme(
    
  •     legend.position = "none",
    
  •     plot.caption = element_text(
    
  •         size = 9, color = "grey60",
    
  •         hjust = .1, vjust = 10
    
  •     ),
    
  •     plot.margin = unit(
    
  •         c(
    
  •             t = 0, r = 0,
    
  •             b = 0, l = 0
    
  •         ),
    
  •         "lines"
    
  •     ),
    
  •     plot.background = element_rect(
    
  •         fill = "black",
    
  •         color = NA
    
  •     ),
    
  •     panel.background = element_rect(
    
  •         fill = "black",
    
  •         color = NA
    
  •     )
    
  • ) +
    
  • labs(
    
  •     title = "",
    
  •     x = "",
    
  •     y = "",
    
  •     # caption = "Source: ©World Wildlife Fund, Inc. (2006-2013) HydroSHEDS database http://www.hydrosheds.org"
    
  • )
    

ggsave(

  • filename = "us-river-basins.png",
    
  • width = 7, height = 7.75, dpi = 600,
    
  • bg = "white", device = "png", p
    
  • )

st_write(brazil_river_basin_width, "us-river-basins.geojson", layer = NULL, driver = "GeoJson")
Writing layer us-river-basins' to data source us-river-basins.geojson' using driver `GeoJson'
Writing 464880 features with 8 fields and geometry type Unknown (any).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant