[gdal-dev] Question about using crop_to_cutline
Marius Jigmond
mariusjigmond at hotmail.com
Fri Oct 26 05:34:12 PDT 2012
At the time I created the ticket I had created a workaround that uses gdal_translate to clip a rectangular window and gdal_rasterize to burn an inverse image of the vector. Interested folks can email me for the script (does the list take attachments?). The script makes some assumptions about your data type (e.g. 0 is assigned as nodata) but you can change those assumptions to suit your needs.
I plan to make the feature request I mentioned in #3947.
-marius
> To: gdal-dev at lists.osgeo.org
> From: jukka.rahkonen at mmmtike.fi
> Date: Fri, 26 Oct 2012 09:05:06 +0000
> Subject: Re: [gdal-dev] Question about using crop_to_cutline
>
> 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-
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20121026/4256bc94/attachment.html>
More information about the gdal-dev
mailing list