[GRASS-user] ascii to dem

Hi,

I have imported into GRASS an ascii file (bathymetry) like this:

r.in.ascii in=/home/toni/tmp/38n34n9w2w/baty2.xyz out=bati

north: 38
south: 34
east: -2
west: -9
rows: 241
cols: 421
-9 38 -137
-8.98333 38 -127
-8.96667 38 -119
-8.95 38 -112
-8.93333 38 -101
-8.91667 38 -81
-8.9 38 -63
-8.88333 38 -45
-8.86667 38 1
-8.85 38 8

How do I transform it into a 'typical' dem map. It's to say a continous-aspect dem map not a dotted-aspect one?

TIA

Antonio

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14/03/07 10:47, antonio rodriguez wrote:

Hi,

I have imported into GRASS an ascii file (bathymetry) like this:

r.in.ascii in=/home/toni/tmp/38n34n9w2w/baty2.xyz out=bati

north: 38
south: 34
east: -2
west: -9
rows: 241
cols: 421
-9 38 -137
-8.98333 38 -127
-8.96667 38 -119
-8.95 38 -112
-8.93333 38 -101
-8.91667 38 -81
-8.9 38 -63
-8.88333 38 -45
-8.86667 38 1
-8.85 38 8

How do I transform it into a 'typical' dem map. It's to say a
continous-aspect dem map not a dotted-aspect one?

r.to.vect & v.surf.*

or

v.in.ascii & v.surf.*

?

Moritz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF+AN/MiPFf/8qzFYRApPMAKCV8FC2A1KTp1cRt/mNen7UHW1xzwCcCYzW
r6KN5nM3nF3lvRi9NTikapo=
=v0fk
-----END PGP SIGNATURE-----

antonio rodriguez wrote:

I have imported into GRASS an ascii file (bathymetry) like this:

r.in.ascii in=/home/toni/tmp/38n34n9w2w/baty2.xyz out=bati

north: 38
south: 34
east: -2
west: -9
rows: 241
cols: 421
-9 38 -137
-8.98333 38 -127
-8.96667 38 -119
-8.95 38 -112
-8.93333 38 -101
-8.91667 38 -81
-8.9 38 -63
-8.88333 38 -45
-8.86667 38 1
-8.85 38 8

How do I transform it into a 'typical' dem map. It's to say a
continous-aspect dem map not a dotted-aspect one?

That looks like x,y,z data, not a 2D ASCII array. r.in.ascii wants a 2D
array of z values, x,y are calculated from header. (see the example in
the help page)

Use r.in.xyz to import your data after crafting g.region settings by hand.

Hamish

Hamish escribió:

antonio rodriguez wrote:
  

I have imported into GRASS an ascii file (bathymetry) like this:

r.in.ascii in=/home/toni/tmp/38n34n9w2w/baty2.xyz out=bati

north: 38
south: 34
east: -2
west: -9
rows: 241
cols: 421
-9 38 -137
-8.98333 38 -127
-8.96667 38 -119
-8.95 38 -112
-8.93333 38 -101
-8.91667 38 -81
-8.9 38 -63
-8.88333 38 -45
-8.86667 38 1
-8.85 38 8

How do I transform it into a 'typical' dem map. It's to say a continous-aspect dem map not a dotted-aspect one?
    
That looks like x,y,z data, not a 2D ASCII array. r.in.ascii wants a 2D
array of z values, x,y are calculated from header. (see the example in
the help page)

Use r.in.xyz to import your data after crafting g.region settings by hand.
  

Hi Hamish,

I understand the issue of using r.in.xyz but I'm having problems with the import:

r.in.xyz z=3 fs='space' input=baty2.xyz out=baty

Scanning data ...
ERROR:Not enough data columns. Incorrect delimiter or column number? Found
      the following character(s) in row 1:
      [north: 38]

If I erase the header of baty2.xyz (the first six lines above):

r.in.xyz z=3 fs='space' input=baty2.xyz out=baty

Scanning data ...
ERROR:Not enough data columns. Incorrect delimiter or column number? Found
      the following character(s) in row 1:
      [-9 38 -137]

Don't know what I'm doing wrong since the 1st column holds the x's (longitude) values, the 2nd column, lat values, and 3rd column the z values (elevation +/-) The column delimiter is 'space'

Thanks,

Antonio

Hamish

antonio rodriguez wrote:

