- If you are using Windows, be sure to install OSGeo4W, as suggested in the initial instructions for this chapter. This will include Python and GDAL Python bindings with NumPy support.
For Linux users, in case you did not do it yet, follow the initial instructions for this chapter and create a Python virtual environment in order to keep a Python-isolated environment to be used for all the Python recipes in this book. Then, activate it:
$ source postgis-cb-env/bin/activate
- For this recipe, you need the GDAL Python bindings and NumPy, the latter being needed by a GDAL method (ReadAsArray) for arrays. In the most likely case, you have already installed GDAL in your virtual environment as you have been using it for other recipes, so be sure to remove it and reinstall it after installing NumPy. In fact, GDAL needs to be compiled with NumPy support if you want to use its array's features:
(postgis-cb-env)$ pip uninstall gdal
(postgis-cb-env)$ pip install numpy (postgis-cb-env)$ pip install gdal
- For the purpose of this recipe, you will use a sample dataset from NOAA Earth System Research Laboratory (ESRL). The excellent ESRL web portal offers a plethora of data in the NetCDF format to be freely downloaded. For example, download the following dataset from the ESRL CPC Soil Moisture data repository (you can find, as usual, a copy of this dataset in the book's dataset directory for this chapter): https://www.esrl.noaa.gov/psd/data/gridded/data.cpcsoil.html.