I'm using PostgreSQL 14.1 with PostGIS 3.1.

I've got a UTM 10x10 km grid malla, set in EPSG 25830, that covers all Spanish territories:

enter image description here

I have run the following code (just to check that everything is OK)

select utmcode, cast(st_area(m.geom)/10000 as integer) ha
from malla m;

but it returns values over 10,000 ha, meaning that the calculation is not accurate. I guess it's a matter of the projection, since the westernmost grids have the largest deviances, but I'm not sure as how to proceed. How could I overcome the problem?

  • 3
    It looks like the 10 kmx10km grid is originally created separately for each UTM zone but you calculate the areas when all data are projected to EPSG:25830. When you look at the data, are the areas of the most western and eastern cells systematically larger than for the cells at the middle?
    – user30184
    Dec 3, 2021 at 11:08
  • @user30184 Yes, they were probably created separately, as you guess. Do you think that I should split them back and make any calculations separately or would there be a solution for working with all of them together?
    – jpinilla
    Dec 3, 2021 at 12:50
  • Because you have data in PostGIS it might be best to use "geography" when computing areas and distances.
    – user30184
    Dec 3, 2021 at 12:58
  • @user30184 Is it feasible to do so with a UTM grid?
    – jpinilla
    Dec 3, 2021 at 13:04
  • 1
    Well, the UTM grid shells won't be exactly 10000 hectares if calculated as geographies. Split by UTM zones and re-projecting cells of each slice into their native zone could be an option but it really depends on what is your goal.
    – user30184
    Dec 3, 2021 at 14:06


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.