0

I am running Python 3.11.4

I would like to use pyproj 3.6 to calculate geoid heights as described in the documentation exemple.
However, I don't get the same result as in the documentation when installing pyproj 3.6.0 with pip.

python3 -m venv env
source env/bin/activate
python
>>> from pyproj import CRS, Transformer
>>> from pyproj.crs import CompoundCRS
>>> src_crs = CRS("EPSG:4979") # Any 3D CRS, here the 3D WGS 84
>>> vert_crs = CRS("EPSG:5773") # Any vertical CRS, here the EGM96 geoid
>>> dst_crs = CompoundCRS(src_crs.name + vert_crs.name, components=[src_crs.to_2d(), vert_crs])
>>> transformer_3d = Transformer.from_crs(src_crs, dst_crs, always_xy=True)
>>> transformer_3d.transform(8.37909, 47.01987, 1000)
(8.37909, 47.01987, 1000)

I checked the result by installing pyproj 3.6.0 with conda and this time I obtained the same result as in the documentation.

conda create -n pyproj_env pyproj
conda activate pyproj_env
python
>>> from pyproj import CRS, Transformer
>>> from pyproj.crs import CompoundCRS
>>> src_crs = CRS("EPSG:4979") # Any 3D CRS, here the 3D WGS 84
>>> vert_crs = CRS("EPSG:5773") # Any vertical CRS, here the EGM96 geoid
>>> dst_crs = CompoundCRS(src_crs.name + vert_crs.name, components=[src_crs.to_2d(), vert_crs])
>>> transformer_3d = Transformer.from_crs(src_crs, dst_crs, always_xy=True)
>>> transformer_3d.transform(8.37909, 47.01987, 1000)
(8.37909, 47.01987, 951.7851086745321)

Have I missed something, or made a mistake?


Thanks to @snowman2, I realized I need to activate the use of network for grids with the wheels on pypi. If I do it works like a charm.

python3 -m venv env
source env/bin/activate
pip install pyproj
python
>>> from pyproj import CRS, Transformer
>>> from pyproj.crs import CompoundCRS
>>>
>>> pyproj.network.set_network_enabled(active=True)
>>>
>>> src_crs = CRS("EPSG:4979") # Any 3D CRS, here the 3D WGS 84
>>> vert_crs = CRS("EPSG:5773") # Any vertical CRS, here the EGM96 geoid
>>> dst_crs = CompoundCRS(src_crs.name + vert_crs.name, components=[src_crs.to_2d(), vert_crs])
>>> transformer_3d = Transformer.from_crs(src_crs, dst_crs, always_xy=True)
>>> transformer_3d.transform(8.37909, 47.01987, 1000)
(8.37909, 47.01987, 951.7851086745321)
basso31
  • 1
  • 1

0 Answers0