[Solved] Specifying geoid grid for osr.SpatialReference instance

corvus Asks: Specifying geoid grid for osr.SpatialReference instance
How can I specify e.g. Geoid 12A or Geoid 18 when (for example) converting NAVD88 orthometric heights to ellipsoid heights using the OSR Python bindings?

I would like to be able to specify any .gtx file that is available to OSR.

I guess it looks something like this:

from osgeo import osr

# Take NAD83/UTM 15N as an example
src_horz = osr.SpatialReference()
src_horz.SetUTM(15, True)
# Use NAVD88 vertical datum
src_vert = osr.SpatialReference()
# Define compound SRS
src_srs = osr.SpatialReference()
src_srs.SetCompoundCS('', src_horz, src_vert)

# Define output SRS
dst_horz = osr.SpatialReference()
# Use NAVD88 vertical datum
dst_vert = osr.SpatialReference()
# dst_vert.SetVerticalShiftGrid('Geoid 12A') ### How do I do this?
# Define compound SRS
dst_srs = osr.SpatialReference()
dst_srs.SetCompoundCS('', dst_horz, dst_vert)

transform = osr.CoordinateTransformation(src_srs, dst_srs)

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.