- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用 Sentinel2 图像并尝试对它们重新采样。
我尝试了以下代码:
import os, fnmatch
INPUT_FOLDER = "/d/afavro/Bureau/test_resampling/original"
OUTPUT_FOLDER = "/d/afavro/Bureau/test_resampling/resampling_10m"
def findRasters (path, filter):
for root, dirs, files in os.walk(path):
for file in fnmatch.filter(files, filter):
yield file
for raster in findRasters(INPUT_FOLDER,'*.tif'):
print(raster)
inRaster = INPUT_FOLDER + '/' + raster
print(inRaster)
outRaster = OUTPUT_FOLDER + '/resample' + raster
print (outRaster)
cmd = "gdalwarp -tr 10 10 -r cubic " % (inRaster,outRaster)
os.system(cmd)
但我仍然收到相同的错误消息:
def findRasters (path, filter): ^
IndentationError: unexpected indent
我已经尝试过使用相同类型的代码来制作一个子集并且它有效。我不明白我的错误从何而来。
最佳答案
错误类型IndentationError
应该按字面理解:你的缩进似乎是错误的。你的线路
def findRasters (path, filter):
缩进太多,但需要与上一行保持相同的缩进级别
OUTPUT_FOLDER = "/d/afavro/Bureau/test_resampling/resampling_10m"
您提供的完整代码示例应如下所示:
import os, fnmatch
INPUT_FOLDER = "/d/afavro/Bureau/test_resampling/original"
OUTPUT_FOLDER = "/d/afavro/Bureau/test_resampling/resampling_10m"
def findRasters (path, filter):
for root, dirs, files in os.walk(path):
for file in fnmatch.filter(files, filter):
yield file
for raster in findRasters(INPUT_FOLDER,'*.tif'):
print(raster)
inRaster = INPUT_FOLDER + '/' + raster
print(inRaster)
outRaster = OUTPUT_FOLDER + '/resample' + raster
print (outRaster)
cmd = "gdalwarp -tr 10 10 -r cubic " % (inRaster,outRaster)
os.system(cmd)
此外,正如您在附加评论中所写,您的台词
cmd = "gdalwarp -tr 10 10 -r cubic " % (inRaster,outRaster)
似乎是错误的,因为 inRaster
和 outRaster
不会在字符串中使用。使用 String formatting相反:
cmd = 'gdalwarp -tr 10 10 -r cubic "{}" "{}"'.format(inRaster, outRaster)
关于python - 使用 gdalwarp 重新采样导致 IndentationError : unexpected indent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55829171/
这很奇怪,我只是在变量设置中进行了更改以使用哈希代替......你知道: black = #000 替换为: colors = { 'black': #000 // and so o
这很奇怪,我只是在变量设置中进行了更改以使用哈希代替......你知道: black = #000 替换为: colors = { 'black': #000 // and so o
我有这行代码,在测试 pep8 错误时我得到:线太长。因此,为了尝试解决此问题,我使用了 slash('\') 但随后我将延续行过度缩进以进行视觉缩进。我该怎么做才能解决这个问题? 我尝试过的事情:
我在下面的代码中收到一个 continuation line under-indented for visual indent 错误: command = 'ffmpeg -i downloa
我就是想不通这是怎么回事…… #!/usr/bin/env python # # Bugs.py # from __future__ import division # No
我是一个 Emacs 用户,在配置编辑器方面没有任何技能。我从 haskell-mode 升级后从 2.4 到 2.7,我注意到两个变化: 缩进在某种程度上是不同的,在某种程度上我不太喜欢。我不能完全
我正在尝试制作一个嗅探DNS数据包的程序,然后将数据包的qname放入字典的“键”中,并将数据包的dst ip放入字典的“值”中,由于某种原因,我遇到了此错误在第6行 from scapy.all
为了进行比较: 在Sublime(以及Atom)中,如果我在已经有4个制表符空间的代码行下按Tab,Sublime将自动跳到上一行的相同制表符间距(4个制表符空间)。 在VS Code中,当尝试完成相
无论我以哪种方式编写以下函数都会引发错误。 @staticmethod def _generate_clone_spec(param1=None, p
我正在 Sublime 文本编辑器中使用 Python。我被添加PEP8 packages . 我将 128 添加到以下文件“pep8_ignore”中。添加128并保存后。 Preferences
我从这里得到了 Google java 风格: https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style
刚刚使用 Sublime Text(使用 Sublime Linter)打开了一个文件,并注意到我以前从未见过的 PEP8 格式错误。正文如下: urlpatterns = patterns('',
我已安装 google-java-format插件 IntelliJ我已经启用了插件。当我格式化代码时,我的 java 代码缩进了 2 个空格。如何将 google java 格式化程序插件设置更改为
Haskell Parsec 的 indents 包提供了一种解析缩进式语言(如 Haskell 和 Python)的方法。它重新定义了 Parser类型,那么如何使用 Parsec 的 Text.P
我想让我的代码更有条理。因此,每当我从我的functions.php 文件中复制一个函数并将其粘贴到一个类中时,我需要将函数的每一行缩进一次或多次,以便于阅读并且看起来更美观。我的一些函数只不过是巨大
我直接从教科书中复制了这个 block ,并收到许多错误消息,但我无法解决其中的任何一个。我已经阅读并重读了我书中的这一部分,据我所知,这都是一个 block ,所以我很困惑为什么会有意外的缩进。我将
我直接从教科书中复制了这个 block ,并收到许多错误消息,但我无法解决其中的任何一个。我已经阅读并重读了我书中的这一部分,据我所知,这都是一个 block ,所以我很困惑为什么会有意外的缩进。我将
我一直在尝试找到一种也适合回溯缩进的递归下降解析器算法。但我一直让自己为此寻找麻烦的解决方案。 是否有任何资源也可以处理缩进? 谢谢 最佳答案 根据您的问题,我假设您正在为缩进敏感语言编写自己的递归下
有时,当我在 Sublime text2 中编辑 coffeescript 文件时,将其编译为 js 时出现错误: error: unexpected INDENT
我的main.sass中有这个: #thing { -moz-box-sizing: border-box; -webkit-box-sizing: border
我是一名优秀的程序员,十分优秀!