GPT Cookbook: Mosaic


Creates a mosaic file from any number of input source files.

Note: when processing a large number of files with the Mosaic tool you may likely need to increase your memory allocation. To do this edit the file gpt.sh.


Example 1  Geographic Lat/Lon Projection

Example 2  Oblique Stereographic Projection

Example 3  Lambert Azimuthal Equal Area Projection

Example 4  Lambert Azimuthal Equal Area Projection (alternate)

Example 5  Lambert Azimuthal Equal Area Projection of Full OC Suite L2 File


Notes 1  Resampling Options








Example 1: Geographic Lat/Lon Projection


This uses the SeaDAS Mosaic tool in GPT (command line) mode to combine several input level-2 files into a single mapped output file. The level-2 files were imaged January 23 2017 over the Gulf of Mexico by both the VIIRS and the MODIS Aqua instruments. The output file is specifically geographically bounded to this Gulf of Mexico region. Level-2 quality flags are used to constrain the source pixels being used. Two products are created: chlor_a and apparent_optical_depth. The product chlor_a exists in the source level-2 files and the product apparent_optical_depth is derived using a mathematical expression from the level-2 product Kd_490. The projection is standard geographic lat/lon with a pixelSize=0.009 (roughly 1km resolution). A parameter properties "par" file is used to store the variables needed for the xml graph file.

Note: you can readily modify these parameters in this "par" file to adapt to your own specific region, products, and quality criteria.

Note: the Mosaic GPT call acquires the input files from individual arguments in the command line. A convenience system call (`cat level2Files.txt`) is used here instead of entering each file as a command line argument.


Command Line Entry

gpt MosaicGeneralGraph.xml -p MosaicEx01.par `cat level2Files.txt` -Pofile=AquaVIIRS_2017023_MosaicEx01.dim

File = MosaicGeneralGraph.xml

<graph id="MosaicGraph">
  <version>1.0</version>

  <node id="MosaicNode">
    <operator>Mosaic</operator>
    <sources>
       <sourceProducts>${sourceProducts}</sourceProducts>
    </sources>

    <parameters>
        <variables>
            <variable>
                <name>${band1}</name>
                <expression>${band1Expression}</expression>
            </variable>
            <variable>
                <name>${band2}</name>
                <expression>${band2Expression}</expression>
            </variable>
        </variables>
        <conditions>
            <condition>
                <name>condition_0</name>
                <expression>${qualityExpression}</expression>
                <output>false</output>
            </condition>
        </conditions>
        <combine>OR</combine>
        <crs>${crs}</crs>
        <resampling>${resampling}</resampling>
        <westBound>${west}</westBound>
        <northBound>${north}</northBound>
        <eastBound>${east}</eastBound>
        <southBound>${south}</southBound>
        <pixelSizeX>${pixelSize}</pixelSizeX>
        <pixelSizeY>${pixelSize}</pixelSizeY>
    </parameters>

  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
        <sourceProduct refid="MosaicNode"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
        <file>${ofile}</file>
        <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>
</graph>

File = MosaicEx01.par

band1=chlor_a
band1Expression=chlor_a
band2=apparent_optical_depth
band2Expression=if (Kd_490 != 0) then 1.3/Kd_490 else NaN
qualityExpression=!l2_flags.HIGLINT and !l2_flags.HISATZEN and !l2_flags.LOWLW and !l2_flags.HILT
north=31.0
south=17.5
west=-98.5
east=-80.0
pixelSize=0.009
resampling=Nearest
crs=GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]

File = level2Files.txt

level2_files/A2017023193000.L2_LAC_OC.nc
level2_files/A2017023193500.L2_LAC_OC.nc
level2_files/V2017023190000.L2_SNPP_OC.nc
level2_files/V2017023190600.L2_SNPP_OC.nc




Example 2: Oblique Stereographic Projection


