Topics

Using Rasterio with GDAL 2.4.x

Ratcliff, Christina (A&F, Waite Campus)
 

Hi,

 

I’m trying to determine if it is possible to install Rasterio against GDAL 2.4.x on windows using the Gohlke wheels.

 

When installing rasterio versions 1.0.25 and above, it detects that the GDAL requirement is not met and attempts to build and install GDAL 3.0.4 and fails (log attached).
The environment I’m installing into is QGIS3 has GDAL 2.4.1 which shouldn’t be upgraded.

 

Is it possible to install the current release of Rasterio against GDAL 2.4.x ? The Rasterio readme suggests that this is supported.

 

On the assumption that this behavior is in error, I have been looking at source files and have a couple of queries.

 

1. In the .travis.yml are the following lines

- GDALINST=$HOME/gdalinstall
- GDALBUILD=$HOME/gdalbuild
- PROJINST=$HOME/gdalinstall
- PROJBUILD=$HOME/projbuild

 

      Should the 3rd line read $home/projinstall?

 

2. I have when installing using the wheel file, that GDAL is being matched to ~=3.0.1. (see attached log)

Collecting gdal~=3.0.1

  Using cached GDAL-3.0.4.tar.gz (577 kB)


    Where is this specified in the source files? 
If Rasterio indeed supports GDAL 2.4.1 should this in fact be >= 2.x.x ?


Many thanks in advance,

Christina

Sean Gillies
 

Hi Christina,

On Thu, Feb 13, 2020 at 12:15 AM <christina.ratcliff@...> wrote:

Hi,

 

I’m trying to determine if it is possible to install Rasterio against GDAL 2.4.x on windows using the Gohlke wheels.


Yes. It is my understanding that if you download one of the GDAL wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal and then the matching rasterio wheel from https://www.lfd.uci.edu/~gohlke/pythonlibs/#rasterio and then install them using pip like `python -m pip /path/to/gdal.whl /path/to/rasterio.whl`, you can have a working rasterio installation. The rasterio wheels from that site depend on a matching gdal wheel from that same site being installed. As far as I know, Gohlke's rasterio wheels are not compatible with GDAL installed in a different way.
 

When installing rasterio versions 1.0.25 and above, it detects that the GDAL requirement is not met and attempts to build and install GDAL 3.0.4 and fails (log attached).
The environment I’m installing into is QGIS3 has GDAL 2.4.1 which shouldn’t be upgraded.


I'm pretty sure that installing one of Gohlke's rasterio wheels into your QGIS3 python will not work. I am not sure what is the best way to install rasterio into QGIS3's python on Windows. I am not even sure that it is a good idea: QGIS3 has raster capabilities and its own Python modules, it think the happy path may be to use those instead.
 

Is it possible to install the current release of Rasterio against GDAL 2.4.x ? The Rasterio readme suggests that this is supported.


Yes. Note that to build and install Rasterio against a GDAL version installed on your system requires headers and other development files. I am not sure if those are provided by QGIS.

On the assumption that this behavior is in error, I have been looking at source files and have a couple of queries.

 

1. In the .travis.yml are the following lines

- GDALINST=$HOME/gdalinstall
- GDALBUILD=$HOME/gdalbuild
- PROJINST=$HOME/gdalinstall
- PROJBUILD=$HOME/projbuild

 

      Should the 3rd line read $home/projinstall?


In rasterio's Travis CI configuration, PROJ and GDAL are built at different locations but then are installed into a common location which just happens to be called "gdalinstall". We could have had different install locations, but a single one is much easier to use.

 

2. I have when installing using the wheel file, that GDAL is being matched to ~=3.0.1. (see attached log)

Collecting gdal~=3.0.1

  Using cached GDAL-3.0.4.tar.gz (577 kB)


    Where is this specified in the source files? 
If Rasterio indeed supports GDAL 2.4.1 should this in fact be >= 2.x.x ?


I would need to see the command you ran to install the wheel file before I began to answer this question.

I am not familiar enough with Windows or QGIS to give really great advice. I think that QGIS users who want to use rasterio in QGIS scripts should lobby the QGIS project to start including rasterio in QGIS.
 
Many thanks in advance,


Christina


I hope I've been able to help and I hope that someone else with more Windows and QGIS knowledge will jump in to correct any misinformation that I may have given you.

Joris Van den Bossche
 



On Sun, 16 Feb 2020 at 01:14, Sean Gillies <sean.gillies@...> wrote:
Hi Christina,

On Thu, Feb 13, 2020 at 12:15 AM <christina.ratcliff@...> wrote:

Hi,

 

I’m trying to determine if it is possible to install Rasterio against GDAL 2.4.x on windows using the Gohlke wheels.


Yes. It is my understanding that if you download one of the GDAL wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal and then the matching rasterio wheel from https://www.lfd.uci.edu/~gohlke/pythonlibs/#rasterio and then install them using pip like `python -m pip /path/to/gdal.whl /path/to/rasterio.whl`, you can have a working rasterio installation. The rasterio wheels from that site depend on a matching gdal wheel from that same site being installed. As far as I know, Gohlke's rasterio wheels are not compatible with GDAL installed in a different way.
 

When installing rasterio versions 1.0.25 and above, it detects that the GDAL requirement is not met and attempts to build and install GDAL 3.0.4 and fails (log attached).
The environment I’m installing into is QGIS3 has GDAL 2.4.1 which shouldn’t be upgraded.


