2011/2/8 Lefman, Jonathan ERDC-TEC-VA <[email protected]>: > Classification: UNCLASSIFIED > Caveats: NONE > > Thank you Jorge. That worked. :) > >
Good to hear it :-). Adapted from http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/python/raster2pgsql.py > > -----Original Message----- > From: Jorge Arévalo [mailto:[email protected]] > Sent: Tuesday, February 08, 2011 11:15 > To: Lefman, Jonathan ERDC-TEC-VA > Cc: [email protected] > Subject: Re: [gdal-dev] New to list and question (UNCLASSIFIED) > > Hi Jonathan, > > On Tue, Feb 8, 2011 at 4:46 PM, Lefman, Jonathan ERDC-TEC-VA > <[email protected]> wrote: >> Classification: UNCLASSIFIED >> >> Caveats: NONE >> >> Hi all, >> >> I joined this list today. I have a question about using Python >> bindings with GDAL to get info from a geotiff. >> >> What are the functions that I need to obtain coordinate extents of >> raster data? For example, if I have a rectangular area from >> Washington, DC with coordinates in UTM format, how would I determine >> the top-left and lower-right corners? I was unable to find an example in > the documentation. >> >> Here's a snippet of my code of where I'm at: >> >> from osgeo import gdal >> >> gdaldata = gdal.Open(gtiff_filename) >> >> prj = gdaldata.GetProjection() >> >> trfm = gdaldata.GetGeoTransform() >> >> Thanks everyone, >> >> Jon >> >> Classification: UNCLASSIFIED >> >> Caveats: NONE >> >> _______________________________________________ >> gdal-dev mailing list >> [email protected] >> http://lists.osgeo.org/mailman/listinfo/gdal-dev >> > > Test this: > > from osgeo import gdal > > def calculate_geoxy(gt, xy): > """Calculate georeferenced coordinate from given x and y""" > xgeo = gt[0] + gt[1] * xy[0] + gt[2] * xy[1]; > ygeo = gt[3] + gt[4] * xy[0] + gt[5] * xy[1]; > > return (xgeo, ygeo) > > ds = gdal.Open(gtiff_filename) > prj = ds.GetProjection() > gt = tuple(list(ds.GetGeoTransform())) > dim = ( > (0,0),(0,ds.RasterYSize),(ds.RasterXSize,0),(ds.RasterXSize,ds.RasterYSize) > ) > ext = (calculate_geoxy(gt, dim[0]), calculate_geoxy(gt, dim[1]), > calculate_geoxy(gt, dim[2]), calculate_geoxy(gt, dim[3])) > > > Best regards, > > -- > Jorge Arévalo > Internet & Mobilty Division, DEIMOS > [email protected] > http://es.linkedin.com/in/jorgearevalo80 > http://mobility.grupodeimos.com/ > http://www.twitter.com/jorgeas80 > http://gis4free.wordpress.com > http://geohash.org/ezjqgrgzz0g > > Classification: UNCLASSIFIED > Caveats: NONE > > > -- Jorge Arévalo Internet & Mobilty Division, DEIMOS [email protected] http://es.linkedin.com/in/jorgearevalo80 http://mobility.grupodeimos.com/ http://www.twitter.com/jorgeas80 http://gis4free.wordpress.com http://geohash.org/ezjqgrgzz0g _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
