Re: [R-sig-Geo] raster: stackApply problems..

2019-12-15 Thread Leonidas Liakos via R-sig-Geo
 Thank you, I did a Pull Request.
Στις Πέμπτη, 28 Νοεμβρίου 2019, 01:25:38 μ.μ. EET, ο χρήστης Roger Bivand 
 έγραψε:  
 
 On Wed, 27 Nov 2019, Leonidas Liakos via R-sig-Geo wrote:

> Thank you for your help!
>
> I tried to fix stackApply according to your instructions.
>
> Now the indices of names are the same and consistent with indices
> enumeration (gist for validation and tests:
> https://gist.github.com/kokkytos/93f315a5ecf59c0b183f9788754bc170).
>
> I've attached a patch file here:
>
> https://gist.github.com/kokkytos/ca2c319134677b19900579665267a7a7

Thanks very much for contributing!

Please consider raising an issue on https://github.com/rspatial/raster 
pointing to this thread and your patch. I had expected response from 
raster developers here, but they may well be on field work, so raising an 
issue on the development site should get their attention when there is 
enough time for them to look. You might even fork raster, apply your patch 
and file a PR in addition to the issue. In that case, a short test would 
be helpful, and maybe edits to the documentation.

Roger


>
>> stackapply_mean
> class  : RasterBrick
> dimensions : 300, 300, 9, 7  (nrow, ncol, ncell, nlayers)
> resolution : 500, 500  (x, y)
> extent : 0, 15, 0, 15  (xmin, xmax, ymin, ymax)
> crs    : NA
> source : /tmp/Rtmp9W8UNc/raster/r_tmp_2019-11-27_191205_2929_20324.grd
> names  :  index_5,  index_6,  index_7,  index_1,  index_2, 
> index_3,  index_4
> min values : 444.6946, 440.2028, 429.6900, 442.7436, 440.0467, 444.9182,
> 437.1589
> max values : 565.8671, 560.1375, 561.7972, 556.2471, 563.8341, 561.7687,
> 560.4509
>
>> ver_mean
> class  : RasterStack
> dimensions : 300, 300, 9, 7  (nrow, ncol, ncell, nlayers)
> resolution : 500, 500  (x, y)
> extent : 0, 15, 0, 15  (xmin, xmax, ymin, ymax)
> crs    : NA
> names  :  layer.1,  layer.2,  layer.3,  layer.4,  layer.5, 
> layer.6,  layer.7
> min values : 442.7436, 440.0467, 444.9182, 437.1589, 444.6946, 440.2028,
> 429.6900
> max values : 556.2471, 563.8341, 561.7687, 560.4509, 565.8671, 560.1375,
> 561.7972
>
>
>
>
>
> On 11/26/19 10:58 PM, Vijay Lulla wrote:
>> Hmm...it appears that stackApply is using different conditions which
>> might be causing this problem. Below is the snippet of the code which
>> I think might be the problem.
>>
>> ## For canProcessInMemory
>> if (rowcalc) {
>>   v <- lapply(uin, function(i) fun(x[, ind == i, drop = FALSE], na.rm
>> = na.rm))
>> }
>> else {
>>   v <- lapply(uin, function(i, ...) apply(x[, ind == i, drop = FALSE],
>> 1, fun, na.rm = na.rm))
>> }
>>
>>
>> ## If canProcessInMemory is not TRUE
>> if (rowcalc) {
>>   v <- lapply(uin, function(i) fun(a[, ind == uin[i], drop = FALSE],
>> na.rm = na.rm))
>> }
>> else {
>>   v <- lapply(uin, function(i, ...) apply(a[, ind == uin[i], drop =
>> FALSE], 1, fun, na.rm = na.rm))
>> }
>>
>> I think they should both be same but it appears that they aren't and
>> that's what you've discovered.  Maybe you can try fix(stackApply) to
>> see if it really is the problem and can tell us what you find. 
>> Anyways, good catch...and...sorry for wasting your time.
>> Cordially,
>> Vijay.
>>
>> On Tue, Nov 26, 2019 at 2:53 PM Leonidas Liakos
>> mailto:leonidas_lia...@yahoo.gr>> wrote:
>>
>>    Thank you!
>>    The problem is not with the resulting values but with the index
>>    mapping. Values are correct in all three cases.
>>
>>    As I wrote in a previous post in the thread
>>    (https://stat.ethz.ch/pipermail/r-sig-geo/2019-November/027821.html)
>>    , stackApply behaves inconsistently depending on whether the
>>    exported stack will remain in memory or it will be stored, due to
>>    its large size, on the hard disk.
>>
>>    In the first case the indices are identical to my function
>>    (ver_mean) and the lubridate::wday indexing system (and are
>>    correct) while in the second they are shuffled.
>>
>>    So, while Sunday has index 1 and while in the first case (when the
>>    result is in memory) stackApply returns the correct index, in the
>>    second case (when the result is stored on the hard disk) it
>>    returns index_4! So how can one be sure if index_1 corresponds to
>>    Sunday or another day using stackApply since it sometimes
>>    enumerates it with index_1 and sometimes index_4?
>>
>>
>>    Try to run this example (when the resulting stack remains in
>>    memory) to see that the indexes are identical (stackApply =
>>    ver_median = lubridate::wday)
>>    https://gist.github.com/kokkytos/5d554b5a725bb48d2189e2d1fa0e2206
>>
>>    Thank you again
>>
>>    On 11/26/19 9:00 PM, Vijay Lulla wrote:
>>>    I'm sorry for the miscommunication.  What I meant to say is that
>>>    the output from stackApply and zApply are the same (because
>>>    zApply uses stackApply internally) except the names.  The
>>>    behavior of stackApply makes sense because AFAIUI R doesn't
>>>    automatically reorder vectors/indices that it 

Re: [R-sig-Geo] Package 'gdalUtils' when using 'gdal_translate' on HDF files it gives error "no installation match"

2019-12-15 Thread Lorenzo Busetto
The `gdal_chooseInstallation ` issue should be indeed related to switching
to GDAL3. The problem should have been already addressed in the github repo
here:

https://github.com/gearslaboratory/gdalUtils/commit/a94bbe422e7fe3bda1f571fc3629c3d052b4f195


Therefore, installing from github should solve the issue and allow you to
keep working with GDAL3 (at least, it did it for me).

Note that on Windows the gdalUtils package has some additionals problems
related with GDAL 3 migration due to issues reported here:

https://github.com/r-spatial/discuss/issues/31

HTH,

 Lorenzo

PS: For Francisco: sorry for the double replies, but I noticed that by
mistake I replied only to you and not to the list.

On Fri, 13 Dec 2019 at 13:40, Francisco Zambrano  wrote:

> Hi all,
>
> I'm using the package gdalUtils to work with HDF (MODIS data), I've used
> for a while without problems, but now (I believe after the update of gdal)
> is giving me the following error when I use the function 'gdal_translate'
> over HDF files. A time before this used to work fine.
>
> Error in gdal_chooseInstallation(hasDrivers = of) :
>   No installations match.
>
>
> also,
>
> gdal_chooseInstallation(hasDrivers=c("HDF4","HDF5"))Error in
> gdal_chooseInstallation(hasDrivers = c("HDF4", "HDF5")) :
>   No installations match.
>
> The version and date for gdal are:
>
> > getOption("gdalUtils_gdalPath")[[1]]$versionversion
> "3.0.2" > getOption("gdalUtils_gdalPath")[[1]]$datedate
> "2019-10-28"
>
>
> Searching the HDF drivers I get:
>
> >
> getOption("gdalUtils_gdalPath")[[1]]$drivers[grep('HDF',getOption("gdalUtils_gdalPath")[[1]]$drivers$format_name),]
> format_code read write update virtualIO subdatasets  format_name
> 43  HDF4Image-raster- TRUE  TRUE   TRUE FALSE   FALSE HDF4 Dataset
> 114 HDF5Image-raster- TRUE FALSE  FALSE  TRUE   FALSE HDF5 Dataset
>
>
> My sessionInfo():
>
> R version 3.6.1 (2019-07-05)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 18.04.3 LTS
>
> Matrix products: default
> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
>
> locale:
>  [1] LC_CTYPE=es_CL.UTF-8   LC_NUMERIC=C
> LC_TIME=es_CL.UTF-8
>  [4] LC_COLLATE=es_CL.UTF-8 LC_MONETARY=es_CL.UTF-8
> LC_MESSAGES=es_CL.UTF-8
>  [7] LC_PAPER=es_CL.UTF-8   LC_NAME=C
> LC_ADDRESS=C
> [10] LC_TELEPHONE=C LC_MEASUREMENT=es_CL.UTF-8
> LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] stringr_1.4.0  gdalUtils_2.0.1.14 purrr_0.3.3
> raster_3.0-7   sp_1.3-1
>
> loaded via a namespace (and not attached):
>  [1] Rcpp_1.0.2lattice_0.20-38   codetools_0.2-16
> foreach_1.4.7 R.methodsS3_1.7.1
>  [6] grid_3.6.1magrittr_1.5  stringi_1.4.3 rlang_0.4.1
>   R.oo_1.23.0
> [11] R.utils_2.9.0 rgdal_1.4-8   iterators_1.0.12  tools_3.6.1
>   compiler_3.6.1
>
>
> Regards,
>
> Francisco
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo