[Qgis-user] Info: how get raster extent (xmin, xmax, ymin and ymax)

Matt Wilkie maphew at gmail.com
Mon Jun 15 14:34:36 PDT 2015


Hi Filippo,

    raster = gdal.Open(src_raster)
    georef = raster.GetGeoTransform()
    xmin, ymax = georef[0], georef[3]

Will work for a regular north-to-top image. More details at
http://www.gdal.org/gdal_tutorial.html under "Getting Dataset Information"
heading.

If you need to get extent of data, e.g. strip the nodata collar, have a
look at
http://gis.stackexchange.com/questions/45159/finding-minimum-bounding-extent-of-given-pixel-value-within-raster/
.

cheers,

Matt


On Mon, Jun 15, 2015 at 7:26 AM, Filippo Gualla <filippog16 at gmail.com>
wrote:

> Hi everybody,
> a quich question: I have a raster and I want to get the extent (xmin,
> xmax, ymin and ymax). I expected to find something like
> "gdal.GetExtent()"... I donĀ“t think I have to run through all the
> coordinates with a loop...
> Regards,
> Filippo
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150615/ca203780/attachment.html>


More information about the Qgis-user mailing list