Whether you are finding it difficult to install the GDAL library or have been able to install it but do not know how to make it work in Django for your geoDjango app, I would like to share how I was able to successfully get it to work for me. I hope I would not miss any step as it took me days to make it work.
Solution to installing GDAL/PROJ/GEOS in windows 10 for Django/Geodjango
3k views Asked by james morgan At
1
There are 1 answers
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in DJANGO
- Django Admin Panel and Sub URLs Returning 404 Error on Deployment
- How to return HTTP Get request response from models class in Django project
- Issue with Quantity Increment in Django E-commerce Cart
- Can't install Pipenv on Windows
- use dict from python in django html template and also in js
- 'pyodbc.Cursor' object has no attribute 'callproc', mssql with django
- Django socketio process
- Root path analogue in uWSGI as in Uvicorn
- Django - ModuleNotFoundError: No module named 'backend'
- Does Python being a loosely typed programming language make it less secure?
- sorl-thumbnail adds a background color when padding is used
- Can't connect to local postgresql server from my docker container
- Why ProductHunt api dont work with Python?
- why i have to put extra space in before write option selected because it show error if i don't ' option:selected'
- Django Arrayfield migration to cloud sql (Postgresql) not creating the column
Related Questions in GDAL
- I can not load sf in docker
- ModuleNotFoundError: No module named '_gdal'
- empty output files when using gdal.vectorTranslate
- How to compile java gdal PGEO on apple silicon MacOS to read mdb file?
- GDAL ogr2ogr alternative that uses multiprocessing
- Not able to install the gdal module of python
- Geoserver Docker image GDAL library extension error
- Wrong coordinate transformation with osr.CoordinateTransformation
- Masking a raster file using another file with different resolution and
- Warnings when cropping SpatRaster or read/write NetCDF files using terra package
- Transparent background for Openlayers single-band, overviews GeoTIFF
- Tried both import gdal and from osgeo import gdal but not helping although gdal is installed. Is there a way to change environments to make it work?
- Is there a way to resample a raster to a lower resolution using a weighted average of constituent pixels?
- Can I use GDAL Translate to define 4 corners without reprojecting the image?
- Why am I getting this error when trying to use postgis
Related Questions in GEODJANGO
- Readonly map for GeoDjango fields in Django>=4.0?
- GeoDjango: How can I calculate the distance between two points on a linestring?
- How to add ManyToMany field in geojson serializer
- GeoDjango endpoint is extremely slow
- Django access MultilinestringM in Postgis with Geometry(dim=3)
- OSError: [WinError 127] after gdal installation
- Could not find module 'C:\OSGeo4W\bin\gdal308.dll' (or one of its dependencies)
- Issues installing Spatialite on Amazon Linux 2 "libgdal.so: undefined symbol: sqlite3_trace_v2"
- Django ORM: how to cast geometry to geography in filter?
- Use serializer in Django (GeoDjango) to include both model field and some related ForeignKey fields
- Django does not load the maps in the admin panel
- How do I create an emptry LineString in GeoDjango
- displaying large shapefile in leaflet-geojson-vt
- GeoDjango and Geoserver tutorial or book suggestion for beginner
- How to create tables in different schemas using Geodjango and Postgres/ PostGIS?
Related Questions in OSGEO
- Conversion problem: Large TIFF File to XYZ Format
- No module named 'osgeo._gdal_array' - Docker image with Python and GDAL
- GDAL Installation on Mac (Ventura) with Python 3.11 via Homebrew Fails: 'Python.h' File Not Found
- I am getting incorrect north and east values after carthographic projection using PROJ library in c++
- how to stack bands of satellite images located in a folder without the need to name them using gdal in OSGeo 4W Shell
- ERROR: Failed building wheel for osgeo, Failed to build osgeo
- How to convert raster map to shapefile (raster map boundaries to vector center line shapefile)
- GDAL Warp produces a black image
- proj.db not found in gdal-3.2.1 runing in Amazon Linux 2
- Install GDAL on LINUX Ubuntu 20.04.4LTS for python
- I keep getting blank images while trying to Georeference an image with GDAL
- why do I receive these errors "WARNING: Ignoring invalid distribution -yproj " while installing any python module in cmd
- How to check if the environment variable "PROJ_LIB" is defined and how to unset it ? (PyQGIS Standalone Script Executer)
- Solution to installing GDAL/PROJ/GEOS in windows 10 for Django/Geodjango
- GDAL and Fiona conflicting versions but downgrading Fiona leads to a legacy-install-failure error
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
For geoDjango to work it needs some free Geospatial libraries, which it uses in the inbuilt
django.contrib.gisapp and I will be showing you how to install it.Step 1: Downloading osgeo4w
For some reason the hosting website https://trac.osgeo.org/osgeo4w/ download link does not work properly, either it won't work at all in chrome or downloads the 32bit in firefox but seems to work alright in the Edge browser an alternative is to use the QGIS link https://qgis.org/en/site/forusers/download.html. You will get a downloaded file as
osgeo4w-setup.exe.Step 2: Installing it
They say use the Express install which I am sure does not work cause I have tried it at least 30 times and each download cost a little above 500MB. Use the Advance install because that was what worked for me. Click on
Things might change a little in the future so be cautious.
Step 3: Modifying Windows environment
Open command prompt in administrative mode for administrative privileges'. You can then copy and paste these one after the other in the order they appear.
This is for win64 systems as of 2022 as it is the one supported, if you are using win32 make sure you download an 32bit version of OSGeo4W/GDAL the same commands will work.
See django Doc for all the commands above.
After you are done you can check the environment variables to confirm your changes by typing in the windows search box:
Click on the Environment Variables button and in the system variables section scroll and double click on Path. Here you should see your python path and also "C:\OSGeo4W" and "C:\OSGeo4W\bin" if you don't click on New and add it yourself.
When done success click on OK on all open windows go back to your python environment and in the command prompt use pip to install psycopg2 if you will be working with Postgres.
Step 4: Configuring django After getting through successfully when you open cmd and type
gdalinfo --versionyou should see the version of gdal installed, but when your run django (python manage.py check or runserser) you will get this error most of the time depending on the version of gdal you installed and if you do not get an error whilst running django you are good to go and no need to follow the rest of the answer.To solve this go to the system folder holding the OSGeo4W most of the time it will be here C:\OSGeo4W open it and locate and open bin as well. Look inside the
binfolder for the largest file with the namegdal***.dll.The *** number if you have a memory span of less than 60 seconds write that number somewhere and go into your python environment where django is installed and navigate to this path:
and open
libgdal.pyfile with your favorite editor.Scroll down to line 24, in the lib_names list, add the *** number into the list as a string, mine was
304. So it becomes something like thisAlso on line 38 add the version of gdal prefixed with gdal like this
"gdal3.4.2", you will get the version when you typegdalinfo --versionin command prompt.Save file and done, you can now run your Geodjango app with no problem. Good luck.