Is it possible to calculate area or centroid of the_geom in cartoDB?
It would not be a huge time saver, and I am doubtful that it is an option but figured I would ask.
Is it possible to calculate area or centroid of the_geom in cartoDB?
It would not be a huge time saver, and I am doubtful that it is an option but figured I would ask.
Using spatial SQL:
SELECT *, ST_Area(the_geom) FROM Table
SELECT *, ST_AsText(ST_Centroid(the_geom)) FROM Table
warrieka's answer is correct but there are other ways to do them that might be useful.
Area calculations are going to be in whatever the projection of the geometry is though. So for area, distance, length type functions it can be a lot more useful to cast them as geography
so your results are in meters (or square meters).
SELECT ST_Area(the_geom::geography) area_sqm FROM tablename
Centroid of geometries are just as you expect. However, if you have interested shapes in your geoms, sometimes they can fall outside of your actual polygons! If you just want a point that is inside your geometry and similar to center, you can use PointOnSurface
SELECT ST_PointOnSurface(the_geom) the_geom FROM tablename