I'm pretty sure that installing one of Gohlke's rasterio wheels into your QGIS3 python will not work. I am not sure what is the best way to install rasterio into QGIS3's python on Windows. I am not even sure that it is a good idea: QGIS3 has raster capabilities and its own Python modules, it think the happy path may be to use those instead.

You can install QGIS from conda-forge nowadays, so that could be an option to install both QGIS and rasterio that should be compatible with each other (I think, didn't try on windows): https://anaconda.org/conda-forge/qgis
 
 

Is it possible to install the current release of Rasterio against GDAL 2.4.x ? The Rasterio readme suggests that this is supported.


Yes. Note that to build and install Rasterio against a GDAL version installed on your system requires headers and other development files. I am not sure if those are provided by QGIS.

On the assumption that this behavior is in error, I have been looking at source files and have a couple of queries.

 

1. In the .travis.yml are the following lines

- GDALINST=$HOME/gdalinstall
- GDALBUILD=$HOME/gdalbuild
- PROJINST=$HOME/gdalinstall
- PROJBUILD=$HOME/projbuild

 

      Should the 3rd line read $home/projinstall?


In rasterio's Travis CI configuration, PROJ and GDAL are built at different locations but then are installed into a common location which just happens to be called "gdalinstall". We could have had different install locations, but a single one is much easier to use.

 

2. I have when installing using the wheel file, that GDAL is being matched to ~=3.0.1. (see attached log)

Collecting gdal~=3.0.1

  Using cached GDAL-3.0.4.tar.gz (577 kB)


    Where is this specified in the source files? 
If Rasterio indeed supports GDAL 2.4.1 should this in fact be >= 2.x.x ?


I would need to see the command you ran to install the wheel file before I began to answer this question.

I am not familiar enough with Windows or QGIS to give really great advice. I think that QGIS users who want to use rasterio in QGIS scripts should lobby the QGIS project to start including rasterio in QGIS.
 
Many thanks in advance,


Christina


I hope I've been able to help and I hope that someone else with more Windows and QGIS knowledge will jump in to correct any misinformation that I may have given you.

Ratcliff, Christina (A&F, Waite Campus)
 

Hi,

 

Thank you for your responses. I have previously installed rasterio via the Gohlke wheel file alongside QGIS quite successfully by using a properly configured osgeo4w shell to ensure it installs against the correct version of python and GDAL.

 

Joris, thank you for the link to QGIS on conda, but our end users aren’t programmers so installing QGIS this way may be a bit difficult for them.

 

The version of GDAL that the Rasterio wheel is built for on the Gohlke page isn’t explicitly stated, just that GDAL is required. There are wheels available for GDAL 2.2.4, 2.4.1 and 3.0.4 for python 3.7.  I have confirmed the Rasterio 1.0.24 wheel installs successfully against QGIS’s GDAL 2.4.1, 2.4.3 and 3.0.3 but Rasterio 1.0.25+ only installs against 3.0.x.

 

My method for installation is to download a wheel file from the Gohlke page and install it into the configured environment with admin privileges using

          pip install <path to rasterio wheel file>

I have attached the resulting log files created when installing Rasterio 1.0.25 & 1.1.2.

 

Just to clarify, I would like to be able to skip the building and installation of GDAL on Windows if the requirement of using GDAL >= 1.11 is already met; hence my question regarding  gdal~=3.0.1. If this is possible, where in the code is this set? Are there extra options I can use with pip to achieve this?

 

Thanks,

 

Christina

Sean Gillies
 

Hi Christina,

On Mon, Feb 17, 2020 at 11:23 PM Ratcliff, Christina (A&F, Waite Campus) <christina.ratcliff@...> wrote:

Hi,

 

Thank you for your responses. I have previously installed rasterio via the Gohlke wheel file alongside QGIS quite successfully by using a properly configured osgeo4w shell to ensure it installs against the correct version of python and GDAL.

 

Joris, thank you for the link to QGIS on conda, but our end users aren’t programmers so installing QGIS this way may be a bit difficult for them.

 

The version of GDAL that the Rasterio wheel is built for on the Gohlke page isn’t explicitly stated, just that GDAL is required. There are wheels available for GDAL 2.2.4, 2.4.1 and 3.0.4 for python 3.7.  I have confirmed the Rasterio 1.0.24 wheel installs successfully against QGIS’s GDAL 2.4.1, 2.4.3 and 3.0.3 but Rasterio 1.0.25+ only installs against 3.0.x.

 

My method for installation is to download a wheel file from the Gohlke page and install it into the configured environment with admin privileges using

          pip install <path to rasterio wheel file>

I have attached the resulting log files created when installing Rasterio 1.0.25 & 1.1.2.

 

Just to clarify, I would like to be able to skip the building and installation of GDAL on Windows if the requirement of using GDAL >= 1.11 is already met; hence my question regarding  gdal~=3.0.1. If this is possible, where in the code is this set? Are there extra options I can use with pip to achieve this?

 

Thanks,

 

Christina


Because Gohlke's wheels are not known to pip, you must either

1) install the appropriate GDAL wheel *before* installing the rasterio wheel, or
2) use the --find-links option documented in  https://pip.pypa.io/en/stable/reference/pip_install/#cmdoption-f to point to a directory containing wheels downloaded from Gohlke's page.

If you try to install Gohlke's rasterio wheel first, pip will go looking, by default, in the Python package index for a GDAL package and will not find anything there that is compatible with Gohlke's rasterio wheel.

--
Sean Gillies