concept real - world coordinate in category geoprocessing

appears as: real-world coordinates, real-world coordinates
Geoprocessing with Python

This is an excerpt from Manning's book Geoprocessing with Python.

9.3.1. Using real-world coordinates

Until now, we’ve only considered pixel offsets when deciding where to start reading or writing data, but most of the time you’ll have real-world coordinates instead. Fortunately, converting between the two is easy, as long as your coordinates use the same SRS as the raster. You saw earlier how to calculate coordinates of individual pixels, and now you need to reverse that process. All of the data required, including the origin coordinates, pixel sizes, and rotation values, are stored in the geotransform you’ve been copying between datasets. The geotransform is a tuple containing the six values shown in table 9.2. The rotation values are usually 0; in fact, I can’t recall ever using an image that wasn’t north up, but they’re certainly out there.

Table 9.2. GeoTransform items

Index

Description

0 Origin x coordinate
1 Pixel width
2 x pixel rotation (0° if image is north up)
3 Origin y coordinate
4 y pixel rotation (0° if image is north up)
5 Pixel height (negative)

You could use this information to apply the affine transformation yourself, but GDAL provides a function that does it for you, called ApplyGeoTransform, that takes a geotransform, an x value, and a y value. When used with a dataset’s geotransform, this function converts image coordinates (offsets) to real-world coordinates. But right now you’re interested in going the other direction, so you need to get the inverse of the dataset’s geotransform. Fortunately, a function exists for that, but you use it differently depending on the version of GDAL that you’re using. If you’re using GDAL 1.x, the InvGeoTransform function returns a success flag and a new geotransform that can be used to go the other direction: