[R-sig-Geo] Fwd: Problem with writing parameters in overlay()

Agustin Lobo alobolistas at gmail.com
Thu Dec 16 10:52:33 CET 2010


---------- Forwarded message ----------
From: Agustin Lobo <Agustin.Lobo at ija.csic.es>
Date: 2010/12/16
Subject: Re: Problem with writing parameters in overlay()
To: "Robert J. Hijmans" <r.hijmans at gmail.com>, Roger.Bivand at nhh.no,
alobolistas at gmail.com


Robert,

The weird problem at writing raster layers in some cases is also
solved once I remove gdal1.8dev:
> require(rgdal)
Loading required package: rgdal
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.7.3, released 2010/11/10
Path to GDAL shared files: /usr/share/gdal17
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: (autodetected)
 require(raster)

> bN3v2 <- overlay(bN3, bSM3, fun=fun1,filename="bN3v2",overwrite=TRUE,format="EHdr", NAflag=0)

works fine now.

Considering the bug fixed in gdal1.8 that I forwarded you, the problem
should also be solved even using the newest gdal1.8,
but I rather do not test until gdal1.8 is available in ubuntugis. You
might want to keep an eye on this, though.

Agus

On 11/28/2010 01:33 AM, Robert J. Hijmans wrote:
>
> Is it only with overlay, or do other functions have the same problem?
>
>  a<- calc(r2, fun=function(x)x*2, filename="test2", format='GTiff',overwrite=T)
>  a<- aggregate(r2, 10, filename="test2", format='GTiff',overwrite=T)
>
> Robert
>
> On Sat, Nov 27, 2010 at 12:34 PM, Robert J. Hijmans<r.hijmans at gmail.com>  wrote:
>>
>> Hi Agus,
>>
>> This is very strange. Somehow the filetype and filename get mixed up.
>> I cannot reproduce this.
>> Does the below all work for you? (it does for me)
>>
>> library(raster)
>> r<- raster(ncol=10, nrow=10)
>> r<- writeStart(r, filename="test", format="GTiff", overwrite=TRUE)
>> filename(r)
>> r<- writeValues(r, 1:100, 1)
>> filename(r)
>> r<- writeStop(r)
>> filename(r)
>>
>> r<- raster(ncol=10, nrow=10)
>> r[]<- 1:100
>> r2<- r
>>
>> a<- overlay(r, r2, fun=sum, filename="test.tif", overwrite=TRUE, NAflag=0)
>> b<- overlay(r, r2, fun=sum, filename="test.img",overwrite=TRUE, NAflag=0)
>>
>> setOptions(todisk=TRUE)
>> a<- overlay(r, r2, fun=sum, filename="test1", format='GTiff',
>> overwrite=TRUE, NAflag=0)
>>
>> r<- writeRaster(r, filename='r1', overwrite=TRUE)
>> r2<- writeRaster(r2, filename='r1', overwrite=TRUE)
>> a<- overlay(r, r2, fun=sum, filename="test2", format='GTiff',
>> overwrite=TRUE, NAflag=0)
>> setOptions(todisk=FALSE)
>>
>>
>> Thanks for your help, Robert
>>
>>
>> On Sat, Nov 27, 2010 at 3:37 AM, Agustin Lobo<Agustin.Lobo at ija.csic.es>  wrote:
>>>
>>> Robert,
>>>
>>> There is still this problem:
>>> These work:
>>>>
>>>> bN3v2<- overlay(bN3, bSM3, fun=fun1,filename="bN3v2",NAflag=0)
>>>> bN3v2<- overlay(bN3, bSM3,
>>>> fun=fun1,filename="bN3v2",overwrite=TRUE,NAflag=0)
>>>
>>> These do not work (is not a parsing problem?)
>>> (Not critical for me, just trying to help out testing):
>>>>
>>>> bN3v2<- overlay(bN3, bSM3, fun=fun1,filename="bN3v2",overwrite=TRUE,
>>>> format="EHdr", NAflag=0)
>>>
>>> Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",
>>>  :
>>>  file: /home/alobo/EHdr does not exist
>>> Calls: overlay ... raster ->  raster ->  .local ->  .rasterObjectFromFile
>>>
>>>> bN3v2<- overlay(bN3, bSM3, fun=fun1,filename="bN3v2", format="EHdr",
>>>> NAflag=0)
>>>
>>> Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",
>>>  :
>>>  file: /home/alobo/EHdr does not exist
>>> Calls: overlay ... raster ->  raster ->  .local ->  .rasterObjectFromFile
>>>
>>>> bN3v2<- overlay(bN3, bSM3, fun=fun1,filename="bN3v2",overwrite=TRUE,
>>>> format="EHdr", NAflag=0)
>>>
>>> Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",
>>>  :
>>>  file: /home/alobo/EHdr does not exist
>>> Calls: overlay ... raster ->  raster ->  .local ->  .rasterObjectFromFile
>>>
>>>> bN3v2<- overlay(bN3, bSM3, fun=fun1,filename="bN3v2", NAflag=0,
>>>> format="GTiff")
>>>
>>> Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",
>>>  :
>>>  file: /home/alobo/GTiff does not exist
>>> Calls: overlay ... raster ->  raster ->  .local ->  .rasterObjectFromFile
>>>
>>>
>>>
>>>> sessionInfo()
>>>
>>> R version 2.12.0 (2010-10-15)
>>> Platform: i486-pc-linux-gnu (32-bit)
>>>
>>> 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=en_US.UTF-8
>>> LC_ADDRESS=en_US.UTF-8
>>> [10] LC_TELEPHONE=en_US.UTF-8      LC_MEASUREMENT=en_US.UTF-8
>>> LC_IDENTIFICATION=en_US.UTF-8
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>> other attached packages:
>>> [1] rgdal_0.6-27  raster_1.6-22 sp_0.9-72     rkward_0.5.4
>>>
>>> loaded via a namespace (and not attached):
>>> [1] grid_2.12.0     lattice_0.19-13 tools_2.12.0
>>>
>>>
>>>
>>> Agus
>>> --
>>> Dr. Agustin Lobo
>>> Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
>>> LLuis Sole Sabaris s/n
>>> 08028 Barcelona
>>> Spain
>>> Tel. 34 934095410
>>> Fax. 34 934110012
>>> email: Agustin.Lobo at ija.csic.es
>>> http://www.ija.csic.es/gt/obster
>>>



More information about the R-sig-Geo mailing list