[gdal-dev] Area from gdalinfo metadata on a .tif image
Andrew C Aitchison
andrew at aitchison.me.uk
Thu Jul 26 07:23:57 PDT 2018
On Thu, 26 Jul 2018, Tyler Burse wrote:
> I hope you all have had a great week so far. I am hoping you will be able
> to provide some help because I have not been able to find a way to get the
> area from the metadata returned by gdalinfo. What I get as the return of
> gdalinfo appears to be a non-georeferenced figure such as:
>
> C:\Temp>gdalinfo figure1.tif
> Driver: GTiff/GeoTIFF
> Files: figure1.tif
> Size is 244, 210
> Coordinate System is `'
> Metadata:
> TIFFTAG_XRESOLUTION=96
> TIFFTAG_YRESOLUTION=96
> TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
> Image Structure Metadata:
> INTERLEAVE=PIXEL
> Corner Coordinates:
> Upper Left ( 0.0, 0.0)
> Lower Left ( 0.0, 210.0)
> Upper Right ( 244.0, 0.0)
> Lower Right ( 244.0, 210.0)
> Center ( 122.0, 105.0)
> Band 1 Block=244x11 Type=Byte, ColorInterp=Red
> Band 2 Block=244x11 Type=Byte, ColorInterp=Green
> Band 3 Block=244x11 Type=Byte, ColorInterp=Blue
>
>
> Would you be able to help me with finding the best way to extract the area
> in kilometers squared from this info using GDAL?
The output includes
Coordinate System is `'
so, formally, we do not know the relationship between the image and the
piece of the earth that it represents.
If the file specified the coordinate system,
then gdalinfo would report something like:
Coordinate System is:
PROJCS["OSGB 1936 / British National Grid",
GEOGCS["OSGB 1936",
DATUM["OSGB_1936",
SPHEROID["Airy 1830",6377563.396,299.3249646,
AUTHORITY["EPSG","7001"]],
TOWGS84[446.448,-125.157,542.06,0.15,0.247,0.842,-20.489],
AUTHORITY["EPSG","6277"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4277"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",49],
PARAMETER["central_meridian",-2],
PARAMETER["scale_factor",0.9996012717],
PARAMETER["false_easting",400000],
PARAMETER["false_northing",-100000],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["Easting",EAST],
AXIS["Northing",NORTH],
AUTHORITY["EPSG","27700"]]
Origin = (-649749.999999999883585,1449750.000000000465661)
Pixel Size = (500.000000000000000,-500.000000000000171)
Metadata:
...
Corner Coordinates:
Upper Left ( -649750.000, 1449750.000) ( 21d55'22.41"W, 61d27'54.60"N)
Lower Left ( -649750.000, -150250.000) ( 16d 0'12.44"W, 47d41'10.18"N)
Upper Right ( 1350250.000, 1449750.000) ( 16d 9' 2.77"E, 61d43'17.34"N)
Lower Right ( 1350250.000, -150250.000) ( 10d42'41.48"E, 47d50'21.53"N)
Note the lines:
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
- so this coordinate system and file is in metres (other commone coordinate systems use US feet or degrees as units).
This file represents a space on the ground which is
1320250 - -649750 = 2000000m = 2000km east to west, and
1449750 - -150250 = 1600000m = 1600km north to south,
so has an area of 3.2million km^2.
--
Andrew C. Aitchison Cambridge, UK
andrew at aitchison.me.uk
More information about the gdal-dev
mailing list