I have a PostgreSQL db with a table with geometry multipolygons stored in srid 4326 (lat/lngs). I need to calculate the area of the oriented envelope around each polygon, and I am using
st_orientedenvelope to do so. I want area in reasonable units, so I also need to use
st_transform before calling
Why do I get different results depending on the order of transforming and generating the envelope?
select st_area(st_orientedenvelope(st_transform(geom, 26910))) a, st_area(st_transform(st_orientedenvelope(geom), 26910)) reverse from mytable
Whether the envelope is generated and then transformed or the transformation happens and then the envelope is generated shouldn't (to my mind) matter. Calculating
a / reverse should always result in a number very close to 1. However, in my data set of ~2000 records, more than 10% of the area calculations (
a compared to
reverse) differ from each other by more than 5% - some by as much as 25%.
In the image, the black line is envelope generated after transform (
a), and the orange line is transform after creating envelope (
In the above example, I use 26910, which is SRID for UTM 10N because the data is in Seattle area. However, I get very similar results using other SRIDs, including 2926 (Washington State Plane) and 2163 (US National Atlas Equal Area).