[gdal-dev] Question about using crop_to_cutline

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Fri Oct 26 02:05:06 PDT 2012


Even Rouault <even.rouault <at> mines-paris.org> writes:


> This is the very same topic that is discussed in 
> http://trac.osgeo.org/gdal/ticket/3947 . There's no solution to your problem, 
> but some background discussion that explains the current behaviour.

This is close to a problem I had once with creating mosaics from individually
warped orthophotos. Accurately calculated extents make pixels to slide a bit and
individually warped images do not share any common canvas for their pixels. I
sketched a plan for forcing the warped image to use a common canvas and found a
python guy to make a program. I have been satisfied with the result.

I believe that the same solution will work for you. You must widen the -te
parameters that is calculated by crop_to_cutline to each direction so that they
match exactly with some pixel row and line of the original image. See figures 3,
4, and 5 in http://www.scangis.org/scangis2007/papers/r3_rahkonen.pdf. The
python code is there too. Without understanding anything about programming I
suppose that the job is done with this:

minmax = get_minmax(tm32_coords)
	minmax_wider = [
		(int(math.floor(minmax[0][0])), int(math.floor(minmax[0][1]))),
		(int(math.ceil (minmax[1][0])), int(math.ceil (minmax[1][1]))),
	]

	log("Extents (min,max): " + str(minmax), outfilename)
	log("Widened extents (min,max): " + str(minmax_wider), outfilename)

-Jukka Rahkonen-



More information about the gdal-dev mailing list