[GRASS-dev] r.resample.interp also does not behave according to manual

Clarification, I’m using a recent build of trunk/GRASS 7.1

I only want to resample part of a large DEM. I have the region set to the appropriate bounds and resolution. And I also have MASK turned on for the area to be resampled. Here is an excerpt from the r.resample.interp manual…

"Resampling modules (r.resample, r.resamp.stats, r.resamp.interp, r.resamp.rst) resample the map to match the current region settings.

Note that for bilinear, bicubic and lanczos interpolation, cells of the output raster that cannot be bounded by the appropriate number of input cell centers are set to NULL (NULL propagation). This could occur due to the input cells being outside the current region, being NULL or MASKed. “

But it give me an error and fails because a line of my input map is outside the current region. In fact, most of my input map is outside the current region.

Is this a bug or an error in the manual?

Michael


C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Head, Graduate Faculty in Complex Adaptive Systems Science
Arizona State University

voice: 480-965-6262 (SHESC), 480-965-8130/727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)

www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Sun, Aug 30, 2015 at 4:22 AM, Michael Barton <Michael.Barton@asu.edu> wrote:

Clarification, I'm using a recent build of trunk/GRASS 7.1

I only want to resample part of a large DEM. I have the region set to the
appropriate bounds and resolution. And I also have MASK turned on for the
area to be resampled. Here is an excerpt from the r.resample.interp manual…

...

But it give me an error and fails because a line of my input map is outside
the current region. In fact, most of my input map is outside the current
region.

Can you please provide a NC dataset example?

thanks
Markus

So I tried it with the North Carolina demo data and it seemed to go fine

g.region raster=elev_lid792_1m@PERMANENT
r.resamp.interp input=elevation@PERMANENT output=elevation1m method=lanczos

I went back and did the same thing with my data from the Near East and it raised an error. I made the raster map ziqlab_region_resamp30m using r.resample.bspline from a 90m SRTM map of the region. I originally set the region in the display and then set the resolution manually to 30m. In the test here, I used the successfully resampled map to set the region, just like I did with the NC data. You can see a section of the original 90m DEM and the region of this resampled map here:

g.region raster=ziqlab_region_resamp30m
r.resamp.interp --overwrite input=Mediterranean_east_SRTM90m@PERMANENT output=ziqlab_region_resamp30m_test method=lanczos

ERROR: Reading raster map <Mediterranean_east_SRTM90m@PERMANENT> request for row 1216 is outside region

The region does not go into any of the null value areas of the original 90m map, though it shouldn’t really matter if it does. They should just be ignored as nulls. My location is a Lambert Conformal Conic, which is not a lot different from the State Plane of the NC data.

This error doesn’t make sense. So I wonder if it is sort of bogus for some other problem that it not obvious. Any thoughts?

Michael

____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Head, Graduate Faculty in Complex Adaptive Systems Science
Arizona State University

voice: 480-965-6262 (SHESC), 480-965-8130/727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Aug 30, 2015, at 11:49 AM, Markus Neteler <neteler@osgeo.org> wrote:

On Sun, Aug 30, 2015 at 4:22 AM, Michael Barton <Michael.Barton@asu.edu> wrote:

Clarification, I'm using a recent build of trunk/GRASS 7.1

I only want to resample part of a large DEM. I have the region set to the
appropriate bounds and resolution. And I also have MASK turned on for the
area to be resampled. Here is an excerpt from the r.resample.interp manual…

...

But it give me an error and fails because a line of my input map is outside
the current region. In fact, most of my input map is outside the current
region.

Can you please provide a NC dataset example?

thanks
Markus

Michael Barton wrote:

g.region raster=ziqlab_region_resamp30m
r.resamp.interp --overwrite input=Mediterranean_east_SRTM90m@PERMANENT output=ziqlab_region_resamp30m_test method=lanczos

ERROR: Reading raster map <Mediterranean_east_SRTM90m@PERMANENT>
request for row 1216 is outside region

1. Does it happen with a method other than lanczos?

2. Does the following change fix it?

--- raster/r.resamp.interp/main.c (revision 66085)
+++ raster/r.resamp.interp/main.c (working copy)
@@ -111,11 +111,11 @@
   double north = Rast_row_to_northing(0.5, &dst_w);
   double south = Rast_row_to_northing(dst_w.rows - 0.5, &dst_w);
   int r0 = (int)floor(Rast_northing_to_row(north, &src_w) - 0.5) - 2;
- int r1 = (int)floor(Rast_northing_to_row(south, &src_w) - 0.5) + 3;
+ int r1 = (int)floor(Rast_northing_to_row(south, &src_w) - 0.5) + 4;
   double west = Rast_col_to_easting(0.5, &dst_w);
   double east = Rast_col_to_easting(dst_w.cols - 0.5, &dst_w);
   int c0 = (int)floor(Rast_easting_to_col(west, &src_w) - 0.5) - 2;
- int c1 = (int)floor(Rast_easting_to_col(east, &src_w) - 0.5) + 3;
+ int c1 = (int)floor(Rast_easting_to_col(east, &src_w) - 0.5) + 4;

   src_w.south -= src_w.ns_res * (r1 - src_w.rows);
   src_w.north += src_w.ns_res * (-r0);

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