Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I use PostgreSQL with POSTGIS extension.

I have a set of points in the_geom column from a table myshema.myobjects I would want create a select statement to get the centroid of this cluster, so from a select statement like this :

select the_geom from myshema.myobjects

Then I search the correct syntax of a statement that could look like that :

SELECT ST_AsText(ST_Centroid( (SELECT the_geom FROM myshema.myobjects) ));
share|improve this question

1 Answer 1

up vote 8 down vote accepted

you have to use the union function like this

SELECT att1, st_centroid(st_union(geom)) as geom
FROM schema.table
GROUP BY att1;

so you can obtain centroid of point that have same attribute.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.