Install PostGIS
This post considers that you have already installed PostgreSQL & pgAdmin on your windows computer. So, you should already have the Application Stack Builder software on your system. Application Stack Builder is actually used to download and install add-ons to our Postgres databases.
Goto Application Stack Builder and install PostGIS extension.
![Install PostGIS and GDAL 1 install postgis rathank.com](https://rathank.com/wp-content/uploads/2022/04/install-postgis.png)
Go to Pgadmin 4 and create a PostGIS extension for your database
Click on the Query tool and run the below query
CREATE EXTENSION postgis;
Install GDAL on Windows
Download GDAL wheel file that is supported for your platform from here
Cut the wheel file and paste it inside your project’s root directory. Make sure your virtual environment is activated.
Install the wheel using command pip install name_of_the_file
You will see osgeo folder has been created in the location ‘..envLibsite-packages’ .
Go to osgeo folder and copy the path of your gdalxxx.dll file and add it to the settings.py file as gdal library path.
os.environ['PATH'] = os.path.join(BASE_DIR, 'venvLibsite-packagesosgeo') + ';' + os.environ['PATH']
os.environ['PROJ_LIB'] = os.path.join(BASE_DIR, 'venvLibsite-packagesosgeodataproj') + ';' + os.environ['PATH']
GDAL_LIBRARY_PATH = os.path.join(BASE_DIR, 'venvLibsite-packagesosgeogdal303.dll')
Install GDAL on Mac OS
Install GDAL on your system
brew install gdal
To be sure that GDAL is installed in your system, just type:
gdal-config --version
Now we have GDAL installed, we proceed to setup a GDAL Python binding. Just upgrade your version of pip before to install the library in python environment.
pip3 install — upgrade pip
Once updated, just type:
pip3 install gdal==x.x.x
Replace x.x.x with the gdal version, it must be the same as the one obtained in the step above using gdal-config. To avoid conflicts or any further issues, it’s important to install and use the exact versions that any component will require.
Sometimes you could experiment ModuleNotFoundError trying to install the GDAL python binding, you can solve this issue by installing the needed modules. The most required module is Numpy, and you can install it just by typing:
pip3 install numpy # only if you get Numpy ModuleNotFoundError
Check out your GDAL python binding
python3 -c "from osgeo import gdal"
You won’t see anything if everything is well installed.