GDAL: jp2 driver missing in python

I need to open .jp2 raster files in python.

i installed GDAL after these instructions .

Using the command line gdalinfo --formatsdisplays the driver JP2OpenJPEG. gdalinfo filename.jp2returns the expected result.

But in python import gdal data=gdal.Open('filename.jp2')

returns nothing (.tiff works).

There are two other applications using GDAL, so I assume that python is using the wrong GDAL installation.

I have the same problem in R, but there I can indicate the correct installation with library(gdalUtils) gdal_chooseInstallation('JP2OpenJPEG')

Is there a way to tell python to install correctly or add a driver for jp2?


Windows 10

Python 2.7

GDAL 2.1.0

+4
source share
1 answer

.

, :

OSGEO4W https://trac.osgeo.org/osgeo4w/, GDAL JP2.

. , OSGEO bin\O4W_ENV.bat, , Path %OSGEO4W_ROOT%\bin;%WINDIR%\system32;%WINDIR%;%WINDIR%\WBem , , PATH, .

do gdalinfo --format JP2OpenJPEG

anaconda PATH, osgeo home script.

# set environment osgeo_home_bin = "C:\\OSGeo4W64\\bin" # the path order matters so make sure OSGEO4W64 is the first one os.environ['PATH'] = ''.join([osgeo_home_bin,";",os.environ['PATH']])

0

Source: https://habr.com/ru/post/1657767/


All Articles