[GRASS-user] importing GMT grids

any good advice on importing GMT grids? r.in.bin keeps complaining
about the file size, no matter what byte size I choose, and setting it
to get the header from the grid, makes it error on "east must be
larger than west". Exporting the grid to xyz (grd2xyz) and then
importing with r.in.xyz seems to work, but the resulting image is full
of artifacts (see attach). I tried to change the grid registration in
GMT (grdedit), and the boundaries too (in surface), giving it a
half-pixel difference, but all came in the same way.

If anyone wants to try, this is the xyz file:
http://www.igc.usp.br/pessoais/guano/temp/3arcsec.csv

and these are the commands I used:

nearneighbor 3arcsec.csv -R337575/351435/3855915/3872175 -I30/30 -S200
-V -Goutnear.grd
grdedit outnear.grd -T
grdinfo outnear.grd
grd2xyz outnear.grd --D_FORMAT=%f >near.xyz

and

surface 3arcsec.csv -R337575/351435/3855915/3872175 -I30/30 -T0.35 -V -Gout.grd

grdedit out.grd -T
grdinfo out.grd
grd2xyz out.grd --D_FORMAT=%f >spline.xyz

the commands above have the "half pixel displacement" I mentioned, for
this region:

projection: 1 (UTM)
zone: 11
datum: wgs84
ellipsoid: wgs84
north: 3872190
south: 3855900
west: 337560
east: 351450
nsres: 30
ewres: 30
rows: 543
cols: 463
cells: 251409

thanks

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.

(attachments)

import.jpg

I convert the NC file to an ESRI ASCII grid and then use r.in.arc to
import the data (you can write a script to do this).

MB System has a perl script that does the netCDF -> ASCII grid
conversion (using GMT behind the scenes) called MBM_GRD2ARC. I have
attached the script here so that you do not need to install all of MB
System to get the code. (It's GPL like GMT and GRASS).

This process should give you exactly the same grid in both GMT and
GRASS. (By the way, MB System has the reverse tool called MBM_ARC2GRD
as well)

David

On 9/17/07, Carlos Guâno Grohmann <carlos.grohmann@gmail.com> wrote:

any good advice on importing GMT grids? r.in.bin keeps complaining
about the file size, no matter what byte size I choose, and setting it
to get the header from the grid, makes it error on "east must be
larger than west". Exporting the grid to xyz (grd2xyz) and then
importing with r.in.xyz seems to work, but the resulting image is full
of artifacts (see attach). I tried to change the grid registration in
GMT (grdedit), and the boundaries too (in surface), giving it a
half-pixel difference, but all came in the same way.

If anyone wants to try, this is the xyz file:
http://www.igc.usp.br/pessoais/guano/temp/3arcsec.csv

and these are the commands I used:

nearneighbor 3arcsec.csv -R337575/351435/3855915/3872175 -I30/30 -S200
-V -Goutnear.grd
grdedit outnear.grd -T
grdinfo outnear.grd
grd2xyz outnear.grd --D_FORMAT=%f >near.xyz

and

surface 3arcsec.csv -R337575/351435/3855915/3872175 -I30/30 -T0.35 -V -Gout.grd

grdedit out.grd -T
grdinfo out.grd
grd2xyz out.grd --D_FORMAT=%f >spline.xyz

the commands above have the "half pixel displacement" I mentioned, for
this region:

projection: 1 (UTM)
zone: 11
datum: wgs84
ellipsoid: wgs84
north: 3872190
south: 3855900
west: 337560
east: 351450
nsres: 30
ewres: 30
rows: 543
cols: 463
cells: 251409

thanks

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.

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

--
David Finlayson, Ph.D.
Operational Geologist

U.S. Geological Survey
Pacific Science Center
400 Natural Bridges Drive
Santa Cruz, CA 95060, USA

Tel: 831-427-4757, Fax: 831-427-4748, E-mail: dfinlayson@usgs.gov

(attachments)

mbm_grd2arc (9.09 KB)

Carlos "Guâno" Grohmann wrote:

any good advice on importing GMT grids? r.in.bin keeps complaining
about the file size,

If it is binary grid format which GDAL calls as "EHdr", create a header
file (see r.in.srtm script for inspiration and format desrciption on
[1]) and r.in.gdal should be a able to import it.

Maciek

[1]http://www.gdal.org/frmt_various.html#EHdr