Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用rasterio的WarpedVRT对geotiff进行翘曲时出现问题_Python_Rasterio - Fatal编程技术网

Python 使用rasterio的WarpedVRT对geotiff进行翘曲时出现问题

Python 使用rasterio的WarpedVRT对geotiff进行翘曲时出现问题,python,rasterio,Python,Rasterio,我不熟悉使用rasterio在Python中进行空间数据处理,并且一直在使用示例。我在翘曲方面遇到了问题,即使使用了可用的示例数据集,我也不确定从这里可以走到哪里。下面是我一直在运行的代码(直接来自rasterio文档)和我收到的错误 from affine import Affine import mercantile import rasterio from rasterio.enums import Resampling from rasterio.vrt import WarpedVR

我不熟悉使用rasterio在Python中进行空间数据处理,并且一直在使用示例。我在翘曲方面遇到了问题,即使使用了可用的示例数据集,我也不确定从这里可以走到哪里。下面是我一直在运行的代码(直接来自rasterio文档)和我收到的错误

from affine import Affine
import mercantile

import rasterio
from rasterio.enums import Resampling
from rasterio.vrt import WarpedVRT

with rasterio.open('RGB.byte.tif') as src:
    with WarpedVRT(src, crs='EPSG:3857',
                   resampling=Resampling.bilinear) as vrt:

        # Determine the destination tile and its mercator bounds using
        # functions from the mercantile module.
        dst_tile = mercantile.tile(*vrt.lnglat(), 9)
        left, bottom, right, top = mercantile.xy_bounds(*dst_tile)

        # Determine the window to use in reading from the dataset.
        dst_window = vrt.window(left, bottom, right, top)

        # Read into a 3 x 512 x 512 array. Our output tile will be
        # 512 wide x 512 tall.
        data = vrt.read(window=dst_window, out_shape=(3, 512, 512))

        # Use the source's profile as a template for our output file.
        profile = vrt.profile
        profile['width'] = 512
        profile['height'] = 512
        profile['driver'] = 'GTiff'

        # We need determine the appropriate affine transformation matrix
        # for the dataset read window and then scale it by the dimensions
        # of the output array.
        dst_transform = vrt.window_transform(dst_window)
        scaling = Affine.scale(dst_window.num_cols / 512,
                               dst_window.num_rows / 512)
        dst_transform *= scaling
        profile['transform'] = dst_transform

        # Write the image tile to disk.
        with rasterio.open('/tmp/test-tile.tif', 'w', **profile) as dst:
            dst.write(data)

CPLE\u BaseError回溯(最近一次调用)
rasterio/_crs.pyx在rasterio中。_crs._crs.来自用户输入()
rasterio/_err.pyx在rasterio中。_err.exc_wrap_ogrer()
CPLE_BaseError:OGR错误代码6
在处理上述异常期间,发生了另一个异常:
CRSRERROR回溯(最近一次呼叫最后一次)
在里面
8将rasterio.open('RGB.byte.tif')作为src:
9带翘曲VRT(src,crs='EPSG:3857',
--->10重采样=重采样。双线性)作为vrt:
11
12#使用
rasterio中的rasterio/_warp.pyx._warp.WarpedVRTReaderBase.uuuu init_uuuuuuuuu()
~/opt/anaconda3/envs/tensorflow/lib/python3.6/site-packages/rasterio/crs.py in
来自用户输入(cls、值、来自esri方言的变形)
457 elif isinstance(值、字符串类型):
458 obj=cls()
-->459对象=来自用户输入的对象(值,
来自esri方言的变体=来自esri方言的变体)
460返回obj
461其他:
rasterio/_crs.pyx在rasterio中。_crs._crs.来自用户输入()
错误:无法分析WKT。OGR错误代码6
CPLE_BaseError                            Traceback (most recent call last)
rasterio/_crs.pyx in rasterio._crs._CRS.from_user_input()

rasterio/_err.pyx in rasterio._err.exc_wrap_ogrerr()

CPLE_BaseError: OGR Error code 6

During handling of the above exception, another exception occurred:

CRSError                                  Traceback (most recent call last)
<ipython-input-26-764b8370d990> in <module>
      8 with rasterio.open('RGB.byte.tif') as src:
      9     with WarpedVRT(src, crs='EPSG:3857',
---> 10                    resampling=Resampling.bilinear) as vrt:
     11 
     12         # Determine the destination tile and its mercator bounds using

rasterio/_warp.pyx in rasterio._warp.WarpedVRTReaderBase.__init__()

~/opt/anaconda3/envs/tensorflow/lib/python3.6/site-packages/rasterio/crs.py in 
from_user_input(cls, value, morph_from_esri_dialect)
    457         elif isinstance(value, string_types):
    458             obj = cls()
--> 459             obj._crs = _CRS.from_user_input(value, 
morph_from_esri_dialect=morph_from_esri_dialect)
    460             return obj
    461             else:

rasterio/_crs.pyx in rasterio._crs._CRS.from_user_input()

CRSError: The WKT could not be parsed. OGR Error code 6