[GRASS-user] Problem after import using r.in.ascii

Glynn Clements glynn at gclements.plus.com
Wed Apr 28 16:42:47 EDT 2010


Hanlie Pretorius wrote:

> I have an existing CSV file that has the headers lat, long and precip.
> The precipitation is a floating point number to two decimal places.
> The coordinates in the CSV file define the centre of a quarter degree
> square. The first set of coordinates in the file is -19.625,15.875.
> 
> Becuase the TRMM data defines the centre of the square, I subtracted
> 0.125 from the first set of coordinates to get the north-west corner
> of the raster. And I added 0.125 to the last coordinate in the CSV
> file, which is -34.875,34.125, to get the south-east corner of the
> raster.

This seems wrong; positive-X is east, positive-Y is north, so you
should be adding to north and east, subtracting from south and west.

> In the CSV file, the latitude stays constant for 74 rows while the
> longitude increments in quarter degree steps. The whole file contains
> 4588 rows, so a grid of the data should have 74 rows and 62 columns,
> right?
> 
> So I reformatted the data to 74 rows and 62 columns and added the header:
> 
> north:	 -19.5
> south:	 -35.0

> east:	 15.75
> west:	 34.25

Positive-X is east, so either east and west are the wrong way around,
or they should both be negative, or this represents a span of 341.5
degrees.

> rows:	 74
> cols:	 62
> null:	 -319.99
> 
> 
> The output of g.region -p is:
> 
> projection: 3 (Latitude-Longitude)
> zone:       0
> datum:      wgs84
> ellipsoid:  wgs84
> north:      18S
> south:      36S

> west:       15E
> east:       35E

Here, east and west have been swapped relative to what you say above.

> nsres:      0:15
> ewres:      0:15
> rows:       72
> cols:       80
> cells:      5760
> 
> 
> I then imported the reformatted file using the command:
> 
> r.in.ascii -f input="3B42RT.2010032409.6.bin.sa.grass"\
> output="2010032409.6.precip" \
> title="Precipitation 2010032409.6"\
> mult=1.0 or read from header nv="* or read from header"
> 
> 
> When imported, I get two thin strips of data on the sides of the
> image. The raster shouldn't contain any nulls (the text file doesn't
> contain the value -319.99), so something is wrong.
> 
> r.info gives a very strange resolutions:
> 
> 
>  |   Type of Map:  raster               Number of Categories: 255
>  |   Data Type:    FCELL
>  |   Rows:         74
>  |   Columns:      62
>  |   Total Cells:  4588
>  |        Projection: Latitude-Longitude
>  |            N:     19:30S    S:        35S   Res: 0:12:34.054054
>  |            E:     15:45E    W:     34:15E   Res: 5:30:29.032258

The west edge is east of the east edge, resulting in a span of 341.5
degrees. 341.5 / 62 = 5.508064516129032 = 5:30:29.032258.

>  |   Range of data:    min = 0.000000  max = 7.470000
> 
> 
> Can someone perhaps help me to see what's happening here?

East and west are swapped.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list