12.07.2015 Views

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PostGIS</strong> <strong>1.5.8</strong> <strong>Manual</strong>163 / 310ExamplesReturn area in square feet for a plot of Massachusetts land and multiply by conversion to get square meters. Note this is in squarefeet because 2249 is Mass State Plane FeetSELECT ST_Area(the_geom) As sqft, ST_Area(the_geom)*POWER(0.3048,2) As sqmFROM (SELECTST_GeomFromText(’POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))’,2249) ) As foo(the_geom);sqft | sqm---------+-------------928.625 | 86.27208552Return area square feet and transform to Massachusetts state plane meters (26986) to get square meters. Note this is in squarefeet because 2249 is Mass State Plane Feet and transformed area is in square meters since 26986 is state plane mass metersSELECT ST_Area(the_geom) As sqft, ST_Area(ST_Transform(the_geom,26986)) As sqmFROM (SELECTST_GeomFromText(’POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))’,2249) ) As foo(the_geom);sqft | sqm---------+------------------928.625 | 86.2724304199219Return 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 isjust 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_spheroidFROM (SELECTgeography(ST_Transform(ST_GeomFromText(’POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 ←↪2967416,743238 2967416))’,2249) ,4326))) As foo(the_geog);sqft_spheroid | sqft_sphere | sqm_spheroid-----------------+------------------+------------------928.684405217197 | 927.186481558724 | 86.2776044452694--if your data is in geography alreadySELECT ST_Area(the_geog)/POWER(0.3048,2) AsFROM somegeogtable;sqft, ST_Area(the_geog) As sqmSee AlsoST_GeomFromText, ST_GeographyFromText, ST_SetSRID,ST_Transform7.8.2 ST_AzimuthST_Azimuth — Returns the angle in radians from the horizontal of the vector defined by pointA and pointB

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!