[gdal-dev] Retrieving pixel corners through Python-gdal

Monica Buescu monicabuescu1985 at gmail.com
Wed Jun 30 08:22:44 EDT 2010


Hello Tom
Thanks. It also worked for me

Thanks
Monica

On Tue, Jun 29, 2010 at 3:01 PM, Kralidis,Tom [Ontario] <
Tom.Kralidis at ec.gc.ca> wrote:

>
>
> > -----Original Message-----
> > From: gdal-dev-bounces at lists.osgeo.org
> > [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Monica Buescu
> > Sent: Tuesday, 29 June 2010 09:49
> > To: gdal-dev at lists.osgeo.org
> > Subject: [gdal-dev] Retrieving pixel corners through Python-gdal
> >
> > Greetings
> >
> > I'm a kind of newbie in GDAL specially in Python-GDAL. I'm
> > doing a script to do some minor image processing but I need
> > to retrieve, in a Python Scrpt, coorners coordinates
> > (top-left; bottom-right). Is there any way to retrieve this
> > using gdalpython?
> >
> > Thanks
> >
> > Monica
> >
>
> This has worked for me:
>
> import osgeo.gdal as gdal
>
> ds = gdal.Open('foo.tif')
> gt = ds.GetGeoTransform()
> width = ds.RasterXSize
> height = ds.RasterYSize
> miny = gt[3] + width*gt[4] + height*gt[5]
> maxx = gt[0] + width*gt[1] + height*gt[2]
> # bbox of raster (minx, miny, maxx, maxy)
> bbox = (gt[0], miny, maxx, gt[3])
>
> ..Tom
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100630/1ff8ac9a/attachment.html


More information about the gdal-dev mailing list