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

Level 2 polygons: no projection (?) + longitude exceeds |180| #7

Open
MarcRieraDominguez opened this issue Nov 12, 2021 · 0 comments
Open

Comments

@MarcRieraDominguez
Copy link

Hi!
I'd like to share some issues I have encountered when loading and operating with the level 2 polygons, with R. I'm not an expert on R or GIS, or anything, sorry if I ask silly questions.

  • Is there any issue with the projection of the polygons? I have downloaded the files from here, but when I load the polygons into R as simple features (sf::read_sf()), the polygons have no CRS. I have assigned the polygons the same CRS as the WorldClim v1.4 rasters: +proj=longlat +datum=WGS84 +no_defs.

  • The bounding box exceeds |180|: not a big deal, but might hint that something is off?

sf::st_bbox(lv2)
      xmin       ymin       xmax       ymax 
-180.00006  -90.00000  180.00004   83.62361 
  • Issues when intersecting with points: I tried performing an intersection between the polygons and some coordinates (sf::st_intersection()), and got an error message:
Error in s2_geography_from_wkb(x, oriented = oriented, check = check) : 
  Evaluation error: Found 1 feature with invalid spherical geometry.
[1] Loop 222 is not valid: Edge 7469 has duplicate vertex with edge 7480.

Nevertheless, I could perform the intersection (and the result appear OK) after setting: sf::sf_use_s2(FALSE).

None of these are major problems, as I am able to perform the GIS opeartions I need. Some of these issues might be the result of inexperience and not issues per se, but I thought it best to share them than just ignoring them.
Thank you for your time! :)

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252    LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C                   LC_TIME=Spanish_Spain.1252    

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] tictoc_1.0.1               terra_1.4-11               ecospat_3.2                gbm_2.1.8                  ape_5.5                    ade4_1.7-18                raster_3.5-2              
 [8] sp_1.4-5                   CoordinateCleaner_2.0-18   sf_1.0-2                   countrycode_1.3.0          extrafont_0.17             scales_1.1.1               rgbif_3.6.0               
[15] data.table_1.14.0          PerformanceAnalytics_2.0.4 xts_0.12.1                 zoo_1.8-9                  openxlsx_4.2.4             forcats_0.5.1              stringr_1.4.0             
[22] dplyr_1.0.7                purrr_0.3.4                readr_2.0.1                tidyr_1.1.3                tibble_3.1.4               ggplot2_3.3.5              tidyverse_1.3.1           
[29] readxl_1.3.1              

loaded via a namespace (and not attached):
  [1] utf8_1.2.2            ks_1.13.2             rms_6.2-0             tidyselect_1.1.1      htmlwidgets_1.5.4     grid_4.1.0            maptools_1.1-2        ecodist_2.0.7         pROC_1.18.0          
 [10] munsell_0.5.0         codetools_0.2-18      units_0.7-2           future_1.22.1         withr_2.4.2           colorspace_2.0-2      knitr_1.34            uuid_0.1-4            rstudioapi_0.13      
 [19] stats4_4.1.0          wk_0.5.0              Rttf2pt1_1.3.9        listenv_0.8.0         conditionz_0.1.0      TeachingDemos_2.12    oai_0.3.2             ENMeval_2.0.1         TH.data_1.0-10       
 [28] parallelly_1.28.1     vctrs_0.3.8           generics_0.1.0        ipred_0.9-12          xfun_0.26             randomForest_4.6-14   R6_2.5.1              doParallel_1.0.16     reshape_0.8.8        
 [37] assertthat_0.2.1      multcomp_1.4-17       nnet_7.3-16           rgeos_0.5-8           gtable_0.3.0          wellknown_0.7.4       globals_0.14.0        conquer_1.0.2         mda_0.5-2            
 [46] sandwich_3.0-1        timeDate_3043.102     rlang_0.4.11          MatrixModels_0.5-0    splines_4.1.0         rgdal_1.5-27          extrafontdb_1.0       lazyeval_0.2.2        ModelMetrics_1.2.2.2 
 [55] hexbin_1.28.2         earth_5.3.1           broom_0.7.9           checkmate_2.0.0       biomod2_3.5.1         reshape2_1.4.4        abind_1.4-5           modelr_0.1.8          backports_1.2.1      
 [64] Hmisc_4.5-0           caret_6.0-90          tools_4.1.0           lava_1.6.10           nabor_0.5.0           ellipsis_0.3.2        RColorBrewer_1.1-2    proxy_0.4-26          Rcpp_1.0.7           
 [73] plyr_1.8.6            base64enc_0.1-3       rnaturalearth_0.1.0   classInt_0.4-3        rpart_4.1-15          deldir_1.0-5          haven_2.4.3           cluster_2.1.2         fs_1.5.0             
 [82] magrittr_2.0.1        SparseM_1.81          reprex_2.0.1          mvtnorm_1.1-2         whisker_0.4           matrixStats_0.61.0    hms_1.1.1             jpeg_0.1-9            mclust_5.4.7         
 [91] gridExtra_2.3         compiler_4.1.0        KernSmooth_2.23-20    crayon_1.4.1          htmltools_0.5.2       mgcv_1.8-35           tzdb_0.1.2            Formula_1.2-4         lubridate_1.7.10     
[100] DBI_1.1.1             dbplyr_2.1.1          MASS_7.3-54           boot_1.3-28           Matrix_1.3-3          permute_0.9-5         cli_3.0.1             quadprog_1.5-8        gower_0.2.2          
[109] pkgconfig_2.0.3       geosphere_1.5-14      foreign_0.8-81        recipes_0.1.17        xml2_1.3.2            foreach_1.5.1         plotmo_3.6.1          prodlim_2019.11.13    adehabitatHR_0.4.19  
[118] rvest_1.0.1           digest_0.6.27         pracma_2.3.3          vegan_2.5-7           cellranger_1.1.0      htmlTable_2.2.1       PresenceAbsence_1.1.9 gtools_3.9.2          quantreg_5.86        
[127] CircStats_0.2-6       lifecycle_1.0.1       nlme_3.1-152          dismo_1.3-5           jsonlite_1.7.2        viridisLite_0.4.0     fansi_0.5.0           pillar_1.6.4          lattice_0.20-44      
[136] fastmap_1.1.0         httr_1.4.2            plotrix_3.8-2         survival_3.2-11       glue_1.4.2            rasterVis_0.51.0      zip_2.2.0             png_0.1-7             iterators_1.0.13     
[145] class_7.3-19          adehabitatMA_0.3.14   stringi_1.7.4         maxnet_0.1.4          polspline_1.1.19      adehabitatLT_0.3.25   latticeExtra_0.6-29   snowfall_1.84-6.1     poibin_1.5           
[154] e1071_1.7-8           future.apply_1.8.1   
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