美文网首页
2020-02-22

2020-02-22

作者: TYY用来学习的账号 | 来源:发表于2020-02-22 16:52 被阅读0次
    • 发现上一次数据中大面积是海…(所以搜索结果里的文件实际所在区域可能与find data里选的区域周围距离很远?),于是又重新下了 2019-09-04 10:25 H: 18, V: 6

    • 将某图层数据显示为图片

      • MODIS可见光及近红外波段
        Band Color BandWidth(nm)
        1 Red 620 - 670
        2 NIR 841 - 876
        3 Blue 459 - 479
        4 Green 545 - 565
      • 显示nparray数组为图片
        # matplotlib
        plt.imshow(data)
        plt.savefig(fileName)
        plt.show()
        # PIL
        im = Image.fromarray(data)
        im.save(fileName)
        im.show()
        
    • 将某三个图层数据显示为图片

      • 代码
        red = sds[16].ReadAsArray() * 0.0001
        nir = sds[17].ReadAsArray() * 0.0001
        blue = sds[18].ReadAsArray() * 0.0001
        green = sds[19].ReadAsArray() * 0.0001
        
        red_ = np.expand_dims(red, 0)
        blue_ = np.expand_dims(blue, 0)
        green_ = np.expand_dims(green, 0)
        
        # true color array
        trueColor = np.concatenate([red_, green_, blue_])
        # 转换为matplotlib中的数据格式  即:(C, H, W) -> (H, W, C)
        trueColor = trueColor.transpose((1, 2, 0))
        display(trueColor, "trueColor")
        
        def display(data, title, band=1):
            plt.imshow(data)
            plt.savefig(title + ".png")
            plt.show()
        
      • 结果:


        真彩色图像
    • 计算NDVI

      • 使用两个波段
        def cal_NDVI(data_red, data_nir):
            """
            To calculate the NDVI of each pixel and return the result.
            :param data_red:
            :param data_nir:
            :return:
            """
            result = ((data_nir - data_red) / (data_nir + data_red))
            # 进行异常值处理
            result[np.isnan(result)] = 0
            result[result > 1] = 1
            result[result < 0] = 0
            print(np.min(result))
            print(np.max(result))
            # check the histogram
            hist, edges = np.histogram(result)
            print(hist)
            print(edges)
        
            display(result, "NDVI")
        
      • 结果


        NDVI值
      • 分布


        NDVI的histogram结果(100)
    • 绘制LST-NDVI散点图


    相关文章

      网友评论

          本文标题:2020-02-22

          本文链接:https://www.haomeiwen.com/subject/pvzkqhtx.html