[FWTools] How can I know what measurement units a raster's pixel is?

Susana Iraiis Delgado Rodriguez susana.delgado_s at utzmg.edu.mx
Fri Oct 22 13:53:14 EST 2010


I'm working in a python script to get the extent from a raster, I already
used GetGeoTransform() and found the x_min and y_max, and the pixels
measures. But I also need to get x_max and y_min. In order to do this I make
some calculus, but this function will only work if my pixel measures are in
meters, otherwise I must have to convert to meters. This is the script:

impot os
from osgeo import gdal
from osgeo.gdalconst import *

gdal.AllRegister()
dataset = gdal.Open(filepath, GA_ReadOnly)
geotransform = dataset.GetGeoTransform()
x_min=geotransform[0]
y_max=geotransform[3]
pixel_width=geotransform[1]
pixel_height=geotransform[5]

rows=dataset.RasterYSize
cols=dataset.RasterXSize

x_max = (cols*pixel_width) + x_min
y_min = y_max + (rows*pixel_height)

Does anyone know a better way to do it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20101022/e4051ff2/attachment.htm 


More information about the FWTools mailing list