[GRASS-user] automated cropping of reprojected images

Richard Greenwood richard.greenwood at gmail.com
Thu Jul 13 17:14:13 EDT 2006


On 7/13/06, Trevor Wiens <twiens at interbaun.com> wrote:

> As Paulo mentioned I am talking about the big black regions around the
> landsat images. I can visually adjust the region, but with the volume
> of images I'm dealing with here, that isn't practical so I'm looking
> for a programmatic method. For example I tried to make a MASK and then
> set g.region rast=MASK, but the MASK includes all the nulls or zeros so
> the region size doesn't change. I also tried creating a copy of the
> file with r.mapcalc using the MASK hoping the end file would have a
> smaller region and then did g.region rast=<mask r.mapcalc output>, but
> the region size again didn't change. I want to set the region to an
> area that only has actual data, not nulls.
>
> Ideally, it would be nice to be able to determine this using gdal so I
> can crop the images with gdalwarp without having to import and export
> as the client wants to use these images to check the results of change
> analysis after being run between pairs of the original images in the
> UTM projection they were acquired in.

I have done this a couple times, unfortunately I can not find my
scripts. If my memory serves me, I've done it both in GRASS and with
gdal_translate. My approach was less than elegant, but I simply
subtracted a predefined amount from image extents. With gdal_translate
this would be done with -srcwin, or in GRASS simply by setting a new
region (r.region).

I had enough overlap between images that I did not need to be very
precise. So I reprojected a couple representative images and measured
how wide the no-data bands were after reprojection. I then used this
amount is a fixed cropping value in my scripts.

If you do not have enough overlap between images you could r.patch
them into a single, large image and then "write out" tiles from that
large patched image.

HTH,
Rich

-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com




More information about the grass-user mailing list