1

I am trying to develop Python code to do a vertical datum transformation between WGS84 (GNSS elipsoid height) to NAVD88 geoid height. I have seen and copied the code from @asynchron located in the post here.

My code (below) returns the same elevation as the input elevation but this UNAVCO site states that my expected values should be 93.22m converted from the 72.5m input elevation at my latitude and longitude.

import pyproj

def convert_wgs84_to_navd88(latitude, longitude, altitude_wgs84):
    wgs84 = pyproj.crs.CRS.from_epsg(4979)  # WGS84 CRS
    navd88 = pyproj.crs.CRS.from_epsg(5498)  # NAVD88 CRS

transformer = pyproj.transformer.Transformer.from_crs(crs_from=wgs84, crs_to=navd88)

converted_latitude, converted_longitude, converted_altitude_navd88 = transformer.transform(latitude, longitude, altitude_wgs84)

return converted_latitude, converted_longitude, converted_altitude_navd88

latitude = 48.790886  # Example latitude in decimal degrees
longitude = 122.625369  # Example longitude in decimal degrees
altitude_wgs84 = 72.5  # Example altitude in meters (WGS84)

converted_latitude, converted_longitude, converted_altitude_navd88 = convert_wgs84_to_navd88(latitude, longitude, altitude_wgs84)

print(f"Converted Latitude (NAVD88): {converted_latitude}")
print(f"Converted Longitude (NAVD88): {converted_longitude}")
print(f"Converted Altitude (NAVD88): {converted_altitude_navd88}")

asychron suggests that this is because I do not have any vertical transformation grids installed (which is true to my knowledge because I have not installed any gtx grid transformation files.

Furthermore, asychon states that a missing grid transformation file will return a noop value but I do not see a noop value in any error message nor do I see this when watching the variable in my Python IDE. Here is the variable information from the IDE. Sorry for the image paste but WingIDE is not letting me copy text from the variable watch portion of the IDE: enter image description here

How do I convert elevation in WGS84 ellipsoid heights to NAVD88 elevations with Pyproj.

2
  • Is proj-data installed?
    – GeoMonkey
    Commented Jul 26, 2023 at 3:19
  • @Geomonkey - I have a directory here that was recently downloaded from Proj: /usr/share/proj/proj-data-1.14/ with a number of tiffs (but no GPX files are included in that directory). I also have this from the terminal in Ubuntu: proj-bin is already the newest version (6.3.1-1)
    – GBG
    Commented Jul 26, 2023 at 16:36

1 Answer 1

0

I encountered the same issue today. After some research, I found that the default installation of pyproj doesn't include the high-precision grid files needed for certain transformations.

Fortunately, pyproj can download these grid files automatically, but this feature is disabled by default.

To enable it, navigate to the pyproj data directory. You can find it under /proj_dir/share/proj inside the pyproj installation folder. For example, if you installed it via pip on Windows, the path is usually something like C:\Users\<your username>\AppData\Roaming\Python\<python version>\site-packages\pyproj\proj_dir\share\proj.

Look for the proj.ini file in this folder, open it, and change network = off to network = on. Save the file. This will allow the package to automatically download the required grid files.

Now, go back to your Python script and run it again. This time, it may take longer as it downloads the necessary files, but after that, it should work smoothly.

By the way, the latest version of WGS84 is WGS84(G2139), and its EPSG code is 9754. You can use this instead.

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.