ecohealthalliance / fasterize

High performance raster conversion for modern spatial data 🚀🌏▦
https://ecohealthalliance.github.io/fasterize/
Other
182 stars 15 forks source link

Error in fasterize(pols, r, field = "value", fun = "sum") : No current support for rotated rasters. #27

Closed herryATcsiro closed 1 year ago

herryATcsiro commented 5 years ago

Hi, is this a bug or is it installation specific?

library(sf) library(fasterize) p1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60), c(-180,-20)) hole <- rbind(c(-150,-20), c(-100,-10), c(-110,20), c(-150,-20)) p1 <- list(p1, hole) p2 <- list(rbind(c(-10,0), c(140,60), c(160,0), c(140,-55), c(-10,0))) p3 <- list(rbind(c(-125,0), c(0,60), c(40,5), c(15,-45), c(-125,0))) pols <- st_sf(value = rep(1,3), geometry = st_sfc(lapply(list(p1, p2, p3), st_polygon))) r <- raster(pols, res = 1) r <- fasterize(pols, r, field = "value", fun="sum")

Error in fasterize(pols, r, field = "value", fun = "sum") : No current support for rotated rasters.

sessionInfo() R version 3.6.1 (2019-07-05) Platform: x86_64-pc-linux-gnu (64-bit) Running under: SUSE Linux Enterprise Server 12 SP3

Matrix products: default BLAS/LAPACK: /apps/intel/mkl/2017.2.174/compilers_and_libraries_2017.2.174/linux/mkl/lib/intel64_lin/libmkl_intel_lp64.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] fasterize_1.0.0 sf_0.7-7

loaded via a namespace (and not attached): [1] compiler_3.6.1 magrittr_1.5 class_7.3-15 DBI_1.0.0
[5] tools_3.6.1 units_0.6-3 sp_1.3-1 Rcpp_1.0.2
[9] raster_2.9-23 KernSmooth_2.23-15 codetools_0.2-16 grid_3.6.1
[13] e1071_1.7-2 classInt_0.3-3 lattice_0.20-38

Any suggestions?

JoshOBrien commented 5 years ago

@herryATcsiro -- It must be at least partially installation-specific, as your code works without complaint on my Windows 10 box.

FWIW, comparing my session info to yours, I do notice that I am using more recent versions of (at least) the raster, units, and classInt packages, so maybe start by updating those and trying again?

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] fasterize_1.0.0 sf_0.7-7       

loaded via a namespace (and not attached):
 [1] compiler_3.6.1     magrittr_1.5       class_7.3-15       tools_3.6.1       
 [5] DBI_1.0.0          units_0.6-4        sp_1.3-1           Rcpp_1.0.2        
 [9] raster_3.0-2       KernSmooth_2.23-15 codetools_0.2-16   grid_3.6.1        
[13] e1071_1.7-2        classInt_0.4-1     lattice_0.20-38   
herryATcsiro commented 5 years ago

Weird… Where is it coming from though? It runs into the error message

test_that("rotated rasters not supported", { r1_err <- r1 r1_err@rotated <- TRUEhttps://rdrr.io/r/base/logical.html expect_error(fasterizehttps://rdrr.io/cran/fasterize/man/fasterize.html(pols, r1_err), "No current support for rotated rasters.")

So how could we do a workaround that removes this error check or forces the @rotated<-FALSE

From: JoshOBrien notifications@github.com Sent: Wednesday, 11 September 2019 3:41 AM To: ecohealthalliance/fasterize fasterize@noreply.github.com Cc: Herr, Alexander (L&W, Black Mountain) Alexander.Herr@csiro.au; Mention mention@noreply.github.com Subject: Re: [ecohealthalliance/fasterize] Error in fasterize(pols, r, field = "value", fun = "sum") : No current support for rotated rasters. (#27)

@herryATcsirohttps://github.com/herryATcsiro -- It must be at least partially installation-specific, as your code works without complaint on my Windows 10 box. Full session info follows:

sessionInfo()

R version 3.6.1 (2019-07-05)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:

[1] LC_COLLATE=English_United States.1252

[2] LC_CTYPE=English_United States.1252

[3] LC_MONETARY=English_United States.1252

[4] LC_NUMERIC=C

[5] LC_TIME=English_United States.1252

attached base packages:

[1] stats graphics grDevices utils datasets methods base

other attached packages:

[1] fasterize_1.0.0 sf_0.7-7

loaded via a namespace (and not attached):

[1] compiler_3.6.1 magrittr_1.5 class_7.3-15 tools_3.6.1

[5] DBI_1.0.0 units_0.6-4 sp_1.3-1 Rcpp_1.0.2

[9] raster_3.0-2 KernSmooth_2.23-15 codetools_0.2-16 grid_3.6.1

[13] e1071_1.7-2 classInt_0.4-1 lattice_0.20-38

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ecohealthalliance/fasterize/issues/27?email_source=notifications&email_token=ANEES3PUTV4OGTX6BCMDMO3QI7L2JA5CNFSM4IUVRO6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6L5PVY#issuecomment-530044887, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANEES3LFGUXNS6ZDVFGCNATQI7L2JANCNFSM4IUVRO6A.

mdsumner commented 1 year ago

I can't see how this can be reproduced, a "rotated raster" is just one with non-zero shear elements in the gdal geotransform when it's read.