span8
span4
开始:Tutorial: Reading and Transforming Satellite Imagery in FME| Next:Raster bit Masks: Making Sense of the Numbers
This article is also part of the tutorialHow Do I Do That in FME|Next: Neighborhood Functions
This article is part of theTutorial: Reading and Transforming Satellite Imagery in FME
In this article we will be calculating theNormalized Difference Vegetation Index (NDVI).In the process,we will learn how to build conditions in the RasterExpressionEvaluator as well as how to create rasters with palettes.NDVI is based on the ability of plants to consume visible light radiation for photosynthesis (mostly in blue and red parts of the spectrum,this is why we see our plants mostly green,this color is mostly reflected).近红外光,on the other hand,cannot cause the proper reaction in cells,and hence,is being reflected (otherwise it will overheat the plants).反射的红外光越多,消耗的红光越多,the healthier the plant is.
This article assumes you have completed the previous article in the tutorial:Making RGB images with Sentinel data.If you have not,please complete the exercise in the first part of the article to download the appropriate images.
Completed workspace (without source data):create-palettes.fmw
1) Create a new workspace and call it NDVICalculator.
2)添加一个jpeg 2000阅读器,并选择红色和近红外波段(b04和b08)的预览图像。参数下,be sure the Feature Type Name is set to 'From File Name'
3)首先添加RasteExpressionEvaluator,set Mode to 'Two Rasters'.红色带应进入“A”端口,NIR应进入“B”端口。使用auto进行解释和表达,use:
(B[0]-A[0])/(B[0]+A[0])
RASTERExpressionEvaluator公司:This expression calculates the NDVI which is a ratio of reflected NIR to reflected Red light.
4) Run,inspect results,notice now that the band ranges of the resulting pixels falls between -1 and 1 and our interpretation has changed to REAL64.
5)添加另一个RasteExpressionEvaluator。In the evaluator set the interpretation to UINT8 and copy and paste the following for the expression:
if(A[0]<=0,0,if(A[0]<=0.3,1,if(A[0]<=0.6,2,3)))
RasterExpressionEvaluator_2:here we use a series of nested ‘if' functions to build a conditional expression to begin building our palette based on our calculated NDVI.This will keep only four raster values - 0,1,2 and 3
6) Add an AttributeCreator and use the text editor to create a _palette attribute as is shown below.下面的颜色是,海军蓝黄色的,bright green and dark green but you can set the RGB triads to what you think is appropriate:
RGB240 0,0,641 255,255,02 0,255,03 0,127,0
_palette Attribute:Here we are defining the interpretation of the palette as RGB24 and are assigning each of the integers from 0 - 3 a RGB color.
7)添加rasterpaletteadder并将调色板添加到光栅
8) Run and inspect results,它应该是这样的:
Final Image:You will likely have a different image to what is seen here,but make sure you take note of the palette information displayed in the Feature Information window
The final workspace should look like this:
Final Workspace:你有不同的东西吗?Download the final workspace at the top of this article to compare
© 2019 亚搏在线Safe Software Inc |Legal