我开始玩GeoPySpark,并正在实现example notebook。
我成功检索了图像
!curl -o /tmp/B01.jp2 http://sentinel-s2-l1c.s3.amazonaws.com/tiles/32/T/NM/2017/1/4/0/B01.jp2
!curl -o /tmp/B09.jp2 http://sentinel-s2-l1c.s3.amazonaws.com/tiles/32/T/NM/2017/1/4/0/B09.jp2
!curl -o /tmp/B10.jp2 http://sentinel-s2-l1c.s3.amazonaws.com/tiles/32/T/NM/2017/1/4/0/B10.jp2
这是脚本:
import rasterio
import geopyspark as gps
import numpy as np
from pyspark import SparkContext
conf = gps.geopyspark_conf(master="local[*]", appName="sentinel-ingest-example")
pysc = SparkContext(conf=conf)
jp2s = ["/tmp/B01.jp2", "/tmp/B09.jp2", "/tmp/B10.jp2"]
arrs = []
for jp2 in jp2s:
with rasterio.open(jp2) as f: #CRASHES HERE
arrs.append(f.read(1))
data = np.array(arrs, dtype=arrs[0].dtype)
data
脚本在我将标记放置在此处的位置崩溃,并出现以下错误:
RasterioIOError: '/tmp/B01.jp2' not recognized as a supported file format.
我准确地复制粘贴了示例代码,Rasterio中的广告甚至将其uses .jp2 files in examples进行了文档记录。
我正在使用随pip3一起安装的以下Rasterio版本。我没有安装Anaconda(迷惑了我的Python环境),也没有安装GDAL(它拒绝,如果这是我唯一的解决方案,那将是另一个问题的主题)
Name: rasterio
Version: 1.1.0
Summary: Fast and direct raster I/O for use with Numpy and SciPy
Home-page: https://github.com/mapbox/rasterio
Author: Sean Gillies
Author-email: sean@mapbox.com
License: BSD
Location: /usr/local/lib/python3.6/dist-packages
Requires: click-plugins, snuggs, numpy, click, attrs, cligj, affine
Required-by:
为什么它拒绝读取.jp2文件?是否有办法将它们转换为可用的东西?还是您知道可以接受的格式类似于这些示例文件的任何示例文件?