[Gdal-dev] Cutting non-square image into square subimages
Frank Warmerdam
fwarmerdam at gmail.com
Thu May 12 00:27:09 EDT 2005
On 5/11/05, Ilya Serebrianik <predator2448 at hotmail.com> wrote:
>
> Hello,
>
> I have an image that is not square due to projection into lat/long. I
> need to cut that image into square tiles without changing the resolution.
> For example if I specify a certain width of tile that fits exactly accross
> the width of the parent non-rectangular image it will obviously not fit
> along the height of the image, there will be some region of the last tile
> row that would be outside the parent image boundary. I would like to know
> whether there is a relatively simple way to fill these last row tiles with
> the remaining data from the parent image and therest of those tiles with
> black color (same as no data value?). I would rather not get into the low
> level image i/o such as RasterIO due to time limits and utilize code from
> the already written utilities. If anyone can suggest another way of cutting
> a non-square image into square images with the same resolution I would
> really like to know about it :-).
Ilya,
At the commandline you could just construct appropriate output file
bounds for each tile with gdalwarp. All areas outside the available source
data will be set to zero.
At the API level you can use RasterIO() to fill just part of a buffer with
appropriate setting of the buffersize, and pixel and line offset values, but
that can be pretty tedious to setup properly.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list