AustralianAntarcticDivision / SOmap

Southern Ocean round maps
https://australianantarcticdivision.github.io/SOmap/
24 stars 6 forks source link

Bizarro figure being chopped off #87

Closed raymondben closed 4 years ago

raymondben commented 4 years ago

Does anyone else see this?

SOmap()

Happening on Windows only, not a problem on Linux.

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

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

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

other attached packages:
[1] SOmap_0.6.0    testthat_2.3.2 raster_3.3-6   sp_1.4-2      

loaded via a namespace (and not attached):
 [1] nlme_3.1-148          fs_1.4.1              sf_0.9-4              usethis_1.6.1         devtools_2.3.0        rprojroot_1.3-2      
 [7] tools_4.0.2           backports_1.1.7       rgdal_1.5-12          R6_2.4.1              rpart_4.1-15          KernSmooth_2.23-17   
[13] rgeos_0.5-3           DBI_1.1.0             mgcv_1.8-31           colorspace_1.4-1      spbabel_0.5.1         withr_2.2.0          
[19] tidyselect_1.1.0      prettyunits_1.1.1     processx_3.4.2        compiler_4.0.2        cli_2.0.2             quadmesh_0.4.5       
[25] desc_1.2.0            graticule_0.1.2       reproj_0.4.2.9001     tabularaster_0.6.5    scales_1.1.1          spatstat.data_1.4-3  
[31] proj4_1.0-10          classInt_0.4-3        callr_3.4.3           spatstat_1.64-1       goftest_1.2-2         digest_0.6.25        
[37] spatstat.utils_1.17-0 rmarkdown_2.3         pkgconfig_2.0.3       htmltools_0.5.0       sessioninfo_1.1.1     rlang_0.4.6          
[43] rstudioapi_0.11       generics_0.0.2        dplyr_1.0.0           magrittr_1.5          geosphere_1.5-10      Matrix_1.2-18        
[49] Rcpp_1.0.4.6          munsell_0.5.0         fansi_0.4.1           clipr_0.7.0           abind_1.4-5           lifecycle_0.2.0      
[55] whisker_0.4           spex_0.7.1            pkgbuild_1.0.8        grid_4.0.2            parallel_4.0.2        crayon_1.3.4         
[61] deldir_0.1-25         lattice_0.20-41       stars_0.4-1           splines_4.0.2         tensor_1.5            knitr_1.28           
[67] ps_1.3.3              pillar_1.4.4          uuid_0.1-4            codetools_0.2-16      pkgload_1.1.0         magic_1.5-9          
[73] reprex_0.3.0          glue_1.4.1            evaluate_0.14         remotes_2.1.1         png_0.1-7             vctrs_0.3.1          
[79] gtable_0.3.0          purrr_0.3.4           polyclip_1.10-0       assertthat_0.2.1      ggplot2_3.3.2         xfun_0.14            
[85] lwgeom_0.2-5          e1071_1.7-3           class_7.3-17          viridisLite_0.3.0     geometry_0.4.5        tibble_3.0.1         
[91] memoise_1.1.0         units_0.6-7           ellipsis_0.3.1
bootneck2000 commented 4 years ago

Same issue but on a mac, so i guess "pretend" Linux too

R version 4.0.1 (2020-06-06) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Catalina 10.15.5

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages: [1] SOmap_0.5.2.9999 raster_3.3-7 trip_1.7.1
[4] sp_1.4-2

