MPI_reduce_ICESat2_ATL06_grounded.py

Source code

Calling Sequence

usage: MPI_reduce_ICESat2_ATL06_grounded.py [-h] [--directory DIRECTORY]
                                            [--area AREA] [--buffer BUFFER]
                                            [--verbose] [--mode MODE]
                                            file

Positional Arguments

file

ICESat-2 ATL06 file to run

Named Arguments

--directory, -D

Working data directory for mask files

--area, -A

Area in square kilometers for minimum polygon size

--buffer, -B

Distance in kilometers to buffer grounded ice mask

--verbose, -V

Verbose output of run

--mode, -M

Permissions mode of output files

Creating BedMachine grounded ice mask

# convert mask variable to separate geotiff
gdal_translate -co "COMPRESS=LZW" -a_srs EPSG:3413 \
    NETCDF:BedMachineGreenland-2021-04-20.nc:mask \
    -of 'Gtiff' BedMachineGreenlandMaskv4.tif

# create grounded ice mask (1=Greenland grounded, 0=other)
gdalwarp -co "COMPRESS=LZW" -srcnodata 1 -dstnodata 0 -ot Byte BedMachineGreenlandMaskv4.tif tmp1.tif
gdalwarp -co "COMPRESS=LZW" -srcnodata 4 -dstnodata 0 -ot Byte tmp1.tif tmp2.tif
gdalwarp -co "COMPRESS=LZW" -srcnodata 3 -dstnodata 0 -ot Byte tmp2.tif tmp3.tif
gdalwarp -co "COMPRESS=LZW" -srcnodata 2 -dstnodata 1 -ot Byte tmp3.tif tmp4.tif
gdalwarp -co "COMPRESS=LZW" -srcnodata 0 -dstnodata 0 -ot Byte tmp4.tif BedMachineGreenlandGroundedv4.tif
rm tmp*.tif

# create vectorized grounded ice mask
gdal_polygonize.py BedMachineGreenlandGroundedv4.tif tmp.shp
# add area attribute and convert units from m^2 to km^2
ogr2ogr BedMachineGreenlandGroundedv4.shp tmp.shp -sql "SELECT *, OGR_GEOM_AREA/1000000 AS area FROM tmp"
rm tmp.dbf tmp.prj tmp.shp tmp.shx