5

As PROJ recent major update introduces importants change in the API, I need in my script to check what is the PROJ version compiled with the current GDAL installation of the user. I know I can get the GDAL version with osgeo.gdal.VersionInfo() but it does not tell me what is the PROJ version.

Any suggestions?

2 Answers 2

9

This way:

>>> from osgeo import osr
>>> osr.GetPROJVersionMajor()
6
>>> osr.GetPROJVersionMinor()
2
3
  • That method doesn't exist for osgeo.version_info : sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
    – Spacedman
    Nov 13, 2020 at 10:36
  • @Spacedman I have osgeo.version_info sys.version_info(major=3, minor=7, micro=0, releaselevel='final', serial=0) and method works. My current Proj version seems to be 6.3. Newest Proj is 7.2 but I do not know if there has been changes between 6 and 7.
    – user30184
    Nov 13, 2020 at 11:08
  • I have Python 3.5.3, and after pip install osgeo (no errors), then from osgeo import osr returns an error: ImportError: cannot import name 'osr'. Also, I don't know which osgeo version was installed by pip: osgeo.__version__ returns an AttributeError: module 'osgeo' has no attribute '__version__'
    – abu
    Apr 4, 2021 at 11:17
1

I found this was necessary (python 3.9)

> import osgeo
> osgeo.version_info

sys.version_info(major=3, minor=9, micro=13, releaselevel='final', serial=0)

> import osgeo.osr
> osgeo.osr.GetPROJVersionMajor()

9
> osgeo.osr.GetPROJVersionMinor()

0

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.