loaded via a namespace (and not attached): [1] tidyselect_1.1.0 remotes_2.1.1 sf_0.9-4
[4] purrr_0.3.4 splines_4.0.1 lattice_0.20-41
[7] generics_0.0.2 colorspace_1.4-1 spatstat.utils_1.17-0 [10] vctrs_0.3.1 graticule_0.1.2 mgcv_1.8-31
[13] rlang_0.4.6 pkgbuild_1.0.8 e1071_1.7-3
[16] spatstat.data_1.4-3 pillar_1.4.4 DBI_1.1.0
[19] spatstat_1.64-1 foreign_0.8-80 glue_1.4.1
[22] withr_2.2.0 crsmeta_0.3.0 lifecycle_0.2.0
[25] rgeos_0.5-3 munsell_0.5.0 gtable_0.3.0
[28] codetools_0.2-16 traipse_0.1.0 callr_3.4.3
[31] maptools_1.0-1 ps_1.3.3 class_7.3-17
[34] fansi_0.4.1 reproj_0.4.2 Rcpp_1.0.4.6
[37] KernSmooth_2.23-17 tensor_1.5 classInt_0.4-3
[40] backports_1.1.8 scales_1.1.1 abind_1.4-5
[43] deldir_0.1-25 proj4_1.0-10 ggplot2_3.3.2
[46] dplyr_1.0.0 processx_3.4.2 polyclip_1.10-0
[49] grid_4.0.1 rprojroot_1.3-2 rgdal_1.5-12
[52] cli_2.0.2 tools_4.0.1 magrittr_1.5
[55] goftest_1.2-2 tibble_3.0.1 crayon_1.3.4
[58] pkgconfig_2.0.3 MASS_7.3-51.6 ellipsis_0.3.1
[61] Matrix_1.2-18 prettyunits_1.1.1 assertthat_0.2.1
[64] rstudioapi_0.11 R6_2.4.1 rpart_4.1-15
[67] units_0.6-7 nlme_3.1-148 compiler_4.0.1

mdsumner commented 4 years ago

I blame raster. I wasn't seeing it in a prior version (3.1-5), but I do see it in 3.3-6 (3.3-7 came out a few days ago).

So probably not a SOmap issue (I'll pursue)

raymondben commented 4 years ago

thanks @bootneck2000 for the confirmation @mdsumner - that's consistent with what I'm seeing too - my Linux box (working OK) is raster 3.1.5/R 3.6.3, my Windows (R 3.6.3 and 4.02) are raster 3.3.7 and 3.3.6, not working with either of those. thanks

mdsumner commented 4 years ago

hmm, but in SOmap I expect this from Bathy

class      : RasterLayer 
dimensions : 1384, 1418, 1962512  (nrow, ncol, ncell)
resolution : 16000, 16000  (x, y)
extent     : -11344000, 11344000, -11344000, 10800000  (xmin, xmax, ymin, ymax)
crs        : +proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
source     : memory
names      : Elevation.relative.to.sea.level 
values     : -10352, 6049  (min, max)

In SOmap() now I see this, so looks like it is our fault

x <- SOmap()
 x$bathy[[1]]$plotargs$x
class      : RasterLayer 
dimensions : 860, 861, 740460  (nrow, ncol, ncell)
resolution : 16000, 16000  (x, y)
extent     : -2976000, 10800000, -6880000, 6880000  (xmin, xmax, ymin, ymax)
crs        : +proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
source     : memory
names      : Elevation.relative.to.sea.level 
values     : -9637, 4081  (min, max)
raymondben commented 4 years ago

Pretty sure it's the trim operation on https://github.com/AustralianAntarcticDivision/SOmap/blob/dev-0.6/R/SOmap.R#L68 Remove the trim but leave everything else and it's OK (just with a lot of whitespace)

mdsumner commented 4 years ago

it's definitely isolated to the earlier raster versions though, it's just not only about the plot ... - I probably will put this aside for now for health reasons more tmw

mdsumner commented 4 years ago

yes good one, works in early raster fails now:

library(SOmap)
x <- Bathy
x1 <- SOmap::latmask(x, -45)
plot(x1)  ## ok
plot(trim(x1))  ## bad in raster >=3.3-6
mdsumner commented 4 years ago

reprex!

v <- raster(volcano)
v[v < 150] <- NA
plot(v)          ## good 
plot(trim(v)) ## bad
mdsumner commented 4 years ago

huh, beaten to it: https://github.com/rspatial/raster/issues/138

so, we can forget it!

raymondben commented 4 years ago

added a check/warning in onLoad, at least temporarily