[R-sig-Geo] spgrass6 : diferent values from original

Roger Bivand Roger.Bivand at nhh.no
Sun Mar 29 17:04:14 CEST 2009


On Sun, 29 Mar 2009, milton ruser wrote:

> Checking the result on the readRAST6, I noticed that
> the number of bytes are 2, and I need 4 bits to store
> values greather than 32565, I suppose.
> --------------
>> mapa <- readRAST6(varint, cat=FALSE)
> Creating BIL support files...
> Header File =
> C:/Data/Tibagi/vegPR_probio_proatlan_abr2009/tibagi_Probio_grass_sdb_apr2009/newLocation/PERMANENT/.tmp/uso_tibagi_fundo_soflor_ero30m_dila030m_mata_clump.hdr
> World File =
> C:/Data/Tibagi/vegPR_probio_proatlan_abr2009/tibagi_Probio_grass_sdb_apr2009/newLocation/PERMANENT/.tmp/uso_tibagi_fundo_soflor_ero30m_dila030m_mata_clump.wld
> Exporting raster as integer values (bytes=2)
> Using the current region settings...
> --------------------
> But how can I chance the number of bytes, if it is not an
> argument on readRAST6?

Thanks for including your sessionInfo() in the preceding mail. If you are 
still using 0.5-10, you have no choice but to cast the data to floating 
point using r.mapcalc (add 0.0 should do it). There have been many changes 
in readRAST6() since that version, for example to use a GRASS GDAL plugin 
if available, and to use GDAL to read and write GTiff temporary files. The 
older route using r.out.bin only offers 2-byte integers, so was a reason 
for making more formats available.

So the answer in general is to update sp, spgrass6 and rgdal if you can. 
Since you in addition on Windows, and probably using the Native Windows 
version, until a new release you will hit a snag that more recent GRASS 
r.out.gdal have a -c flag which is not in your release - here you can wait 
for the next release, and use the trick of casting to floating point until 
then.

Roger

> Best wishes
>
> miltinho
>
>
> On Sun, Mar 29, 2009 at 12:43 AM, milton ruser <milton.ruser at gmail.com>wrote:
>
>> Hi there,
>>
>> I have a set of maps on GRASS 6.5 and I need to compute some basic stats
>> on R 2.7.1. For some maps I get the desired results, but for other I am
>> getting different values. My raster are integer values >= 1 (with some NAs
>> where not mapped).
>>
>> I start R from GRASS session without problem, and can read the rasters
>> on R:
>>
>> require(spgrass6)
>> varint<-"uso_tibagi_fundo_soflor_ero30m_dila030m_mata_clump_AreaHA"
>> mapa <- readRAST6(varint, cat=FALSE)
>> mapa.valores<-mapa at data[1]
>> mapa.valores<-mapa.valores[!is.na(mapa.valores)]
>> quantile(mapa.valores, probs=c(0.20,0.40,0.60,0.80))
>> summary(mapa.valores)
>> rm(mapa, mapa.valores,varint)
>> But for one of my map I get different range of value between R and GRASS
>> ON GRASS - r.univar
>> n: 8336636
>> minimum: 1
>> maximum: 303396
>> range: 303395
>> mean: 125949
>>
>> ON R
>>> summary(mapa at data[1])
>>  uso_tibagi_fundo_soflor_dila030m_clump_mata_limpa_AreaHA
>>  Min.   :  -24284
>>  1st Qu.:  -24284
>>  Median :      31
>>  Mean   :   -6551
>>  3rd Qu.:    2225
>>  Max.   :   27846
>>  NA's   :59217475
>>
>> -----> sessionInfo()
>> R version 2.7.1 (2008-06-23)
>> i386-pc-mingw32
>> locale:
>>
>> LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>> other attached packages:
>> [1] spgrass6_0.5-10 rgdal_0.5-25    sp_0.9-26
>> loaded via a namespace (and not attached):
>> [1] grid_2.7.1     lattice_0.17-8
>> Any help are welcome.
>>
>> Regards
>>
>> miltinho
>> Toronto, CA
>>
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list