10

Polygon in Postgres/PostGIS database. It has the spatial reference 4269 which is in degrees.

I know there is a ST_Area() to calculate it. this is my query to select the areas in the SRID units.

select st_area(geom) from counties;

I want to calculate the area in Square Miles and insert a column named Area with the correct Square Mileage for each county

*I am a new to SQL and Postgres

asked May 13, 2016 at 22:32

1 Answer 1

16

ST_Area will use the units in your coordinate system, which as you say are degrees. So you have two options:

  • transform your geometries to a coordinate system that uses feet or meters
  • cast your geometries as geographies. ST_Area will then perform the calculation in meters.

You then need to convert from square feet or square meters to square miles.

Your query would look something like this

ALTER TABLE counties ADD COLUMN area real;
UPDATE counties SET area = ST_Area(geom::geography) / 1609.34^2
answered May 14, 2016 at 0:43
2
  • awesome I will give this a try Commented May 14, 2016 at 2:51
  • Saved a day. Thanks heaps @amball! Commented Jan 8, 2020 at 2:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.