0

I'm using gdalinfo to get some information out of a map, and want to use it to calculate the area represented by the map. I'm currently doing it (when the units are given in metres), by multiplying size[0]*size[1]*geoTransform[1]*-geoTransform[5]/1,000,000 to get the area in square kilometres.

I've manually confirmed many of these areas by entering the wgs84extent into geojson. However, this usually only works when the skew and rotation values (geoTransform[2] and geoTransform[4]) are 0. If they are non-zero, my area calculation is wrong. I was wondering what equation I should be using to consider these values and get an accurate area?

This is an example. The units are again in metres here. My calculations get me 0.025 square kilometres, while geojson gives me 16.3.

  "size":[
    2565,
    2052
  ]

  "coordinateSystem":{
    "wkt":"PROJCS[\"NAD_1983_UTM_Zone_11N\",\n    GEOGCS[\"GCS_North_American_1983\",\n        DATUM[\"North_American_Datum_1983\",\n            SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],\n        PRIMEM[\"Greenwich\",0.0],\n        UNIT[\"Degree\",0.0174532925199433]],\n    PROJECTION[\"Transverse_Mercator\"],\n    PARAMETER[\"False_Easting\",500000.0],\n    PARAMETER[\"False_Northing\",0.0],\n    PARAMETER[\"Central_Meridian\",-117.0],\n    PARAMETER[\"Scale_Factor\",0.9996],\n    PARAMETER[\"Latitude_Of_Origin\",0.0],\n    UNIT[\"Meter\",1.0]]"
  }

  "geoTransform":[
    569166.1990436509950086,
    0.070050043573309,
    -1.7578549919737869,
    4986248.3334737550467253,
    -1.7582010122098635,
    -0.0705420294500134
  ]

  "wgs84Extent":{
    "type":"Polygon",
    "coordinates":[
      [
        [
          -116.1220248,
          45.0263128
        ],
        [
          -116.1678264,
          45.0253527
        ],
        [
          -116.166135,
          44.9847436
        ],
        [
          -116.1203658,
          44.9857033
        ],
        [
          -116.1220248,
          45.0263128
        ]
      ]
    ]
  }
0

Seems like this answers my question Why doesn't gdalinfo report pixel size?. You have to add the squares of geoTransform[1] geoTransform[4], and square root it to get the x spatial resolution. Same with geoTranform[2] and geoTransform[5] to get y pixel resolution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.