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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PostGIS</strong> <strong>1.5.8</strong> <strong>Manual</strong>138 / 310ExamplesChange Mass state plane US feet geometry to WGS 84 long latSELECT ST_AsText(ST_Transform(ST_GeomFromText(’POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))’,2249),4326)) As wgs_geom;wgs_geom---------------------------POLYGON((-71.1776848522251 42.3902896512902,-71.1776843766326 42.3903829478009,-71.1775844305465 42.3903826677917,-71.1775825927231 42.3902893647987,-71.1776848522251 42.3902896512902));(1 row)--3D Circular String exampleSELECT ST_AsEWKT(ST_Transform(ST_GeomFromEWKT(’SRID=2249;CIRCULARSTRING(743238 2967416 ←↪1,743238 2967450 2,743265 2967450 3,743265.625 2967416 3,743238 2967416 4)’),4326));st_asewkt--------------------------------------------------------------------------------------SRID=4326;CIRCULARSTRING(-71.1776848522251 42.3902896512902 1,-71.1776843766326 ←↪42.3903829478009 2,-71.1775844305465 42.3903826677917 3,-71.1775825927231 42.3902893647987 3,-71.1776848522251 42.3902896512902 4)Example of creating a partial functional index. For tables where you are not sure all the geometries will be filled in, its best to usea partial index that leaves out null geometries which will both conserve space and make your index smaller and more efficient.CREATE INDEX idx_the_geom_26986_parcelsON parcelsUSING gist(ST_Transform(the_geom, 26986))WHERE the_geom IS NOT NULL;Configuring transformation behaviourSometimes coordinate transformation involving a grid-shift can fail, for example if PROJ.4 has not been built with grid-shift filesor the coordinate does not lie within the range for which the grid shift is defined. By default, <strong>PostGIS</strong> will throw an error if agrid shift file is not present, but this behaviour can be configured on a per-SRID basis by altering the proj4text value within thespatial_ref_sys table.For example, the proj4text parameter +datum=NAD87 is a shorthand form for the following +nadgrids parameter:+nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.datThe @ prefix means no error is reported if the files are not present, but if the end of the list is reached with no file having beenappropriate (ie. found and overlapping) then an error is issued.If, conversely, you wanted to ensure that at least the standard files were present, but that if all files were scanned without a hit anull transformation is applied you could use:+nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat,nullThe null grid shift file is a valid grid shift file covering the whole world and applying no shift. So for a complete example, if youwanted to alter <strong>PostGIS</strong> so that transformations to SRID 4267 that didn’t lie within the correct range did not throw an ERROR,you would use the following:UPDATE spatial_ref_sys SET proj4text = ’+proj=longlat +ellps=clrk66 +nadgrids=@conus, ←↪@alaska,@ntv2_0.gsb,@ntv1_can.dat,null +no_defs’ WHERE srid = 4267;

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

Saved successfully!

Ooh no, something went wrong!