Short version

How can I remove SRID information from PostGIS geometry? Is ST_SetSRID(geom, 0) well-defined?

Long version

I am rendering maps, using PostGIS. To do this, I create a temporary table, and populate it by ST_Transform():ing my geometries from EPSG:4326 to my desired map projection (usually EPSG:3006, SWEREF99TM) and using ST_Affine() to scale and translate them into map coordinates (90-per-inch units on the paper). I then do some processing on this temporary table (cartographic generalization of different kinds), before marshalling it all out to the styling stage.

Apparently, the result of ST_Affine(ST_Transform(..., srid), ...) is considered to be “in” that SRID, even though the ST_Affine makes this dubious, at best. This means that whenever I want to add geometry from other sources into the mix, that, too, has to be tagged with that SRID, even though it is actually in “paper space”. This means that I have to keep track of the SRID in various places in my program, which are really only concerned with things like “25 mm from the left side of the paper”. If I don’t, PostGIS complains that I am doing operations on geometries with different SRID:s.

It seems like PostGIS happily performs things like ST_Intersects on geometries with no SRID, so if I could get everything to this state, I would be fine.

  • 1
    You can't eliminate a fundamental property of the geometry type. I'd suggest doing all your geometric processing in the projection before doing the Affine transformation (and doing a SetSRID to zero afterward). – Vince Jun 10 at 11:00
  • It should be OK to use SRID=0 even it might be more correct to use SRID=-1. This is from the GeoPackage standard but same should apply to PostGIS The record with an srs_id of -1 SHALL be used for undefined Cartesian coordinate reference systems. The record with an srs_id of 0 SHALL be used for undefined geographic coordinate reference systems. See also gis.stackexchange.com/questions/64252/…. – user30184 Jun 10 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.