Hamish escribió:
> antonio rodriguez wrote:
>
>> I have imported into GRASS an ascii file (bathymetry) like this:
>>
>> r.in.ascii in=/home/toni/tmp/38n34n9w2w/baty2.xyz out=bati
>>
>> north: 38
>> south: 34
>> east: -2
>> west: -9
>> rows: 241
>> cols: 421
>> -9 38 -137
>> -8.98333 38 -127
>> -8.96667 38 -119
>> -8.95 38 -112
>> -8.93333 38 -101
>> -8.91667 38 -81
>> -8.9 38 -63
>> -8.88333 38 -45
>> -8.86667 38 1
>> -8.85 38 8
>>
>> How do I transform it into a 'typical' dem map. It's to say a
>> continous-aspect dem map not a dotted-aspect one?
>
> That looks like x,y,z data, not a 2D ASCII array. r.in.ascii wants a
> 2D array of z values, x,y are calculated from header. (see the
> example in the help page)
>
>
> Use r.in.xyz to import your data after crafting g.region settings by
> hand.
>
Hi Hamish,

I understand the issue of using r.in.xyz but I'm having problems with
the import:

r.in.xyz z=3 fs='space' input=baty2.xyz out=baty

Scanning data ...
ERROR:Not enough data columns. Incorrect delimiter or column number?
Found
      the following character(s) in row 1:
      [north: 38]

If I erase the header of baty2.xyz (the first six lines above):

Correct. You could also have commented them out with the hash (#) char:
# north:
# south:
...

r.in.xyz z=3 fs='space' input=baty2.xyz out=baty

Scanning data ...
ERROR:Not enough data columns. Incorrect delimiter or column number?
Found
      the following character(s) in row 1:
      [-9 38 -137]

Don't know what I'm doing wrong since the 1st column holds the x's
(longitude) values, the 2nd column, lat values, and 3rd column the z
values (elevation +/-) The column delimiter is 'space'

try fs=tab, or fs=space without the 'quotes' (if done from the GUI
window, from the command line 'quotes' shouldn't matter).
AndI think it is hoping for just one space,

this might help:

cat bathy2.xyz | awk '{print $1 $2 $3}' > bathy3.txt

?

Hamish

r.in.xyz z=3 fs='space' input=baty2.xyz out=baty

Scanning data ...
ERROR:Not enough data columns. Incorrect delimiter or column number?
Found
      the following character(s) in row 1:
      [-9 38 -137]

Don't know what I'm doing wrong since the 1st column holds the x's (longitude) values, the 2nd column, lat values, and 3rd column the z values (elevation +/-) The column delimiter is 'space'
    
try fs=tab, or fs=space without the 'quotes' (if done from the GUI
window, from the command line 'quotes' shouldn't matter).
AndI think it is hoping for just one space,

this might help:

cat bathy2.xyz | awk '{print $1 $2 $3}' > bathy3.txt

?

Hamish
  
Thanks Hamish, it helps a lot. What a powerful tool is awk (if one knows how to use it :-[ )

The raster data is imported fine, but when trying to convert it to a vector file:

r.to.vect in=bati3 out=bati3

Extracting lines ...
update_list: crowded cell 8H (1,2)
ERROR:Raster map is not thinned properly.
      Please run r.thin.

I do that, but:

r.thin in=bati3 out=bati3_thin

File bati3 -- 241 rows X 421 columns
Bounding box: l = 2, r = 422, t = 2, b = 242
Pass number 1
Deleted 1320 pixels
Pass number 2
Deleted 1312 pixels
Pass number 3
Deleted 1304 pixels
Pass number 4
Deleted 1296 pixels

At the end of the process almost all the data were erased. What is r.thin finding so wrong in my data that it deletes almost everything?

Cheers,

Antonio

antonio rodriguez wrote:

The raster data is imported fine, but when trying to convert it to a
vector file:

r.to.vect in=bati3 out=bati3

Extracting lines ...
update_list: crowded cell 8H (1,2)
ERROR:Raster map is not thinned properly.
      Please run r.thin.

I do that, but:

r.thin in=bati3 out=bati3_thin

File bati3 -- 241 rows X 421 columns
Bounding box: l = 2, r = 422, t = 2, b = 242
Pass number 1
Deleted 1320 pixels
Pass number 2
Deleted 1312 pixels
Pass number 3
Deleted 1304 pixels
Pass number 4
Deleted 1296 pixels

At the end of the process almost all the data were erased. What is
r.thin finding so wrong in my data that it deletes almost everything?

r.thin is appropriate if your raster data consists of lines, e.g. a
scanned contour map. It thins the lines so that they are only one cell
wide.

If you are trying to convert filled areas to vector areas, don't use
r.thin. You also need to pass feature=area to r.to.vect.

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