Skip to main content
100%

Click on a raster layer in the QGIS table of contents, and then run this script. The corners of the bounding box of the layer will be printed to the console in the project's projection system. This is useful for supplying these values to Leaflet when using `imageOverlay`, which requires the top left and bottom right coordinates.

✓ Published0🌍 Public
Aalpha-beta-soup
Last edited May 10, 2015
Created on May 10, 2015

This script prints the geographic bounding-box corners of a raster layer to the QGIS console in the project’s projection system, converting them from pixel coordinates via the GDAL GeoTransform and reprojecting them using the OSR `CoordinateTransformation`. It reads the active layer’s source path with `gdal.Open`, extracts the raster dimensions and geotransform, and transforms each corner from the layer’s spatial reference to its geographic counterpart. The output provides the top-left and bottom-right coordinates needed for a Leaflet `imageOverlay`.

AI-generated description

Similar vizzes