I am a total newbie here,

I have a bunch of polygons in my cartodb map, and I want to create a new column called "AREA" in the table MY_TABLE that contains values from my area calculation query:

select ST_Area(the_geom::geography) as area_sqm FROM My_TABLE

this statement works, but the column area_sqm that contains the area vlue clears every time I clear the query, how can I have this permanently as part of my table so I can display the area value in the info table of my map?


In general:

ALTER TABLE  your_table ADD COLUMN area double precision;

UPDATE your_table SET area=ST_AREA(geom::geography);

(If your srid is 4326 and your data is stored as geometry)


To round to 2 decimals use round() funcrion. If I remember right it works on numeric type and not double precision. So you need something like:

  • Great! worked! Is there anyway to limit the precision to be just 2 digits after decimal points? Now its showing 9 digits....THANKS! – Vivian Ngo Jul 18 '14 at 18:23

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.