使用rasterstast包统计栅格,报错:AttributeError: module 'numpy' has no attribute 'asscalar'

原因:NumPy 1.16.0 后就没有asscalar函数了

New deprecations
The type dictionaries numpy.core.typeNA and numpy.core.sctypeNA are deprecated. They were buggy and not documented and will be removed in the 1.18 release. Use`numpy.sctypeDict` instead.

The numpy.asscalar function is deprecated. It is an alias to the more powerful numpy.ndarray.item, not tested, and fails for scalars.

The numpy.set_array_ops and numpy.get_array_ops functions are deprecated. As part of NEP 15, they have been deprecated along with the C-API functions PyArray_SetNumericOps and PyArray_GetNumericOps. Users who wish to override the inner loop functions in built-in ufuncs should use PyUFunc_ReplaceLoopBySignature.

The numpy.unravel_index keyword argument dims is deprecated, use shape instead.

The numpy.histogram normed argument is deprecated. It was deprecated previously, but no warning was issued.

The positive operator (+) applied to non-numerical arrays is deprecated. See below for details.

Passing an iterator to the stack functions is deprecated

使用numpy.ndarray.item()代替asscalar()

参考:NumPy 1.16.0 Release Notes — NumPy v1.24.dev0 Manual

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