[R-sig-Geo] writeRaster issue
Guillermo E. Ponce-Campos
geponce at gmail.com
Wed Apr 23 07:39:16 CEST 2014
Thanks Andrew...
Here is the raster layer object I can save as geoTif on Windows XP and
7 but not in Centos...
https://www.dropbox.com/s/t8rqkvwqnam3imm/rasterLayer.RData
As you can see, in the Centos box I have a newer version for the rgdal
and raster packages.
Thanks,
Guillermo
On Tue, Apr 22, 2014 at 9:07 PM, Andrew Vitale <vitale232 at gmail.com> wrote:
> Hey Guillermo,
>
> All I can add is that I'm unable to reproduce this on my Lubutu 14.04
> laptop.
>
> Perhaps you should try updating R and your packages?
>
>
> ## The following code plots as expected:
>
> setwd("~/Desktop")
> library(raster)
>
> r <- raster()
> r[] <- 1:ncell(r) * 0.001
> plot(r)
>
> r2 <- writeRaster(r, "testGeoTif", format="GTiff", overwrite=TRUE)
> plot(r2)
>
> r3 <- raster("testGeoTif.tif")
> plot(r3)
>
>
>> sessionInfo()
> R version 3.1.0 (2014-04-10)
> Platform: i686-pc-linux-gnu (32-bit)
>
> locale:
> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
> [9] LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] rgdal_0.8-16 raster_2.2-31 sp_1.0-15
>
> loaded via a namespace (and not attached):
> [1] grid_3.1.0 lattice_0.20-29
>
>
>
> On Tue, Apr 22, 2014 at 11:09 AM, Guillermo E. Ponce-Campos
> <geponce at gmail.com> wrote:
>>
>> Hi:
>>
>> Is there any known issue on using writeRaster under Windows vs Linux?
>>
>> I have been trying to write a rasterlayer as a geotif in a Linux
>> (centos) machine with no success...
>>
>> I have this raster layer:
>>
>> > varTmpRaster
>> class : RasterLayer
>> dimensions : 720, 1440, 1036800 (nrow, ncol, ncell)
>> resolution : 0.25, 0.25 (x, y)
>> extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
>> coord. ref. : +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84
>> +no_defs +towgs84=0,0,0
>> data source : in memory
>> names : layer
>> values : 0, 0.9132664 (min, max)
>>
>> >plot(varTmpRaster)
>> It shows everything right...
>>
>> When I run the writeRaster the resulting file only have NA's:
>>
>> >tf <- writeRaster(varTmpRaster, "testGeoTif", format="GTiff",
>> > overwrite=TRUE)
>> >plot(tf)
>> Just blank plot...
>>
>> >length(tf)
>> [1]1036800
>> >length(tf[is.na[tf])
>> [1] 1036800
>>
>>
>> If I run the exact same instructions on R for Windows7 and everything
>> goes fine, both plots, the one from varTmpRaster and the tf show
>> exactly the same map...
>>
>> Here are the characteristics from both machines...
>>
>> Linux-Centos:
>> ---------------
>> R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
>> rgdal: version: 0.8-16, (SVN revision 498)
>> Geospatial Data Abstraction Library extensions to R successfully loaded
>> Loaded GDAL runtime: GDAL 1.10.1, released 2013/08/26
>> Path to GDAL shared files: /usr/local/share/gdal
>> Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
>> Path to PROJ.4 shared files: /opt/source/proj-4.8.0/nad
>>
>> Windows 7:
>> ----------------
>> R version 3.0.1 (2013-05-16) -- "Good Sport"
>> Loading required package: sp
>> rgdal: version: 0.8-11, (SVN revision 479M)
>> Geospatial Data Abstraction Library extensions to R successfully loaded
>> Loaded GDAL runtime: GDAL 1.9.2, released 2012/10/08
>> Path to GDAL shared files: C:/Program Files/R/R-3.0.1/library/rgdal/gdal
>> GDAL does not use iconv for recoding strings.
>> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470]
>> Path to PROJ.4 shared files: C:/Program Files/R/R-3.0.1/library/rgdal/proj
>>
>> Does anyone has seen a thread commenting on an issue like this before ?
>>
>> I have tried the NAvalue() and also using the datatype FLT8S and FLT4S
>> as part of the parameters of the writeRaster but no luck.
>>
>>
>> Thanks,
>> Guillermo
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
>
> --
> Andrew P. Vitale
> Masters Student
> Department of Geography
> University of Nevada, Reno
> vitale232 at gmail.com
--
Guillermo E. Ponce-Campos
PGP Key ID: 0x57EDC060
Ph. (520) 261-8486
More information about the R-sig-Geo
mailing list