concept ST_Transform in category postgis

appears as: ST_Trsform
PostGIS in Action, Third Edition

This is an excerpt from Manning's book PostGIS in Action, Third Edition.

The shp2pgsql command line lets you transform the SRID with an additional :<to_srid> so you could skip the ST_Transform step in your code by replacing the 4269 with -s 4269:2163 as shown in the next listing.

  • Most commercial mapping toolkit APIs accept data to be mapped only in WGS 84 lon/lat (although they use some variant of Mercator for display). ST_Transform also introduces some rounding errors as you retransform data, so it’s best to transform only once from the source format. ST_Transform is a fairly cheap process, so it’s okay to run it for each geometry if you keep -functional indexes on the transformations of the form CREATE INDEX idx _geomt ON sometable USING gist(ST_Transform(geom,some_srid) and then use ST_DWithin(a.geom, ST_Transform(sometable.geom,some_srid), some _distance) for distance checking. Now when ST_DWithin is used with the transformed geometry, the function spatial index will kick in to help.
  • PostGIS in Action, Second Edition

    This is an excerpt from Manning's book PostGIS in Action, Second Edition.

    As you might have noticed, the command line lets you transform the SRID with an additional -s switch, so you could skip the ST_Transform step in your code or use the data more or less as is. You can also index with the -I switch.

  • Most commercial mapping toolkit APIs accept data to be mapped only in WGS 84 lon/lat (although they use some variant of Mercator for display). ST_Transform also introduces some rounding errors as you retransform data, so it’s best to transform only once from the source format. ST_Transform is a fairly cheap process, so it’s okay to run it for each geometry if you keep functional indexes on the transformations of the form CREATE INDEX idx _geomt ON sometable USING gist(ST_Transform(geom,some_srid) and then use ST_DWithin(a.geom, ST_Transform(sometable.geom,some_srid), some _distance) for distance checking. Now when ST_DWithin is used with the transformed geometry, the function spatial index will kick in to help.
  • PostgreSQL supports not only functional indexes but also partial ones. A partial index allows you to index only part of your data. In general, you should only apply an ST_Transform function for the region defined for a given UTM; otherwise you’ll run into coordinate bounds issues. It’s also generally best to partition your data using table inheritance, and use different transform indexes for each table.

    The next listing is an example of a functional ST_Transform index and of a possible view you might create to take advantage of it.