[GRASS-user] interpolating data points

Hi all,

I have a bunch of data points on a 2 degree lat/lon grid.
I want to interpolate that and extract data on a 0.5 degree
lat/lon grid.

What I've done is:

1. v.in.ascii to load a vector map of points at 2 degree interval

2. create a temp file holding '$lat $lon 0.0' lines for each
   0.5 degree point I want to extract

3. v.in.ascii to load temp file of 0.5 degree grid

4. g.region to 2 degree data extents with res="00:20"

5. v.surf.idw to create raster from 2 degree grid

6. v.what.rast to fill 0.5 degree grid from raster

7. v.to.db and v.db.select to dump 0.5 degree grid to stdout

This, as you can imagine, is slow to execute. Am I missing
a much faster way to do this?

--
Paul Pick <paul.pick@ec.gc.ca>
Informatics Services Unit Gagetown
Chief Information Officer Branch, Environment Canada
[CSN] 432 2082 [CIV] 506 422 2000 x 2082 [FAX] 506 422 1443

On 28-Nov-06, at 12:51 PM, Paul Pick wrote:

2. Set region bounds such that the bounds are on 0.25 degree interval
with 0.5 degree resolution. That should put the pixel centers on the
1/2 degree interval that your looking for.

I'm not sure what you mean by interval vs resolution. I use
'g.region -a vect=v_interp_data res="00:20"' to set a 20
second resolution (as I think a 20 second res will put the
pixel centres at 0.5 degrees). How would you propose that
I modify that?

You'll want the boundary on the quarter second interval and the resolution set to 1/2 second interval. IE, something like this;

GRASS 6.2.0 (newLocation):~ > g.region n=50:15:00N s=49:15:00N e=110:15:00W w=111:45:00W nsres=00:30:00 ewres=00:30:00
GRASS 6.2.0 (newLocation):~ > g.region -p
  projection: 3 (Latitude-Longitude)
  zone: 0
  datum: towgs84=0,0,0,0,0,0,0
  ellipsoid: a=6378137 es=0.006694380022900787
  north: 50:15N
  south: 49:15N
  west: 111:45W
  east: 110:15W
  nsres: 0:30
  ewres: 0:30
  rows: 2
  cols: 3
  cells: 6

This grid will have it's pixel centers on the 30min interval.

3. v.surf.* to interpolate your grid.

This is where the process spends the vast majority of its
time. Perhaps your 'interval 0.25, resolution 0.5' can speed
this along.

Yes, interpolation is always a intensive task and from what I remember of my exeriences in GRASS, r.surf.idw is one of the faster modules. Alternately, you might want to try r.surf.nnbathy script that is in the addon section of the wiki pages. I think it uses Shewchuk's triangle algorithm, and if it's anything like GMT's implementation, it is very very fast. However, I have never used so I can't say for sure.

4. r.out.xyz to export each pixel to a xyz ascii triplet.

Ah, I didn't know r.out.xyz existed (I'm using 6.2 and
it appears to be present only in 6.3). That looks like
it would simplify my script quite a bit. Unfortunately,
it would not necessarily decrease the execution time.

Ah... didn't realize that either. If you have GMT you can accomplish the same thing in two steps using triangulate (or surface but triangulate is 10x faster with Shewchuk's library) and grd2xyz.

triangulate samples.xyz −R-114/-110/49/60 −I30m −Gfoobar.grd > /dev/null
grd2xyz foobar.grd > interplolated.xyz

Note that GMT is grid line registed rather than pixel center registered. Also, you'll have to play with your gmt settings to get the proper output format.

Cheers,

Mike

Thanks,
- Paul

--
Paul Pick <paul.pick@ec.gc.ca>
Informatics Services Unit Gagetown
Chief Information Officer Branch, Environment Canada
[CSN] 432 2082 [CIV] 506 422 2000 x 2082 [FAX] 506 422 1443

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection aroundhttp://mail.yahoo.com

Michael Perdue wrote:

GRASS 6.2.0 (newLocation):~ > g.region n=50:15:00N s=49:15:00N \
  e=110:15:00W w=111:45:00W nsres=00:30:00 ewres=00:30:00

tip:

for lat/lon positions, you can often leave off trailing ":00"

e.g. for 45S lat:
-45.000, 45S, 45:00S, 45:00:00S, and 45:00:00.000S should all work.

in GRASS 6.2+ decimal minutes should work too. (45:00.000S)

might save you a few keystrokes or conversion steps.

Hamish