This is exactly the same as example 1 except that it uses a Oblique Stereographic projection. (See example 1 for the files "mosaicGeneral.xml" and "level2Files.txt".)

Note: if you modify this to cover a different region you will also have to modify the crs value (specifically "latitude_of_origin" and "central_meridian"). Also, the pixelSize is in units of meters whereas in example 1 is was in units of degrees.


Command Line Entry

gpt MosaicGeneralGraph.xml -p MosaicEx02.par `cat level2Files.txt` -Pofile=AquaVIIRS_2017023_MosaicEx02.dim

File = Mosaic02.par

band1=chlor_a
band1Expression=chlor_a
band2=apparent_optical_depth
band2Expression=1.3/Kd_490
qualityExpression=!l2_flags.HIGLINT and !l2_flags.HISATZEN and !l2_flags.LOWLW and !l2_flags.HILT and !l2_flags.CLDICE
north=31.0
south=17.5
west=-98.5
east=-80.0
pixelSize=1000.0
resampling=Nearest
crs=PROJCS["Oblique_Stereographic / World Geodetic System 1984",GEOGCS["World Geodetic System 1984", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]], PROJECTION["Oblique_Stereographic"], PARAMETER["central_meridian", -90.0], PARAMETER["latitude_of_origin", 25.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH]]




Example 3: Lambert Azimuthal Equal Area Projection


This is exactly the same as example 1 except that it uses a Lambert Azimuthal Equal-Area projection. (See example 1 for the files "mosaicGeneral.xml" and "level2Files.txt".)

Note: if you modify this to cover a different region you will also have to modify the crs value (specifically "latitude_of_center" and "longitude_of_center"). Also, the pixelSize is in units of meters whereas in example 1 is was in units of degrees.


Command Line Entry

gpt MosaicGeneralGraph.xml -p MosaicEx03.par `cat level2Files.txt` -Pofile=AquaVIIRS_2017023_MosaicEx03.dim

File = MosaicEx03.par

