I am just starting to learn how to use PostGIS (1.5.4) and my SQL skills are essentially those of a competent beginner. Having perused the PostGIS documentation and searched these forums, I'm not finding the answers to what are surely some very simple questions.
Given a single table loaded with polygons from shapefiles, how can I query the latitudinal maximum and minimum and the centroids of single and aggregate rows? I'll note that I have found the ST_Centroid() function, but haven't figured out how to interpret its output (CRS=WGS84).
Best Answer
Maximum latitude for one row:
maximum latitude over aggregate:
Centroid in human readable form:
Centroid reprojected to EPSG 4326 (WGS84) in human readable form:
"Centroid of aggregate rows" I'm not sure how to read. You can aggregate geometries by using
st_union
and then compute the centroid of the aggregated geometry:Later edit: If median latitude is the average of minimum and maximum latitude, I don't think
st_centroid
is guaranteed to be equal to it. If you require average latitude, you can just compute(st_ymax(way) + st_ymin(way))/2
.