Skip to content

Conversation

@sanmit99
Copy link
Contributor

@sanmit99 sanmit99 commented Apr 8, 2025

Following up to resolve proximity issue: #1854

I have added the native path of gdal_proximity and ran it in subprocess. additional check is passed as well to make sure the path exists to the gdal_proximity script.

@sanmit99 sanmit99 closed this Apr 8, 2025
@sanmit99 sanmit99 reopened this Apr 8, 2025
@pierotofy
Copy link
Member

Thanks for the PR @sanmit99 ! This is a good workaround, but I don't think it addresses the root cause.

It seems that this issue only happens with the GPU builds of ODM. If you run:

root@4d9e2ef9523d:/code# python3 -c "from osgeo import utils;print(utils.__file__)"
/usr/lib/python3/dist-packages/osgeo/utils/__init__.py

From the latest CPU docker image, it works fine. But doesn't in the GPU images.

For some reason, the osgeo_utils package does not get installed in the system path (/usr/lib/python3). Understanding why that is and fixing it should be the proper fix.

@sanmit99
Copy link
Contributor Author

sanmit99 commented Apr 8, 2025

@pierotofy Yes indeed you are right, I had gone through osgeo util import import. utils itself wont import

python3
Python 3.8.10 (default, Mar 18 2025, 20:04:55) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import utils
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'utils' from 'osgeo' (/usr/lib/python3/dist-packages/osgeo/__init__.py)
>>> 

Note: the container has gdal 3.0.4

And as per investigation going through gdal versions i found out utils were first introduced in gdal3.2:
https://github.com/OSGeo/gdal/blob/release/3.2/gdal/swig/python/osgeo/utils/gdal_proximity.py

Prior versions had it in scripts
https://github.com/OSGeo/gdal/blob/release/3.1/gdal/swig/python/scripts/gdal_proximity.py

@sanmit99
Copy link
Contributor Author

sanmit99 commented Apr 8, 2025

@pierotofy Yes indeed you are right, I had gone through osgeo util import import. utils itself wont import

python3
Python 3.8.10 (default, Mar 18 2025, 20:04:55) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import utils
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'utils' from 'osgeo' (/usr/lib/python3/dist-packages/osgeo/__init__.py)
>>> 

Note: the container has gdal 3.0.4

And as per investigation going through gdal versions i found out utils were first introduced in gdal3.2: https://github.com/OSGeo/gdal/blob/release/3.2/gdal/swig/python/osgeo/utils/gdal_proximity.py

Prior versions had it in scripts https://github.com/OSGeo/gdal/blob/release/3.1/gdal/swig/python/scripts/gdal_proximity.py

This problem is with gdal versions. if we can either force to have bare minimum gdal version or else we can handle like i have shared in PR.

:) hope this helps

@pierotofy
Copy link
Member

Thanks for investigating. Upgrading GDAL could be tricky. I ended up just refactoring the solution proposed here by defining a fallback function for gdal_proximity instead.

@pierotofy pierotofy merged commit 465b66a into OpenDroneMap:master Apr 9, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants