Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to use jython with GDAL on Windows. Python and GDAL are installed through MS4W and work perfectly together. Jython is installed manually, but I can not import GDAL. I tried to update sys.path on Jython to point to all python sys.path.

But it displays the following error message:

> Traceback (most recent call last):    
> File "C: \ myjythonscript.py",
> line 38, in <module>
>      OSGeo import    File "C: \ OSGeo4W \ apps \ Python25 \ lib \ site-packages \ OSGeo \ __init__.py", line 24, in <module>
>      _gdal import ImportError: No module named _gdal

Has anyone worked with Jython and GDAL? Any ideas to solve the problem? Thank you!

share|improve this question
add comment

2 Answers

Jython is Python for the JVM. GDAL is not going to be accessible like this. If you want to use the GDAL bindings, you'll need to use the (C) Python in C:\OSGeo4W\apps\Python25.

If you want to stick with Jython, take a look at importing classes from GeoTools or Geotk.

share|improve this answer
add comment

According to the Jython FAQ you can't use the standard gdal python bindings (yet):

Jython programs cannot currently use CPython extension modules written in C. These modules usually have files with the extension .so, .pyd or .dll. If you want to use such a module, you should look for an equivalent written in pure Python or Java. However, it is technically feasible to support such extensions, as demonstrated by IronPython. For the next release of Jython, we plan to support the C Python Extension API.

The binaries that can be downloaded from http://www.gisinternals.com/sdk contain Java bindings, though I have no idea if you can use them in Jython.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.