1

I am trying to convert coordinates in EPSG:4283 to EPSG:4326 in sf in R, on 2 computers with different dependency versions.

Computer A has GDAL 3.8.2, GEOS 3.11.2 and PROJ 9.31, Windows 10

Computer B has GDAL 3.5.2, GEOS 3.9.3 and PROJ 8.2.1, Windows 8

The default st_transform output for computer A does not alter the input geometry:

> library(sf)
> in_data <- st_as_sf(data.frame(x=151.262387590000003, y=-33.912053239999998766), coords=c('x', 'y'), crs='EPSG:4283')
> st_transform(in_data, 'EPSG:4326')$geometry[[1]]
POINT (151.262387590000003 -33.912053239999998766)

Whereas on computer B there is a difference after 5dp (which is significant for this task):

> library(sf)
> in_data <- st_as_sf(data.frame(x=151.262387590000003, y=-33.912053239999998766), coords=c('x', 'y'), crs='EPSG:4283')
> st_transform(in_data, 'EPSG:4326')$geometry[[1]]
POINT (151.26239300639633711 -33.912040561252297266)

To try and figure out what was causing this, I first printed out the available pipelines for both computers with sf_proj_pipelines('EPSG:4283', 'EPSG:4326') which gave the same 2 operations for both (albeit in different orders, with computer A having the no operation pipeline first):

[1] "+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=GRS80 +step +proj=helmert +x=0.06155 +y=-0.01087 +z=-0.04019 +rx=-0.0394924 +ry=-0.0327221 +rz=-0.0328979 +s=-0.009994 +convention=coordinate_frame +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg"
[2] "proj=noop +ellps=GRS80"

This gives me the options, but not what was specifically used by st_transform (worth noting that both of those options had the same "accuracy" value on both computers). Using rgdal's list_coordOps I tried to find the 'best' candidate pipeline. The output for computer A was:

Candidate coordinate operations found:  3 
Strict containment:  FALSE 
Visualization order:  TRUE 
Source: EPSG:4283 
Target: EPSG:4326 
Best instantiable operation has accuracy: 3 m
Description: axis order change (2D) + GDA94 to WGS 84 (1) + axis order change (2D) 
Definition:  +proj=noop +ellps=GRS80 
Operation 3 is lacking 1 grid with accuracy 3 m
Missing grid: au_icsm_GDA94_GDA2020_conformal_and_distortion.tif 
URL: https://cdn.proj.org/au_icsm_GDA94_GDA2020_conformal_and_distortion.tif 

And computer B:

Candidate coordinate operations found:  3 
Strict containment:  FALSE 
Visualization order:  TRUE 
Source: EPSG:4283 
Target: EPSG:4326 
Best instantiable operation has accuracy: 3 m
Description: axis order change (2D) + GDA94 to WGS 84 (2) + axis order change (2D) 
Definition:  +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=GRS80 +step +proj=helmert +x=0.06155 +y=-0.01087
             +z=-0.04019 +rx=-0.0394924 +ry=-0.0327221 +rz=-0.0328979 +s=-0.009994 +convention=coordinate_frame +step +inv +proj=cart +ellps=WGS84 +step +proj=pop
             +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg
Operation 3 is lacking 1 grid with accuracy 3 m
Missing grid: au_icsm_GDA94_GDA2020_conformal_and_distortion.tif 
URL: https://cdn.proj.org/au_icsm_GDA94_GDA2020_conformal_and_distortion.tif 

When I try and enter the Definition of the best candidate from computer B on an st_transform on computer A:

    Warning message:
    In st_transform.sfc(st_geometry(x), crs, ...) :
      pipeline not found in PROJ-suggested candidate transformations

And even when entering it on computer B:

hgridshift: could not find required grid(s).
pipeline: Pipeline: Bad step definition: proj=hgridshift (File not found or invalid)
hgridshift: could not find required grid(s).
pipeline: Pipeline: Bad step definition: proj=hgridshift (File not found or invalid)
Warning message:
In st_transform.sfc(st_geometry(x), crs, ...) :
  pipeline not found in PROJ-suggested candidate transformations

Both of which result in empty geometries.

In order to get output on computer B to match that of computer A, I can use a no operation projstring:

    +proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=noop +ellps=GRS80

But I can't figure out how to get computer A to match the output of computer B. I suspect computer B is missing the grid required (I've tried sf_proj_network(TRUE) to get grids or other proj info online but this doesn't change anything) to make the shift it puts forward as the best candidate, so it falls back on a different transformation that I cannot find the definition for. But I'm not sure.

What pipeline can I use, or other method, to get results on computer A to match that of computer B, without changing the underlying PROJ or GDAL versions?

5
  • If the aim is to use the noop pipeline, then I would do almost nothing. Just change the code, because EPSG:4326 and EPSG:4283 are considered to mean the same.
    – user30184
    Commented Sep 18 at 23:14
  • The aim is to use the pipeline that does alter the coordinates (ie. the operation computer B performs, where computer A does noop). I agree that there is no need to transform in that case, I just need computer B to match A to avoid breaking other processes Commented Sep 18 at 23:37
  • If you miss the gridshift file, download it and place it into the directory where the "PROJ_DATA" environmental vabiable points.
    – user30184
    Commented Sep 18 at 23:39
  • Thanks, I've tried this. I downloaded the gridshift file and pointed sf to it through the sf_proj_search_paths function and the R_SF_USE_PROJ_DATA environment variable. I've also tried copying the default proj search path from computer B to computer A and that does not work either Commented Sep 18 at 23:45
  • @user30184 When GDA94 was defined, yes, it was considered almost equivalent to the current WGS 84, and was linked to ITRF92 at epoch 1994.0. GDA2020 is tied to ITRF2014 at epoch 2020.0. If someone has recent ITRF data (and it's called WGS 84), a no-op means it's closer to GDA2020 than GDA94. Those two are separated by about 1.8 m.
    – mkennedy
    Commented Sep 20 at 1:05

1 Answer 1

0

I know nothing about R so this may be off-topic, but this Proj command that does alter the coordinates did not fit into the comment box. "cct" is this program https://proj.org/en/9.4/apps/cct.html. The pipeline is captured from the output of projinfo -s epsg:4326 -t epsg:4283.

echo   151.26239300639633711 -33.912040561252297266 0| cct -v +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=GRS80 +step +proj=helmert +x=0.06155 +y=-0.01087 +z=-0.04019 +rx=-0.0394924 +ry=-0.0327221 +rz=-0.0328979 +s=-0.009994 +convention=coordinate_frame +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg

151.2623984228  -33.9120278825        0.0000           inf

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.