I am trying to do some image analysis in Python but am unable to install GDAL due to limited rights. I have attempted copying some of the files and folders into my python folder but am constantly encountering the same error
ImportError: No module named _gdal
The searching that I have done always seems to point to some sort of installer for GDAL, but I am only able to copy the needed .py folders into my python folder.
Is there a way to do this on Windows and if not is there an alternative image reader that can properly open rasters?
sys.path results:
['C:\\Users\\ûser\\Documents\\Python Image Extractor\\Image Interpreter\\src', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages\\xlutils-1.5.2-py2.6.egg', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages\\xlrd-0.8.0-py2.6.egg', 'C:\\Python26\\ArcGIS10.0\\DLLs', 'C:\\Python26\\ArcGIS10.0\\lib', 'C:\\Python26\\ArcGIS10.0\\lib\\plat-win', 'C:\\Python26\\ArcGIS10.0\\lib\\lib-tk', 'C:\\Python26\\ArcGIS10.0', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages\\PIL', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages\\win32', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages\\win32\\lib', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages\\Pythonwin', 'C:\\windows\\system32\\python26.zip', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\bin', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\arcpy', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\ArcToolbox\\Scripts']
Answer
Ok plan B! Looks like there is a problem with the maptools.org package that does not include the _gdal_array. Sorry took me a while to figure that our. I tend use ogr and not gdal for the most part so I never noticed!
So to start again:
- Make sure you have numpy
- Create an install directory where all the final bits and pieces will be located. Lets say C:\GDAL. I'll refer to this dir as
- Download the appropriate package from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
- If you don't have it already get 7-zip, After installing you should be able to right click on the exe and choose extract here. The extract will create two directories DATA and PLATLIB
- Copy everything in PLATLIB to
- Copy everything in DATA\Lib\site-packages\osgeo to \osgeo
Now its just a matter of altering your PYTHONPATH and PATH environment variables to include your . The following code will do it in a script.
import os
import os.path
import sys
environList = os.environ['PATH'].split(';')
root = r'C:\Kevin\proj\pythonJunkyard\GDALComponents\GDAL-10.1'
environList.insert(0,root)
os.environ['PATH'] = ';'.join(environList)
sys.path.insert(0,root)
import osgeo.ogr
import osgeo.gdal
Hope this works!
No comments:
Post a Comment