I have decided to venture into the world of GDAL/OGR with Python with my main motivation to mimic some tools from ArcGIS for Desktop. I am hoping that this will help me to improve on a few fronts; my Python coding, increased knowledge regarding open source geospatial libraries, and to better understand the algorithms that churn away behind the scenes when you click a button in a GUI based GIS and perform some sort of geoprocessing or data analysis.
I mainly work with ESRI File Geodatabases and while I know this is not open source ESRI have an API in place to read and write to a gdb via GDAL/OGR. The first step is to setup what I need to start my journey for learning GDAL/OGR with Python for Windows. I will also install a few libraries that will help speed up some computations for more efficient geoprocessing.
I am using…
Python 2.7.13 32bit on Windows 7 Professional
1. Download and Install Microsoft Visual C++ 2008 Service Pack
Click here to download and the install.
2. Go to Christoph Gohlke’s website and download the GDAL wheel.
Grab the GDAL whl file. I downloaded GDAL‑2.1.3‑cp27‑cp27m‑win32.whl
Open the command prompt, change directory to where the whl was downloaded and use pip to install.
pip install "GDAL‑2.1.3‑cp27‑cp27m‑win32.whl"
3. Get the File Geodatabase API from ESRI (you will need an ESRI account)
Go to ESRI Dowloads and download File Geodatabase API 1.3 version for Windows (Visual Studio 2008). This will be a zip folder. Open the contents of the API zipped folder and extract FileGDBAPI.dll from the bin folder to
C:\Python27\Lib\site-packages\osgeo
or wherever your site-package folder resides. Just make sure to extract it to osgeo.
4. Create a New Variable in Environmental Variables
In Advanced System Settings create a new Environmental Variable called GDAL_DRIVER_PATH and set the path to the osgeo folder in Step 5.
5. Open __init__.py from osgeo…
… and uncomment line 10.
Save the file.
6. Test the setup
Open a Python interpreter and test using…
If you do not get an errors like the screenshot above then setup has been successful.
*************************************************************************************************
OPTIONAL: these will be used in some capacity for scripting geoprocessing,
7. Download numpy + mkl wheel from the brilliant website of Christoph Gohlke
Click here and download the necessary whl file. For my setup I have downloaded numpy‑1.11.3+mkl‑cp27‑cp27m‑win32.whl
Open up the command prompt and change directory to where the downloaded file resides. Use pip to install.
pip install "numpy‑1.11.3+mkl‑cp27‑cp27m‑win32.whl"
8. Install SciPy
Back we go to Gohlke repository and to the SciPy Wheels. Here, I have downloaded scipy‑0.19.0‑cp27‑cp27m‑win32.whl
Open up the command prompt if you have closed it after Step 1 and change directory to where the downloaded file can be found.
Use pip to install.
pip install "scipy‑0.19.0‑cp27‑cp27m‑win32.whl"
9. Install Shapely
You got it, go back to Gohlke and download the Shapely whl file. I grabbed Shapely‑1.5.17‑cp27‑cp27m‑win32.whl. Use pip to install similar to Steps 7 and 8.
Now to immerse myself in learning mode and put GDAL/OGR to some use. Check out OSGP#1.1: Measuring Geographic Distributions – Mean Center for the first attempt.