band1=chlor_a
band1Expression=chlor_a
band2=apparent_optical_depth
band2Expression=1.3/Kd_490
qualityExpression=!l2_flags.HIGLINT and !l2_flags.HISATZEN and !l2_flags.LOWLW and !l2_flags.HILT
north=31.0
south=17.5
west=-98.5
east=-80.0
pixelSize=1000.0
resampling=Nearest
crs=PROJCS["Lambert_Azimuthal_Equal_Area / World Geodetic System 1984",GEOGCS["World Geodetic System 1984",DATUM["World Geodetic System 1984",SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],UNIT["degree", 0.017453292519943295],AXIS["Geodetic longitude", EAST],AXIS["Geodetic latitude", NORTH]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_center", 25.0],PARAMETER["longitude_of_center", -90.0],PARAMETER["false_easting", 0.0],PARAMETER["false_northing", 0.0],UNIT["m", 1.0],AXIS["Easting", EAST],AXIS["Northing", NORTH]]




Example 4: Lambert Azimuthal Equal Area Projection (alternate)


This is basically the same as example 3 except that the crs if defined in the xml graph file with some added variables in order to specify the center of the scene in the "par" file. If you are always using the same projection, but for differing regions this example is a good choice. One other difference here, to illustrate an option, that the same variable is used for convenience for both the band name and the band expression. If you are not creating new bands using a mathematical expression then condensing these two variables into a single variable works.


Command Line Entry

gpt MosaicGraphEx04.xml -p MosaicEx04.par `cat level2Files.txt` -Pofile=AquaVIIRS_2017023_MosaicEx04.dim

File = MosaicGraphEx04.xml

<graph id="MosaicLambertGraph">
  <version>1.0</version>

  <node id="MosaicLambertNode">
    <operator>Mosaic</operator>
    <sources>
       <sourceProducts>${sourceProducts}</sourceProducts>
    </sources>

    <parameters>
        <variables>
            <variable>
                <name>${band1}</name>
                <expression>${band1}</expression>
            </variable>
            <variable>
                <name>${band2}</name>
                <expression>${band2}</expression>
            </variable>
        </variables>
        <conditions>
            <condition>
                <name>condition_0</name>
                <expression>${qualityExpression}</expression>
                <output>false</output>
            </condition>
        </conditions>
        <combine>OR</combine>
        <crs>
            PROJCS["Lambert_Azimuthal_Equal_Area / World Geodetic System 1984",
                    GEOGCS["World Geodetic System 1984",
                            DATUM["World Geodetic System 1984",
                                    SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],
                                    AUTHORITY["EPSG","6326"]],
                            PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
                            UNIT["degree", 0.017453292519943295],
                            AXIS["Geodetic longitude", EAST],
                            AXIS["Geodetic latitude", NORTH]],
                    PROJECTION["Lambert_Azimuthal_Equal_Area"],
                    PARAMETER["latitude_of_center", ${latitudeOfCenter}],
                    PARAMETER["longitude_of_center", ${longitudeOfCenter}],
                    PARAMETER["false_easting", 0.0],
                    PARAMETER["false_northing", 0.0],
                    UNIT["m", 1.0],
                    AXIS["Easting", EAST],
                    AXIS["Northing", NORTH]]
        </crs>
        <resampling>${resampling}</resampling>
        <westBound>${west}</westBound>
        <northBound>${north}</northBound>
        <eastBound>${east}</eastBound>
        <southBound>${south}</southBound>
        <pixelSizeX>${pixelSize}</pixelSizeX>
        <pixelSizeY>${pixelSize}</pixelSizeY>
    </parameters>

  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
        <sourceProduct refid="MosaicLambertNode"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
        <file>${ofile}</file>
        <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>
</graph>

File = MosaicEx04.par

band1=chlor_a
band2=Kd_490
qualityExpression=!l2_flags.HIGLINT and !l2_flags.HISATZEN and !l2_flags.LOWLW and !l2_flags.HILT
latitudeOfCenter=25.0
longitudeOfCenter=-90.0
north=31.0
south=17.5
west=-98.5
east=-80.0
pixelSize=1000.0
resampling=Nearest




Example 5: Lambert Azimuthal Equal Area Projection of Full OC Suite L2 File


Similar to example 3 except producing all bands of the OC suite.


Command Line Entry

gpt MosaicGraphEx05.xml -p MosaicEx05.par -Pifile=A2017023193500.L2_LAC_OC.nc -Pofile=A2017023193500_MosaicEx05.dim

File = MosaicGraphEx05.xml

<graph id="MosaicLambertGraph">
  <version>1.0</version>

  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
        <file>${ifile}</file>
        <formatName>SeaDAS-L2</formatName>
    </parameters>
  </node>

  <node id="Mosaic">
    <operator>Mosaic</operator>
    <sources>
        <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
        <variables>
            <variable>
                <name>${band1Name}</name>
                <expression>${band1Name}</expression>
            </variable>
            <variable>
                <name>${band2Name}</name>
                <expression>${band2Name}</expression>
            </variable>
            <variable>
                <name>${band3Name}</name>
                <expression>${band3Name}</expression>
            </variable>
            <variable>
                <name>${band4Name}</name>
                <expression>${band4Name}</expression>
            </variable>
            <variable>
                <name>${band5Name}</name>
                <expression>${band5Name}</expression>
            </variable>
            <variable>
                <name>${band6Name}</name>
                <expression>${band6Name}</expression>
            </variable>
            <variable>
                <name>${band7Name}</name>
                <expression>${band7Name}</expression>
            </variable>
            <variable>
                <name>${band8Name}</name>
                <expression>${band8Name}</expression>
            </variable>
            <variable>
                <name>${band9Name}</name>
                <expression>${band9Name}</expression>
            </variable>
            <variable>
                <name>${band10Name}</name>
                <expression>${band10Name}</expression>
            </variable>
            <variable>
                <name>${band11Name}</name>
                <expression>${band11Name}</expression>
            </variable>
            <variable>
                <name>${band12Name}</name>
                <expression>${band12Name}</expression>
            </variable>
            <variable>
                <name>${band13Name}</name>
                <expression>${band13Name}</expression>
            </variable>
            <variable>
                <name>${band14Name}</name>
                <expression>${band14Name}</expression>
            </variable>
            <variable>
                <name>${band15Name}</name>
                <expression>${band15Name}</expression>
            </variable>
            <variable>
                <name>${band16Name}</name>
                <expression>${band16Name}</expression>
            </variable>
            <variable>
                <name>${band17Name}</name>
                <expression>${band17Name}</expression>
            </variable>
            <variable>
                <name>${band18Name}</name>
                <expression>${band18Name}</expression>
            </variable>
            <variable>
                <name>${band19Name}</name>
                <expression>${band19Name}</expression>
            </variable>
            <variable>
                <name>${band20Name}</name>
                <expression>${band20Name}</expression>
            </variable>
        </variables>
        <conditions>
            <condition>
                <name>condition_0</name>
                <expression>${qualityExpression}</expression>
                <output>false</output>
            </condition>
        </conditions>
        <combine>OR</combine>
        <crs>
            PROJCS["Lambert_Azimuthal_Equal_Area / World Geodetic System 1984",
                    GEOGCS["World Geodetic System 1984",
                            DATUM["World Geodetic System 1984",
                                SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],
                                AUTHORITY["EPSG","6326"]],
                            PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
                            UNIT["degree", 0.017453292519943295],
                            AXIS["Geodetic longitude", EAST],
                            AXIS["Geodetic latitude", NORTH]],
                    PROJECTION["Lambert_Azimuthal_Equal_Area"],
                    PARAMETER["latitude_of_center", ${latitudeOfCenter}],
                    PARAMETER["longitude_of_center", ${longitudeOfCenter}],
                    PARAMETER["false_easting", 0.0],
                    PARAMETER["false_northing", 0.0],
                    UNIT["m", 1.0],
                    AXIS["Easting", EAST],
                    AXIS["Northing", NORTH]]
        </crs>
        <resampling>${resampling}</resampling>
        <westBound>${west}</westBound>
        <northBound>${north}</northBound>
        <eastBound>${east}</eastBound>
        <southBound>${south}</southBound>
        <pixelSizeX>${pixelSize}</pixelSizeX>
        <pixelSizeY>${pixelSize}</pixelSizeY>
    </parameters>

  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
        <sourceProduct refid="Mosaic"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
        <file>${ofile}</file>
        <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>
</graph>

File = MosaicEx05.par

band1Name=aot_869
band2Name=angstrom
band3Name=chlor_a
band4Name=chl_ocx
band5Name=ipar
band6Name=Kd_490
band7Name=nflh
band8Name=Rrs_412
band9Name=Rrs_443
band10Name=Rrs_469
band11Name=Rrs_488
band12Name=Rrs_531
band13Name=Rrs_547
band14Name=Rrs_555
band15Name=Rrs_645
band16Name=Rrs_667
band17Name=Rrs_678
band18Name=par
band19Name=pic
band20Name=poc

qualityExpression=!l2_flags.HIGLINT and !l2_flags.HISATZEN and !l2_flags.LOWLW and !l2_flags.HILT
latitudeOfCenter=25.0
longitudeOfCenter=-90.0
north=31.0
south=17.5
west=-98.5
east=-80.0
pixelSize=1000.0
resampling=Bilinear




Notes 1    Resampling Options


Here is a full list of the resampling options and their specific names as used by the Mosaic operator. Please be aware that these names differ for the Collocate operator. We will address this in a future SeaDAS release.

resampling=Nearest
resampling=Bilinear
resampling=Bicubic