简体   繁体   English

为什么当我通过 rasterio 或 gdal 加载 NDVI 图像时所有数据都是 Nan

[英]Why all the data is Nan when I load NDVI image by rasterio or gdal

I calculated NDVI value and saved single band images following this page;我在此页面之后计算了 NDVI 值并保存了单波段图像; https://developers.planet.com/docs/planetschool/calculate-an-ndvi-in-python/ . https://developers.planet.com/docs/planetschool/calculate-an-ndvi-in-python/ After that I wanted to load those images on python by rasterio or gdal, loading images were succeeded, but unfortunately all the value was Nan.之后我想通过rasterio或gdal将这些图像加载到python上,加载图像成功,但不幸的是所有值都是Nan。 Why all the value is loaded as Nan?为什么所有的值都加载为 Nan? And how to fixed this situation?以及如何解决这种情况?

I googled but could not find solutions.我用谷歌搜索但找不到解决方案。 I need your helps, Plz...我需要你的帮助,请...

You can use masked array as suggested by this answer :您可以按照此答案的建议使用掩码数组

mar = np.ma.masked_array(ar, np.isnan(ar))
print(mar.min(), np.median(mar), mar.mean(), mar.std(), mar.max())

This masked array allows calculations to be taken on the array without taking into account the invalid values.这个掩码数组允许在不考虑无效值的情况下对数组进行计算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM