4

I'm trying to convert a local PCS (city of Buenos Aires) to wgs1984. Since the PCS is not included in Postgis, I added it to spatial_ref_sys using spatialreference.org (I compared the arguments with a .prj I know is right and they match). My coordinates for the PCS are in WKT, so to make my geometry column in wgs I used:

update <my_table> 
set geom = ST_Transform(ST_SetSRID(ST_GeomFromText(<wkt_column>), <PCS_number>), 4326);

Which works at first glance, but the points are off by approx. 50 meters in relation with my other wgs tables.

When I make the transformation using the Project tool on Arcgis, it works perfect. The difference I see is that Arcgis offers me to use different 'Geographic transformation methods' to make the transformation. The one I choose, and it works fine, is 'Campo_Inchauspe_To_Posgar_2007_1 + Posgar_2007_To_Wgs_1984_1'. I suspect that this method is the key to solve this, but in that case I don't have a clue on how to include that method in the Postgis transformation.


My .prj is this:

PROJCS["Argentina_GKBsAs",
GEOGCS["GCS_Campo_Inchauspe",
DATUM["D_Campo_Inchauspe",
SPHEROID["International_1924",6378388.0,297.0]],
PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["False_Easting",100000.0],
PARAMETER["False_Northing",100000.0],
PARAMETER["Central_Meridian",-58.4627],
PARAMETER["Scale_Factor",0.999998],
PARAMETER["Latitude_Of_Origin",-34.6297166],
UNIT["Meter",1.0]]

The projection number in spatialreference.org is 8333, and here you can see it in wkt as html for comparison:

PROJCS["Gauss Krugger BA", GEOGCS["GCS_Campo_Inchauspe", DATUM["D_Campo_Inchauspe", SPHEROID["International_1924",6378388.0,297.0]], PRIMEM["Greenwich",0.0], UNIT["Degree",0.0174532925199433]], PROJECTION["Transverse_Mercator"], PARAMETER["False_Easting",100000.0], PARAMETER["False_Northing",100000.0], PARAMETER["Central_Meridian",-58.4627], PARAMETER["Scale_Factor",1.0], PARAMETER["Latitude_Of_Origin",-34.6297166], UNIT["Meter",1.0]]

Here is the Postgis insert statement:

INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 98333, 'sr-org', 8333, '+proj=tmerc +lat_0=-34.6297166 +lon_0=-58.4627 +k=1 +x_0=100000 +y_0=100000 +ellps=intl +units=m +no_defs ', 'PROJCS["Gauss Krugger BA",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388.0,297.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",100000.0],PARAMETER["False_Northing",100000.0],PARAMETER["Central_Meridian",-58.4627],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",-34.6297166],UNIT["Meter",1.0]]');

So, I have one point in wgs:

-58.47532313, -34.63847446

And I make the geometry (Point, 4326) in one table

Then I take the same point in the PCS (8333):

POINT(98897.6171875 98978.84375)

And I make the geometry (Point, 4326) out of the following transformation:

update test_t 
set geom = ST_Transform(ST_SetSRID(ST_GeomFromText(coord), 98333), 4326);

I get this when I pick the point in Qgis:

enter image description here

Being the green point the correct one (the one originally in wgs), and the red the misplaced one (the transformed).

1
  • 1
    You haven't provided enough information to receive help. Provide the exact contents of your PRJ file. Provide the exact entry you added to spatial_ref_sys. Provide a point in the PCS, the incorrect WGS84 value you get, and the known correct transformed point location in WGS84. Then folks can do a bit of research and confirm if they have a solution without a lot of back and forth. Commented Aug 5, 2016 at 13:15

1 Answer 1

6

The spatial_ref_sys entry that spatialreference.org gave you was incomplete. It did not include the data to do the transformation from the Campo Inchauspe GCS to WGS84. Here's an entry that includes the transform:

INSERT into spatial_ref_sys 
(srid, auth_name, auth_srid, proj4text, srtext) 
values ( 98334, 'sr-org', 8333, 
'+proj=tmerc +lat_0=-34.6297166 +lon_0=-58.4627 +k=1 +x_0=100000 +y_0=100000 +ellps=intl +units=m +towgs84=-148,136,90,0,0,0,0 +no_defs ', 
'PROJCS["Gauss Krugger BA",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388.0,297.0]],TOWGS84[-148,136,90,0,0,0,0], PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",100000.0],PARAMETER["False_Northing",100000.0],PARAMETER["Central_Meridian",-58.4627],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",-34.6297166],UNIT["Meter",1.0]]');

Using the entry above, I can reproduce your good geographic coordinates from your PCS point.

select st_astext(st_transform('SRID=98334;POINT(98897.6171875 98978.84375)'::geometry,4326));

POINT(-58.475323109322 -34.6384744452138)

I found the TOWGS84 transform parameters by looking for entries in spatial_ref_sys that had "Inchauspe" in the srtext until I found one that had the same datum as your PRJ file had.

In general if you're seeing a transform that is almost-but-not-quite right (like your 50m drift), looking for problems in the datum transform is your most likely solution.

4
  • So does PostGIS support "composite" transformations like ArcGIS, e.g. Campo_Inchauspe_To_Posgar_2007_1 + Posgar_2007_To_Wgs_1984_1 ? Commented Aug 5, 2016 at 15:18
  • Thanks a lot! That worked perfectly, and saved me a lot of work. Btw, just yesterday I was reading your foreword in PostGIS in Action, great book.
    – Ivan
    Commented Aug 5, 2016 at 15:22
  • 2
    @Kirk, No, we just do what proj4 does, which is apply a single towgs84 transform. Commented Aug 5, 2016 at 15:24
  • 2
    If two transformations are both 'equation-based' (3 or 7 parameters), you can algebraically add the values--with the signs corrected for an inverse/reverse applied transformation--to make a new comcatenated transformation. In this case, the 2nd tfm's parameters are zeroes.
    – mkennedy
    Commented Aug 5, 2016 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.