Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

AttributeError: 'numpy.ndarray' object has no attribute 'mask'

未关闭
#91 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
numpy, python
领域
data

调研方向

从 makesurface/scripts/vectorize_raster.py 开始,重点检查 traceback 行中的 classify,并检查传递 nodata 值的 vectorize 入口点。使用不带 --nodata 的 makesurface vectorize 复现;对于没有 nodata 值的输入,矢量化不再引发报告的 AttributeError 即表示完成。

由索引模型根据 Issue 内容生成。

描述

This error occurs when vectorizing without a nodata value.
Use makesurface vectorize --nodata <value> to avoid the problem.

Related(?): https://github.com/mapbox/make-surface/issues/51 Masked arrays with no nodata
See also (?): https://github.com/mapbox/rasterio/issues/240, https://github.com/mapbox/rasterio/issues/241.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/makesurface", line 9, in <module>
    load_entry_point('makesurface==0.2.14.dev0', 'console_scripts', 'makesurface')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/makesurface/scripts/cli.py", line 42, in vectorize
    makesurface.vectorize(infile, outfile, classes, classfile, weight, nodata, smoothing, bidx, carto, axonometrize, nosimple, setnodata, nibble, outvar)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/makesurface/__init__.py", line 4, in vectorize
    vectorize_raster.vectorizeRaster(infile, outfile, classes, classfile, weight, nodata, smoothing, bidx, cartoCSS, axonometrize, nosimple, setNoData, nibbleMask, outvar)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/makesurface/scripts/vectorize_raster.py", line 128, in vectorizeRaster
    classRas, breaks = classify(inarr, int(classes), weight)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/makesurface/scripts/vectorize_raster.py", line 33, in classify
    outRas[np.where(inArr.mask == True)] = 0
AttributeError: 'numpy.ndarray' object has no attribute 'mask'
主要语言
Python
星标
91
派生
16
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

mapbox/make-surface 的其他 Issue

查看 mapbox/make-surface 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。