Hide
Meet people who work on similar things as you – get help if you need it Join Siafoo Now or Learn More

Find Extents of GIS Raster Data Atom Feed 0

In Brief Gets the extents (range of coordinates covered by the data) of any GDAL-compatible raster file and returns them as [minx, miny, maxx, maxy].
# 's
 1# Copyright 2007 Regents of the University of California
2# Written by David Isaacson at the University of California, Davis
3# BSD License
4
5import gdal, os
6from gdalconst import *
7
8def findGDALCoordinates(path):
9 if not os.path.isfile(path):
10 return []
11 data = gdal.Open(path,GA_ReadOnly)
12 if data is None:
13 return []
14 geoTransform = data.GetGeoTransform()
15 minx = geoTransform[0]
16 maxy = geoTransform[3]
17 maxx = minx + geoTransform[1]*data.RasterXSize
18 miny = maxy + geoTransform[5]*data.RasterYSize
19 return [minx,miny,maxx,maxy]

Gets the extents (range of coordinates covered by the data) of any GDAL-compatible raster file and returns them as [minx, miny, maxx, maxy].