## GPT Cookbook: WriteImage

Creates an image file from an input source file.

Example 1 Simple Image

This creates a simple image with a default color palette applied with range based on data statistics.

Command Line Entry

    gpt WriteImage.xml -p WriteImageEx01.par -Ssource=V20172132017243.L3m_MO_SNPP_CHL_chlor_a_9km.nc -PfilePath=WriteImageEx01.png

File = WriteImage.xml

    <graph id="someGraphId">
      <version>1.0</version>
      <node id="someNodeId">
        <operator>WriteImage</operator>
        <sources>
          <source>${source}</source>
        </sources>
        <parameters>
          <sourceBandName>${sourceBandName}</sourceBandName>
          <filePath>${filePath}</filePath>
          <formatName>${formatName}</formatName>
          <level>${level}</level>
        </parameters>
      </node>
    </graph>

File = WriteImageEx01.par

    sourceBandName=chlor_a
    formatName=png
    level=0

Example 2 Image with Color Palette

This creates an image with a color palette applied.

Command Line Entry

    gpt WriteImagePalette.xml -p WriteImageEx02.par -Phome=$HOME -Ssource=V20172132017243.L3m_MO_SNPP_CHL_chlor_a_9km.nc -PfilePath=WriteImageEx02.png

File = WriteImagePalette.xml

    <graph id="someGraphId">
      <version>1.0</version>
      <node id="someNodeId">
        <operator>WriteImage</operator>
        <sources>
          <source>${source}</source>
        </sources>
        <parameters>
          <sourceBandName>${sourceBandName}</sourceBandName>
          <filePath>${filePath}</filePath>
          <formatName>${formatName}</formatName>
          <cpdFilePath>${home}/${cpdFilePath}</cpdFilePath>
          <cpdAutoDistribute>${cpdAutoDistribute}</cpdAutoDistribute>
          <colourScaleMin>${colourScaleMin}</colourScaleMin>
          <colourScaleMax>${colourScaleMax}</colourScaleMax>
          <level>${level}</level>
          <scaleType>${scaleType}</scaleType>
        </parameters>
      </node>
    </graph>

File = WriteImageEx02.par

    sourceBandName=chlor_a
    formatName=png
    cpdFilePath=.seadas/beam-ui/auxdata/color-palettes/universal_bluered.cpd
    cpdAutoDistribute=false
    colourScaleMin=0.01
    colourScaleMax=20.0
    level=0
    scaleType=log

Example 3 Image with Color Palette and Land Mask

This is a very special case example. In the example use a separate land file in order to create a mask. The separate mask file must be the exact dimensions of the source file. Also the source file must not already contain masks.

Command Line Entry

    gpt WriteImageMask.xml -p WriteImageEx03.par -Phome=$HOME -Ssource=V20172132017243.L3m_MO_SNPP_CHL_chlor_a_9km.nc -PfilePath=WriteImageEx03.png

File = WriteImageMask.xml

    <graph id="someGraphId">
      <version>1.0</version>
      <node id="someNodeId">
        <operator>WriteImage</operator>
        <sources>
          <source>${source}</source>
        </sources>
        <parameters>
          <sourceBandName>${sourceBandName}</sourceBandName>
          <filePath>${filePath}</filePath>
          <formatName>${formatName}</formatName>
          <cpdFilePath>${home}/${cpdFilePath}</cpdFilePath>
          <cpdAutoDistribute>${cpdAutoDistribute}</cpdAutoDistribute>
          <colourScaleMin>${colourScaleMin}</colourScaleMin>
          <colourScaleMax>${colourScaleMax}</colourScaleMax>
          <level>${level}</level>
          <scaleType>${scaleType}</scaleType>

          <maskFilePath>${home}/${maskFilePath}</maskFilePath>
          <maskLayer>true</maskLayer>
          <imageMasks>
            <imageMask>
              <imageMaskSourceBandName>water_fraction</imageMaskSourceBandName>
              <imageMaskName>LandMask</imageMaskName>
              <imageMaskDescription>Land Mask</imageMaskDescription>
              <imageMaskExpression>water_fraction == 0</imageMaskExpression>
              <imageMaskColor>51,51,51</imageMaskColor>
              <imageMaskTransparency>0.0</imageMaskTransparency>
            </imageMask>
          </imageMasks>

        </parameters>
      </node>
    </graph>

File = WriteImageEx03.par

    sourceBandName=chlor_a
    formatName=png
    cpdFilePath=.seadas/beam-ui/auxdata/color-palettes/universal_bluered.cpd
    maskFilePath=Desktop/GptExamples/help/WriteImage/V20172132017243.L3m_LAND_9km.dim
    cpdAutoDistribute=false
    colourScaleMin=0.01
    colourScaleMax=20.0
    level=0
    scaleType=log