Vous êtes sur la page 1sur 2

PostGIS 1.5.

1 Manual
165 / 315

Return area square feet and transform to Massachusetts state plane meters (26986) to get square meters. Note this is in square
feet because 2249 is Mass State Plane Feet and transformed area is in square meters since 26986 is state plane mass meters
SELECT ST_Area(the_geom) As sqft, ST_Area(ST_Transform(the_geom,26986)) As sqm
ST_GeomFromText(POLYGON((743238 2967416,743238 2967450,
743265 2967450,743265.625 2967416,743238 2967416)),2249) ) As foo(the_geom);
---------+-----------------928.625 | 86.2724304199219

Return area square feet and square meters using Geography data type. Note that we transform to our geometry to geography
(before you can do that make sure your geometry is in WGS 84 long lat 4326). Geography always measures in meters. This is
just for demonstration to compare. Normally your table will be stored in geography data type already.
SELECT ST_Area(the_geog)/POWER(0.3048,2) As sqft_spheroid, ST_Area(the_geog,false)/POWER (0.3048,2) As sqft_sphere, ST_Area(the_geog) As sqm_spheroid
ST_GeomFromText(POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416)),
) ,4326
) As foo(the_geog);
-----------------+------------------+-----------------928.684405217197 | 927.186481558724 | 86.2776044452694
--if your data is in geography already
SELECT ST_Area(the_geog)/POWER(0.3048,2) As
FROM somegeogtable;

sqft, ST_Area(the_geog) As sqm

See Also
ST_GeomFromText, ST_GeographyFromText, ST_SetSRID,ST_Transform

7.8.2 ST_Azimuth
ST_Azimuth Returns the angle in radians from the horizontal of the vector defined by pointA and pointB

float ST_Azimuth(geometry pointA, geometry pointB);

Returns the azimuth of the segment defined by the given Point geometries, or NULL if the two points are coincident. Return
value is in radians.

PostGIS 1.5.1 Manual

166 / 315

The Azimuth is mathematical concept defined as the angle, in this case measured in radian, between a reference plane and a point
Availability: 1.1.0
Azimuth is especially useful in conjunction with ST_Translate for shifting an object along its perpendicular axis. See upgis_lineshift Plpgsqlfunctions PostGIS wiki section for example of this.

--Azimuth in degrees
SELECT ST_Azimuth(ST_MakePoint(1,2), ST_MakePoint(3,4))/(2*pi())*360 as degAz,
ST_Azimuth(ST_MakePoint(3,4), ST_MakePoint(1,2))/(2*pi())*360 As degAzrev
degaz degazrev
------ --------45

See Also
ST_MakePoint, ST_Translate

7.8.3 ST_Centroid
ST_Centroid Returns the geometric center of a geometry.

geometry ST_Centroid(geometry g1);

Computes the geometric center of a geometry, or equivalently, the center of mass of the geometry as a POINT. For [MULTI]POINTs, this is computed as the arithmetric mean of the input coordinates. For [MULTI]LINESTRINGs, this is computed as the
weighted length of each line segment. For [MULTI]POLYGONs, "weight" is thought in terms of area. If an empty geometry is
supplied, an empty GEOMETRYCOLLECTION is returned. If NULL is supplied, NULL is returned.
The centroid is equal to the centroid of the set of component Geometries of highest dimension (since the lower-dimension
geometries contribute zero "weight" to the centroid).

Computation will be more accurate if performed by the GEOS module (enabled at compile time).

This method implements the OpenGIS Simple Features Implementation Specification for SQL 1.1.
This method implements the SQL/MM specification. SQL-MM 3: 8.1.4, 9.5.5

In each of the following illustrations, the blue dot represents the centroid of the source geometry.