NULL values and readRAST6

8 messages Options
Embed this post
Permalink
Carlos Grohmann-2

NULL values and readRAST6

Reply Threaded More More options
Print post
Permalink
Hi,
Can readRAST6 handle NULL values? How?

I tried NODATA=NULL but it needs a numeric value..

tks

Carlos

--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
Linux User #89721  - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

Can't stop the signal.

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Roger Bivand

Re: NULL values and readRAST6

Reply Threaded More More options
Print post
Permalink
On Tue, 9 Oct 2007, Carlos "Guâno" Grohmann wrote:

> Hi,
> Can readRAST6 handle NULL values? How?
>
> I tried NODATA=NULL but it needs a numeric value..

This is passed to r.out.bin, which says:

null=integer
     Value to write out for null
     Default: 0

so in fact it has to be an integer - I'll fix the documentation and
function (which didn't check what value was assigned to NODATA).

Roger

>
> tks
>
> Carlos
>
>

--
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: [hidden email]

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway
Roger Bivand

Re: NULL values and readRAST6

Reply Threaded More More options
Print post
Permalink
On Tue, 9 Oct 2007, Roger Bivand wrote:

> On Tue, 9 Oct 2007, Carlos "Guâno" Grohmann wrote:
>
>>  Hi,
>>  Can readRAST6 handle NULL values? How?
>>
>>  I tried NODATA=NULL but it needs a numeric value..
>
> This is passed to r.out.bin, which says:
>
> null=integer
>     Value to write out for null
>     Default: 0
>
> so in fact it has to be an integer - I'll fix the documentation and function
> (which didn't check what value was assigned to NODATA).
To make this a bit clearer - the raster layer in GRASS has missing values
set to NULL, but NULL cannot be exported by r.out.bin. So r.out.bin is
given a NODATA value to assign to NULL cells, which are then read into R,
and the NODATA valued cells are set to NA. The only need for the value is
to keep r.out.bin (and r.in.bin) happy, because they do not encode NULL
directly.

Roger

>
> Roger
>
>>
>>  tks
>>
>>  Carlos
>>
>>
>
>
--
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: [hidden email]

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway
Markus Neteler-3

Re: NULL values and readRAST6

Reply Threaded More More options
Print post
Permalink
Roger Bivand wrote:
On Tue, 9 Oct 2007, Roger Bivand wrote:
> On Tue, 9 Oct 2007, Carlos "Guâno" Grohmann wrote:
>
>>  Hi,
>>  Can readRAST6 handle NULL values? How?
>>
>>  I tried NODATA=NULL but it needs a numeric value..
>
> This is passed to r.out.bin, which says:
>
> null=integer
>     Value to write out for null
>     Default: 0
>
> so in fact it has to be an integer - I'll fix the documentation and function
> (which didn't check what value was assigned to NODATA).

To make this a bit clearer - the raster layer in GRASS has missing values
set to NULL, but NULL cannot be exported by r.out.bin. So r.out.bin is
given a NODATA value to assign to NULL cells, which are then read into R,
and the NODATA valued cells are set to NA. The only need for the value is
to keep r.out.bin (and r.in.bin) happy, because they do not encode NULL
directly.

Roger
Could this be automated by using
r.info -r map
to get the range and then auto-use a value outside
of this range as NULL encoder and something in R with
min()/max() to do the same in the other direction?

But maybe I misunderstand the problem.

Markus
Roger Bivand

Re: NULL values and readRAST6

Reply Threaded More More options
Print post
Permalink
On Tue, 9 Oct 2007, Markus Neteler wrote:

>
>
> Roger Bivand wrote:
>>
>> On Tue, 9 Oct 2007, Roger Bivand wrote:
>>> On Tue, 9 Oct 2007, Carlos "Guâno" Grohmann wrote:
>>>
>>>>  Hi,
>>>>  Can readRAST6 handle NULL values? How?
>>>>
>>>>  I tried NODATA=NULL but it needs a numeric value..
>>>
>>> This is passed to r.out.bin, which says:
>>>
>>> null=integer
>>>     Value to write out for null
>>>     Default: 0
>>>
>>> so in fact it has to be an integer - I'll fix the documentation and
>>> function
>>> (which didn't check what value was assigned to NODATA).
>>
>> To make this a bit clearer - the raster layer in GRASS has missing values
>> set to NULL, but NULL cannot be exported by r.out.bin. So r.out.bin is
>> given a NODATA value to assign to NULL cells, which are then read into R,
>> and the NODATA valued cells are set to NA. The only need for the value is
>> to keep r.out.bin (and r.in.bin) happy, because they do not encode NULL
>> directly.
>>
>> Roger
>>
>
> Could this be automated by using
> r.info -r map
> to get the range and then auto-use a value outside
> of this range as NULL encoder and something in R with
> min()/max() to do the same in the other direction?
Yes, I think that it could, I'll take a look - thanks!

Roger

>
> But maybe I misunderstand the problem.
>
> Markus
>

--
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: [hidden email]

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway
HamishB

Re: NULL values and readRAST6

Reply Threaded More More options
Print post
Permalink
Roger Bivand wrote:
> To make this a bit clearer - the raster layer in GRASS has missing values
> set to NULL, but NULL cannot be exported by r.out.bin. So r.out.bin is
> given a NODATA value to assign to NULL cells, which are then read into R,
> and the NODATA valued cells are set to NA. The only need for the value is
> to keep r.out.bin (and r.in.bin) happy, because they do not encode NULL
> directly.


IIUC there is a rgdal pacakge. Why not use it to directly read the GRASS map?
If GDAL's GRASS plugin is not present or the rgdal package is not loaded in R
it can fall back to using the r.{in|out}.bin or r.{in|out}.ascii methods.

(given the r.out.bin NULL restriction, maybe the r.out.ascii format is safer,
albeit a bit slower)

?,
Hamish



      ____________________________________________________________________________________
Don't let your dream ride pass you by. Make it a reality with Yahoo! Autos.
http://autos.yahoo.com/index.html
 


_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Roger Bivand

Re: NULL values and readRAST6

Reply Threaded More More options
Print post
Permalink
On Tue, 9 Oct 2007, Hamish wrote:

> Roger Bivand wrote:
>> To make this a bit clearer - the raster layer in GRASS has missing values
>> set to NULL, but NULL cannot be exported by r.out.bin. So r.out.bin is
>> given a NODATA value to assign to NULL cells, which are then read into R,
>> and the NODATA valued cells are set to NA. The only need for the value is
>> to keep r.out.bin (and r.in.bin) happy, because they do not encode NULL
>> directly.
>
>
> IIUC there is a rgdal pacakge. Why not use it to directly read the GRASS map?
> If GDAL's GRASS plugin is not present or the rgdal package is not loaded in R
> it can fall back to using the r.{in|out}.bin or r.{in|out}.ascii methods.
>
> (given the r.out.bin NULL restriction, maybe the r.out.ascii format is safer,
> albeit a bit slower)

Because GRASS 6.2 is still the scripted r.out.gdal, using the plugin,
*and* the plugin does not (correct me?) use the current region, but uses
the raster map in its "native" form, so doing an r.out.gdal -> tempfile ->
readGDAL() risks getting different regions etc. Getting the plugin working
properly across platforms is less than convenient too. This is a
showstopper when reading multiple rasters into a single
SpatialGridDataFrame.

With GRASS 6.3 this goes away, because r.out.gdal is compiled and does
respect the current region (like r.out.bin does).

As the interface needs to support both GRASS < 6.3 and >= 6.3, using
r.*.bin is simpler. A bit lame, but the GRASS 5 interface is still
supported for users who are still there.

Roger

>
> ?,
> Hamish
>
>
>
>      ____________________________________________________________________________________
> Don't let your dream ride pass you by. Make it a reality with Yahoo! Autos.
> http://autos.yahoo.com/index.html
>
>
>

--
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: [hidden email]

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway
Maciej Sieczka - old

Re: NULL values and readRAST6

Reply Threaded More More options
Print post
Permalink
Roger Bivand wrote:

> With GRASS 6.3 this goes away, because r.out.gdal is compiled and does
> respect the current region

Note it fails to export NULL values properly [1]. Hopefully
to be fixed before GRASS 6.3 release.

[1]http://wald.intevation.org/tracker/?func=detail&atid=204&aid=405&group_id=21

Maciek

_______________________________________________
statsgrass mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/statsgrass