Tag Archives: ndvi

将Global AVHRR NDVI 3g转换为ESRI ASCII Grid栅格的Matlab代码

我在前面的帖子(previous post)介绍了用ArcGIS读取GIMMS AVHRR NDVI 3g格式的数据文件的方法,但并不十分好用。所以写了一点代码,用于方便的将之转换为ESRI ASCII Grid栅格,后者可以很容易的被GIS软件支持。

从这个帖子可以下载到相关的代码和样例ndvi3g数据。

注意运行代码需要 Matlab的支持。

Purpose: Convert GIMMS Global AVHRR NDVI 3g files to ESRI ASCII Grid, which is very easy to be accessed with popular GIS software.
Author: Zhuotong Nan (giscn@msn.com)
Web: https://nanzt.info
Date: Sep 11,2014

Last update: Nov 3,2014

Please distribute codes with this header attached.

Usage:

type convert_ndvi3g_ascii in Matlab to run

Open convert_ndvi3g_ascii.m, modify the ndvi3gfl variable to make it point to the ndvi 3g file you wanto to convert.

After run, three grid files will be created. One is the grid
corresponding to the 3g data file, the other is the ndvi grid extracted from the 3g data file, and the last one is its associated flag grid.

Files included with this code:

  • convert_ndvi3g_ascii.m, the main matlab script
  • geo82dec15a.n07-VI3g, example avhrr ndvi 3g file
  • geo82dec15a.n07-VI3g.asc, ascii grid file corresponding to geo82dec15a.n07-VI3g
  • geo82dec15a.n07-VI3g.ndvi.asc, ascii grid file of the extracted ndvi
  • geo82dec15a.n07-VI3g.flag.asc, grid file of associated flags
  • header.txt, esri grid header information, used in code
  • Readme.txt, this file.

The meaning of the FLAG:
FLAG = 7 (missing data)
FLAG = 6 (NDVI retrieved from average seasonal profile, possibly snow)
FLAG = 5 (NDVI retrieved from average seasonal profile)
FLAG = 4 (NDVI retrieved from spline interpolation, possibly snow)
FLAG = 3 (NDVI retrieved from spline interpolation)
FLAG = 2 (Good value)
FLAG = 1 (Good value)

Nov 3, 2014
Fix bugs that wrongly computing ndvi.asc and flag.asc

Sep 11, 2014
Initial version

Download codes (9,875KB); Link2 (Baidu)

78ae077b84d7455913382971da7731ef  soft.ndvi3g.11032014.zip

Download codes (6,483KB)

MD5:  006d2d630a5c94f3ca629fc9f751d7f1  soft.ndvi3g.zip

用ArcGIS读取GIMMS AVHRR NDVI 3g 数据

用ArcGIS读取GIMMS AVHRR NDVI 3g 数据

giscn@msn.com

这个第三代NDVI数据,文件名类似于geo82dec15a.n07-VI3g ,增加.bsq扩展名,比如geo82dec15a.n07-VI3g.bsq。

然后建立一新文件,文件名与ndvi文件名一致(不包括.bsq),扩展名为 .hdr,如geo82dec15a.n07-VI3g.hdr。把此.hdr与nvdi文件放在一起。.hdr是个文本文件,内容包括:

nrows 4320

ncols 2160

nbands 1

nbits 16

pixeltype SIGNEDINT

byteorder M

layout bsq

在arcgis里就可以以栅格的形式打开。不过遗憾的是,由于ndvi 3G文件好像写数据的次序与arcgis不一样,所以读出来是倒置的。

在ArcGIS里做一个栅格transpose rotate,就是正确的图像。然后增加正确的坐标信息,在正确位置下,坐标信息如下:

upper-left-lat: 90.0-1/24

    upper-left-lon: -180.0+1/24

    lower-right-lat: -90.0+1/24

    lower-right-lon: 180.0-1/24

Geographic Lat/Lon

    pixel-size: 1/12=0.0833 degrees

因ndvi3g读过来的数据中包括flag信息。用raster algebra计算ndvi时,用以下公式,

ndvi = rounddown(ndvi3g / 10) / 1000

标志flag

flagW = ndvi3g – rounddown(ndvi3g / 10) * 10 + 1

(注意栅格运算时,操作符之间是必要有空格的。)

标志含义

The meaning of the FLAG:

    FLAG = 7 (missing data)

    FLAG = 6 (NDVI retrieved from average seasonal profile, possibly snow)

    FLAG = 5 (NDVI retrieved from average seasonal profile)

    FLAG = 4 (NDVI retrieved from spline interpolation, possibly snow)

    FLAG = 3 (NDVI retrieved from spline interpolation)

    FLAG = 2 (Good value)

    FLAG = 1 (Good value)

由于Arcgis需要多个操作,建议用Matlab或别的编程语言自己写点代码来处理。