-
Simon Dreutter authoredSimon Dreutter authored
3_process_glims.py 2.48 KiB
# -*- coding: utf-8 -*-
"""
####################################################################
# #
# AWI Basemap #
# PROCESS GLOBAL LAND ICE MEASUREMENTS FROM SPACE DATA #
# #
####################################################################
This script is processing the Global Land Ice Measurements from
Space (GLIMS) input for the AWI Basemap. The GLIMS geometries are
fixed (with zero buffer) and the global dataset is clipped for the
Arctic and the Antarctic.
"""
#=============================================================================
# SCRIPT INFO
#=============================================================================
__author__ = 'Simon Dreutter'
__version__ = '0.1'
__date__ = '2020-12-17'
__email__ = 'simon.dreutter@awi.de'
__status__ = 'Developement'
#=============================================================================
# IMPORT
#=============================================================================
import os
# import AWI Basemap configuration
from config import *
#=============================================================================
# PROCESS
#=============================================================================
# layer names
glims_in_name = os.path.splitext(os.path.basename(GLIMS_IN))[0]
glims_world_name = os.path.splitext(os.path.basename(GLIMS_WORLD))[0]
glims_arctic_name = os.path.splitext(os.path.basename(GLIMS_ARCTIC))[0]
glims_antarctic_name = os.path.splitext(os.path.basename(GLIMS_ANTARCTIC))[0]
# heading
print()
print('============================================================')
print(' GLOBAL LAND ICE MEASUREMENTS FROM SPACE / GLIMS ')
msg = 'Fixing GLIMS geometries...'
cmd = f'ogr2ogr {GLIMS_WORLD} {GLIMS_IN} -dialect sqlite -sql "SELECT ST_Buffer(geometry, 0.0) AS geometry,* FROM \"{glims_in_name}\"" -nln "{glims_world_name}" -f "GPKG"'
run(msg,cmd)
msg = 'Clipping GLIMS for the Arctic...'
cmd = f'ogr2ogr -spat -180.0 90.0 180.0 {ARCTIC_EXTENT_LAT} -clipsrc spat_extent {GLIMS_ARCTIC} {GLIMS_WORLD} {glims_world_name} -nln "{glims_arctic_name}" -f "GPKG"'
run(msg,cmd)
msg = 'Clipping GLIMS for the Antarctic...'
cmd = f'ogr2ogr -spat -180.0 {ANTARCTIC_EXTENT_LAT} 180.0 -90.0 -clipsrc spat_extent {GLIMS_ANTARCTIC} {GLIMS_WORLD} {glims_world_name} -nln "{glims_antarctic_name}" -f "GPKG"'
run(msg,cmd)