Python3.7 rasterio库无法打开jp2 [英] Python3.7 rasterio library cant open jp2

查看:136
本文介绍了Python3.7 rasterio库无法打开jp2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从sentinel2打开jp2图像,但是当我读取图像时

I want to open a jp2 image from sentinel2 but when I read the image

band = rasterio.open(imagetest, driver= 'JP2OpenJPEG')

我遇到下一个错误

'D:\DataStorage\00_sentinel_data\L1C_T29SQB_A013147_20171228T111919\IMG_DATA\T29SQB_20171228T111451_B02.jp2' not recognized as a supported file format.

我已经在OSGeo4W上安装了GDAL,使用gdalinfo --formats命令时可以看到驱动程序

I have installed GDAL with OSGeo4W and I can see the driver when I use the gdalinfo --formats command

JP2OpenJPEG -raster,vector- (rwv): JPEG-2000 driver based on OpenJPEG library

我唯一看到的可能是问题,当我看到使用python的gdal格式时,JP2OpenJPEG驱动程序不存在.

The only thing that I see that could be the problem is that when I see the gdal formats that I have using python, the JP2OpenJPEG driver does not exist.

from osgeo import gdal
for i in range(gdal.GetDriverCount()):
    drv = gdal.GetDriver(i)
    if drv.GetMetadataItem(gdal.DCAP_RASTER):
        print(drv.GetMetadataItem(gdal.DMD_LONGNAME), drv.GetMetadataItem(gdal.DMD_EXTENSIONS))

有关正在发生的事情的任何想法??

Any ideas about what is happening??

Python版本:3.7Gdal版本:2.3.3Rasterio版本:1.0.21

Python version: 3.7 Gdal version: 2.3.3 Rasterio version: 1.0.21

谢谢

推荐答案

我遇到了同样的问题.看来这是Anaconda的GDAL中的问题.这是解决问题的一种方法:

I had the same issue. It looks like this is a problem in Anaconda's GDAL. Here is one way to fix the problem:

https://gis.stackexchange.com/a/250837/149170

不幸的是,在Anaconda中升级/降级基本软件包对我不起作用.

Unfortunately, upgrading/downgrading the base package in Anaconda did not work for me.

我发现安装带有pip的"fiona"软件包对我来说是gdal的降级.我终于通过使用conda安装fiona解决了降级gdal的问题:

I was finding that installing the package "fiona" with pip was downgrading gdal for me. I finally fixed the issue of downgrading gdal by installing fiona using conda:

conda install fiona

这篇关于Python3.7 rasterio库无法打开jp2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