span8
span4
span8
span4
Start:Tutorial: Reading and Transforming Satellite Imagery in FME
This is the last part of theReading and Transforming Satellite Imagery in FME tutorial.This exercise is fairly advanced.It will cover bit masks,bitshift and logical operations.Here we will take a look at some of the supplementary information which is collected and calculated by Landsat to help with the data quality assessment (QA).You can read more about working with Landsat's QA in thisguide from Landsat.
Start by downloading and extracting LandsatMask.zip.Inspect LC80470252014258LGN00_BQA.TIF in the Data Inspector.Alternately,used what you've already learned in previous exercises to find your own Landsat QA raster (either with the Landsat-8 on AWS reader of theLandsat Sentinel Selector).Inspect the pixel values and note that the values are discreet,similar to what we created in the previous palette exercise,however,you should also notice that there is no palette.
The integer numbers here are really just representations of binary strings where each 0 or 1 (or pair) has a specific meaning.
Using a simple 4-bit example:
Integer - Binary String 0 - 0000 1 - 0001 2 - 0010 3- 0011 4 - 0100
We can say,for the example,that the first bit (0 or 1) from the right represents:
Data Present: 0 = nodata,1 = data,the second bit can mean snow,the third - cloud,the fourth - water.
If we look at the integer '3' above we can say the following based on the 0011 binary sting: Going from right to left - Yes we have data (1),yes,there is snow detected (1),no clouds (0) and no water (0).
Here is a handy online service which canconvert decimal to binary and back.Try using it with a few of the pixel values from the QA image.
1) Add the mask file,LC80470252014258LGN00_BQA.TIF,to workbench using the GeoTiff reader (for faster processing you can use the .ovr file)
2) Add a RasterInterpretationCoercer to convert the GREY16 band to UINT16
3) Add an UINTasBINPaletteAdder custom transformer from FME Hub
4) Right click on the UINTasBINPaletteAdder and click edit to see what it does,there is a lot here,but in particular take a look at AttributeCreator_7.Here we see a pretty scary looking expression:
@Evaluate(@Evaluate((@int64(@Value(_elevation))>>15)&1)@Evaluate((@int64(@Value(_elevation))>>14)&1)@Evaluate((@int64(@Value(_elevation))>>13)&1)@Evaluate((@int64(@Value(_elevation))>>12)&1)@Evaluate((@int64(@Value(_elevation))>>11)&1)@Evaluate((@int64(@Value(_elevation))>>10)&1)@Evaluate((@int64(@Value(_elevation))>>9)&1)@Evaluate((@int64(@Value(_elevation))>>8)&1)@Evaluate((@int64(@Value(_elevation))>>7)&1)@Evaluate((@int64(@Value(_elevation))>>6)&1)@Evaluate((@int64(@Value(_elevation))>>5)&1)@Evaluate((@int64(@Value(_elevation))>>4)&1)@Evaluate((@int64(@Value(_elevation))>>3)&1)@Evaluate((@int64(@Value(_elevation))>>2)&1)@Evaluate((@int64(@Value(_elevation))>>1)&1)@Evaluate((@int64(@Value(_elevation))&1)))
While it looks scary it is actually a concatenation of very simple expressions which usebit-wise operations.Taking one part of this as an example we can find the following:
@Value(_elevation))>>3)&1
_elevation in this case is our pixel value for this example let's say we have 216.This corresponds to a binary value of ‘11011000' (You can check this with the converter above).
The next part (216 >> 3) performs alogical bitwise right shift operationwhich shifts the binary to the right three places so 11011000 (or decimal 216) becomes 00011011 (or decimal 27).
The final part (27 & 1) compares the binary strings of each using thebit-wise Logical AND operation.We compare 11011 (27 without the leading 0's) to 00001.This results in a value of 00001 (or just 1 without the leading 0's).
Putting all of the expressions together we get either a 0 or a 1 for each of the 16 expressions,the concatenated result is the binary string of the original pixel value.The binary number is then passed into a StingFormatter witch pads the number out to 16 digits by creating leading 0's where needed.
NOTE:For a simple example you can check out suppl_SimpleBitshift&LogicalOperations.fmw.Experiment with this workspace and use the online binary converter to check the results.Try testing out some of the other bit-wise Logical operators to see how they work (- & | ^ ~).
Each bit represents the following:
You can also check out thispdf guide from Landsatfor more information for more information on how to interpret the bits.
5) Inspect the mask with palette and analyze what some of the strings mean.Connect an inspector and/or logger to the Custom transformer and run the process (the log window will show the palette).
6) Let's add some color to this.Add an AttributeCreator,and create a palette by copying the following text or typing RGB triads for some values:
RGB241 0,0,020480 0,0,020512 0,255,020516 200,200,25523552 127,127,12728672 255,127,25528704 255,127,25536864 127,127,12736896 0,255,039936 127,127,12745056 255,127,25553248 255,127,053280 255,127,061440 255,127,0
7) Add the palette with RasterPaletteAdder,run,and inspect the results,edit and experiment with a few values to show the difference.Compare the mask with the preview image to see how accurate the QC band is.Your final output should look something like this:
Processed Bit Mask:In the feature information window on the right we can see that the raster has two palettes,one containing the binary string and once with the RGB colors we created.The majority of the image is green which corresponds to a high confidence of vegetation,we also see some detection of snow or ice represented by the greys and in the top right region we can see some pink which represents the presence of Cirrus clouds.
The final workspace should look something like this.You can also open up LandsatMask.fmw from within the .zip to check the parameters.
Comparing Rasters of Different Formats and Structures
Working with Raster Readers for Satellite Imagery
Making RGB Images with Sentinel Data
Tutorial: Reading and Transforming Satellite Imagery in FME
Raster Calculations and Raster Palettes
Raster to Raster Translation (Geotiff to JPEG) with Reprojection
How To Optimize Your Raster Data Using the RasterInterpretationCoercer
Elevation Zoning Scenario - Reclassify Rasters Using the RasterExpressionEvaluator
© 2019 亚搏在线Safe Software Inc |Legal