Mittwoch, 1. April 2015

Custom SRIDs in PostGIS

One small, but occasionally very important feature of PostGIS is the ability to deal with custom spatial reference systems (SRS, in PostGIS SRS are defined using an SRID). Given data in some obscure projection, it is not required to transform the data to some well-known SRS, but it is possible to store the data directly, provided that a custom SRID entry is stored into the spatial_ref_sys relation in PostGIS. The columns in that table are basically the SRID (anything > 100000 should be safe to use for custom projections) and the projection definition in two formats, namely well-known text and as a proj4 string. Note that certain proj4 strings cannot be properly expressed as well-known text (f.e. rotated poles), in that case the well-known text definition can be extended by EXTENSION["PROJ4","<some proj4 string> +wktext"]. Also note that it seems that the "-m" option in the proj4 string is ignored, so it is better to use an equivalent "+to_meter" option (but I haven't tested this in every detail).