Skip to content
Snippets Groups Projects
Commit 91232d61 authored by Simon Dreutter's avatar Simon Dreutter
Browse files

Delete 1_process_add_backup2.py

parent 874680c4
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
"""
####################################################################
# #
# AWI Basemap #
# PROCESS ANTARCTIC DIGITAL DATANASE DATA #
# #
####################################################################
This script is processing the Antarctic Digital Database (ADD) input
for the AWI Basemap. Input layers are the ADD coastlines and the ADD
rock outcrops. Both layers are reprojected to a global CRS
(EPSG_WORLD), coastlines are separated by shelf ice and ice sheet,
and the rock outcrop geometries are fixed.
"""
#=============================================================================
# SCRIPT INFO
#=============================================================================
__author__ = 'Simon Dreutter'
__version__ = '0.1'
__date__ = '2020-12-17'
__email__ = 'simon.dreutter@awi.de'
__status__ = 'Developement'
#=============================================================================
# IMPORT
#=============================================================================
# import standard libraries
import os
# import AWI Basemap configuration
from config import *
#=============================================================================
# PROCESS
#=============================================================================
EPSG_ADD = 'EPSG:3031'
# name of geometry column
geometry = 'geometry'
# layer names
add_coastline_in_name = os.path.splitext(os.path.basename(ADD_COASTLINE_IN))[0]
add_coastline_land_name = os.path.splitext(os.path.basename(ADD_COASTLINE_LAND))[0]
add_shelf_ice_name = os.path.splitext(os.path.basename(ADD_SHELF_ICE))[0]
#add_rock_outcrop_in_name = os.path.splitext(os.path.basename(ADD_ROCK_OUTCROP_IN))[0]
add_rock_outcrop_in_name = 'add_rock_outcrop_medium_res_polygon_v7' # inconsistancy with add layer names
add_rock_outcrop_name = os.path.splitext(os.path.basename(ADD_ROCK_OUTCROP))[0]
add_rock_outcrop_fixed_name = os.path.splitext(os.path.basename(ADD_ROCK_OUTCROP_FIXED))[0]
msg = 'Reprojecting and extracting land mask from ADD coastlines...'
cmd = f'ogr2ogr -s_srs {EPSG_ADD} -t_srs {EPSG_WORLD} -wrapdateline -nln "{add_coastline_land_name}" -nlt MULTIPOLYGON -f "ESRI Shapefile" -overwrite {ADD_COASTLINE_LAND} {ADD_COASTLINE_IN} -dialect SQLite -sql "SELECT ST_Multi(geom) from \'{add_coastline_in_name}\' WHERE surface=\'land\'"'
run(msg,cmd)
msg = 'Reprojecting and extracting ice mask from ADD coastlines...'
cmd = f'ogr2ogr -s_srs {EPSG_ADD} -t_srs {EPSG_WORLD} -wrapdateline -nln "{add_shelf_ice_name}" -nlt MULTIPOLYGON -f GPKG -overwrite {ADD_SHELF_ICE} {ADD_COASTLINE_IN} -dialect SQLite -sql "SELECT ST_Multi(geom) from \'{add_coastline_in_name}\' WHERE surface IN (\'ice shelf\',\'rumple\',\'ocean\',\'ice tongue\')"'
run(msg,cmd)
msg = 'Reprojecting and fixing ADD rock outcrops...'
cmd = f'ogr2ogr -s_srs {EPSG_ADD} -t_srs {EPSG_WORLD} -wrapdateline -nln "{add_rock_outcrop_name}" -nlt MULTIPOLYGON -f "ESRI Shapefile" -overwrite {ADD_ROCK_OUTCROP} {ADD_ROCK_OUTCROP_IN} -dialect SQLite -sql "SELECT ST_Buffer(ST_Multi(geom),0.0) from \'{add_rock_outcrop_in_name}\'"'
run(msg,cmd)
msg = 'Cutting rock outcrops from ice sheet...'
cmd = f'ogr2ogr -dialect SQLite -sql "select ST_Difference(a.{geometry}, ST_Simplify(b.{geometry},500)) as {geometry} from {add_coastline_land_name} as a, \'{ADD_ROCK_OUTCROP}\'.{add_rock_outcrop_name} as b" -overwrite -f GPKG {ADD_ICE_SHEET} {ADD_COASTLINE_LAND}'
run(msg,cmd)
#msg = 'Fixing ADD rock outcrops geometries...'
#cmd = f'ogr2ogr -dialect sqlite -sql "SELECT ST_Buffer({geometry}, 0.0) AS {geometry},* FROM \"{add_rock_outcrop_name}\"" -nln "{add_rock_outcrop_fixed_name}" -overwrite -f "ESRI Shapefile" {ADD_ROCK_OUTCROP_FIXED} {ADD_ROCK_OUTCROP}'
#run(msg,cmd)
#msg = 'Cutting rock outcrops from ice sheet...'
#cmd = f'ogr2ogr -dialect SQLite -sql "select ST_Difference(a.{geometry}, ST_Simplify(b.{geometry},500)) as {geometry} from {add_coastline_land_name} as a, \'{ADD_ROCK_OUTCROP_FIXED}\'.{add_rock_outcrop_fixed_name} as b" -overwrite -f "ESRI Shapefile" {ADD_ICE_SHEET} {ADD_COASTLINE_LAND}'
#run(msg,cmd)
#=============================================================================
# TODO
#=============================================================================
"""
- find a scripted solution for 'Difference'
- once found, add cleanup
"""
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment