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

new RUN.py script and some minor code adjustments

parent 585f351b
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ The GPKG files `add_coastline_medium_res_polygon_v7.3.gpkg` and `add_rock_outcro
# 2. Adjust scripts
Most of the necessary adjustments are happening in `~/process/config.py`. There are two minor things that need adjustment in other scripts.
Most of the necessary adjustments are happening in `~/process/config.py`. There is one minor thing that might need adjustment in another script.
## 2.1 `~/process/config.py`
......@@ -54,16 +54,12 @@ After downloading the input data you need to make sure the input files in the co
The default settings for resolution (degree/meter), the z factor for shading and the extent of the polar grids are set here. If you want different settings, adjust the variables in this section. However, read the notes, expecially on resolution.
##### Operational Parameters
If your Python 3.x installation has a different executable than OSGeo4W (`python3`), adjust this here.
Some scripts call the Python executable which is set in `config.py` with `sys.executable`. If you need a specific Python 3.x executable, adjust it here.
## 2.2 `~/process/1_process_add.py`
Some of the vector processes require the GPKG layer names in their SQL commands. In ADD there is an inconsistency with the layer bames, which is why the layer name varibale for rock outcrops needs to be overwritten at the beginning of the process. In case this gets fixed or other incositencies arise in newer versions, make sure these are taken care of here.
## 2.3 `~/process/run.bat`
Again, if your Python 3.x executable is different to `python3`, adjust this at the beginning of the run script.
# 3. Run
Now run `~/process/run.bat` (or run all python scripts manually in order) and check the results, once finished.
The process is designed, so that all individual sub steps can be run separately. If you want to run everything at once, simply start`~/process/RUN.py` and check the results, once finished.
......@@ -32,7 +32,6 @@ __status__ = 'Developement'
# IMPORT
#=============================================================================
# import standard libraries
import os
# import AWI Basemap configuration
......
......@@ -30,7 +30,6 @@ __status__ = 'Developement'
# IMPORT
#=============================================================================
# import standard libraries
import os
# import AWI Basemap configuration
......
......@@ -31,7 +31,6 @@ __status__ = 'Developement'
# IMPORT
#=============================================================================
# import standard libraries
import os
# import AWI Basemap configuration
......
......@@ -31,7 +31,6 @@ __status__ = 'Developement'
# IMPORT
#=============================================================================
# import standard libraries
import os
# import AWI Basemap configuration
......@@ -52,9 +51,9 @@ glims_arctic_name = os.path.splitext(os.path.basename(GLIMS_ARCTIC))[0]
glims_antarctic_name = os.path.splitext(os.path.basename(GLIMS_ANTARCTIC))[0]
# burn values
v_rock_outcrops = 3000.0
v_shelf_ice = 20000.0
v_ice_sheet = 30000.0
V_ROCK_OUTCROPS = 3000.0
V_SHELF_ICE = 20000.0
V_ICE_SHEET = 30000.0
# heading
print()
......@@ -62,47 +61,47 @@ print('============================================================')
print(' BURN VECTOR LAYERS ')
msg = 'Burning Antarctic ice shelfs in World raster...'
cmd = f'gdal_rasterize -l {add_shelf_ice_name} -burn {v_shelf_ice} {ADD_SHELF_ICE} {GEBCO_WORLD}'
cmd = f'gdal_rasterize -l {add_shelf_ice_name} -burn {V_SHELF_ICE} {ADD_SHELF_ICE} {GEBCO_WORLD}'
run(msg,cmd)
msg = 'Burning Antarctic ice sheet in World raster...'
cmd = f'gdal_rasterize -l {add_ice_sheet_name} -burn {v_ice_sheet} {ADD_ICE_SHEET} {GEBCO_WORLD}'
cmd = f'gdal_rasterize -l {add_ice_sheet_name} -burn {V_ICE_SHEET} {ADD_ICE_SHEET} {GEBCO_WORLD}'
run(msg,cmd)
msg = 'Burning Antarctic rock outcrops in World raster...'
cmd = f'gdal_rasterize -l {add_rock_outcrop_name} -burn {v_rock_outcrops} -at {ADD_ROCK_OUTCROP} {GEBCO_WORLD}'
cmd = f'gdal_rasterize -l {add_rock_outcrop_name} -burn {V_ROCK_OUTCROPS} -at {ADD_ROCK_OUTCROP} {GEBCO_WORLD}'
run(msg,cmd)
msg = 'Burning Greenland ice sheet in World raster...'
cmd = f'gdal_rasterize -l {gimp_name} -burn {v_ice_sheet} {GIMP} {GEBCO_WORLD}'
cmd = f'gdal_rasterize -l {gimp_name} -burn {V_ICE_SHEET} {GIMP} {GEBCO_WORLD}'
run(msg,cmd)
msg = 'Burning glaciers in World raster...'
cmd = f'gdal_rasterize -l {glims_world_name} -burn {v_ice_sheet} {GLIMS_WORLD} {GEBCO_WORLD}'
cmd = f'gdal_rasterize -l {glims_world_name} -burn {V_ICE_SHEET} {GLIMS_WORLD} {GEBCO_WORLD}'
run(msg,cmd)
msg = 'Burning Greenland ice sheet in Arctic raster...'
cmd = f'gdal_rasterize -l {gimp_name} -burn {v_ice_sheet} {GIMP} {GEBCO_ARCTIC}'
cmd = f'gdal_rasterize -l {gimp_name} -burn {V_ICE_SHEET} {GIMP} {GEBCO_ARCTIC}'
run(msg,cmd)
msg = 'Burning glaciers in Arctic raster...'
cmd = f'gdal_rasterize -l {glims_arctic_name} -burn {v_ice_sheet} {GLIMS_ARCTIC} {GEBCO_ARCTIC}'
cmd = f'gdal_rasterize -l {glims_arctic_name} -burn {V_ICE_SHEET} {GLIMS_ARCTIC} {GEBCO_ARCTIC}'
run(msg,cmd)
msg = 'Burning Antarctic ice shelfs in Antarctic raster...'
cmd = f'gdal_rasterize -l {add_shelf_ice_name} -burn {v_shelf_ice} {ADD_SHELF_ICE} {GEBCO_ANTARCTIC}'
cmd = f'gdal_rasterize -l {add_shelf_ice_name} -burn {V_SHELF_ICE} {ADD_SHELF_ICE} {GEBCO_ANTARCTIC}'
run(msg,cmd)
msg = 'Burning Antarctic ice sheet in Antarctic raster...'
cmd = f'gdal_rasterize -l {add_ice_sheet_name} -burn {v_ice_sheet} {ADD_ICE_SHEET} {GEBCO_ANTARCTIC}'
cmd = f'gdal_rasterize -l {add_ice_sheet_name} -burn {V_ICE_SHEET} {ADD_ICE_SHEET} {GEBCO_ANTARCTIC}'
run(msg,cmd)
msg = 'Burning Antarctic rock outcrops in Antarctic raster...'
cmd = f'gdal_rasterize -l {add_rock_outcrop_name} -burn {v_rock_outcrops} -at {ADD_ROCK_OUTCROP} {GEBCO_ANTARCTIC}'
cmd = f'gdal_rasterize -l {add_rock_outcrop_name} -burn {V_ROCK_OUTCROPS} -at {ADD_ROCK_OUTCROP} {GEBCO_ANTARCTIC}'
run(msg,cmd)
msg = 'Burning glaciers in Antarctic raster...'
cmd = f'gdal_rasterize -l {glims_antarctic_name} -burn {v_ice_sheet} {GLIMS_ANTARCTIC} {GEBCO_ANTARCTIC}'
cmd = f'gdal_rasterize -l {glims_antarctic_name} -burn {V_ICE_SHEET} {GLIMS_ANTARCTIC} {GEBCO_ANTARCTIC}'
run(msg,cmd)
cleanup(ADD_SHELF_ICE)
......
......@@ -54,7 +54,7 @@ OVERVIEW_METHOD = 'cubic'
#=============================================================================
def create_basemap(map_params):
name,gebco,hs,cp,epsg,output = map_params
name, gebco, hs, cp, epsg, output = map_params
msg = f'Creating {name} RGB...'
cmd = f'gdaldem color-relief {gebco} {cp} {TMP_RGB} -of GTiff -b 1 -compute_edges {GDAL_CREATE_OPTIONS}'
run(msg,cmd)
......
# -*- coding: utf-8 -*-
"""
####################################################################
# #
# AWI Basemap #
# RUN THE ENTIRE PROCESS #
# #
####################################################################
"""
#=============================================================================
# SCRIPT INFO
#=============================================================================
__author__ = 'Simon Dreutter'
__version__ = '0.1'
__date__ = '2021-05-19'
__email__ = 'simon.dreutter@awi.de'
__status__ = 'Developement'
#=============================================================================
# IMPORT
#=============================================================================
import subprocess
import sys
# import AWI Basemap configuration
from config import PYTHON
#=============================================================================
# RUN
#=============================================================================
cmd = [PYTHON, '1_process_add.py']
subprocess.call(cmd)
cmd = [PYTHON, '2_process_gimp.py']
subprocess.call(cmd)
cmd = [PYTHON, '3_process_glims.py']
subprocess.call(cmd)
cmd = [PYTHON, '4_process_gebco.py']
subprocess.call(cmd)
cmd = [PYTHON, '5_create_shading_layers.py']
subprocess.call(cmd)
cmd = [PYTHON, '6_burn_vector_layers.py']
subprocess.call(cmd)
cmd = [PYTHON, '7_create_basemaps.py']
subprocess.call(cmd)
#=============================================================================
print()
print('All done!')
input('\nPress Enter to exit!\n')
sys.exit()
......@@ -39,9 +39,8 @@ __status__ = 'Developement'
# IMPORT
#=============================================================================
# import standard libraries
import os
import sys
#=============================================================================
# INPUT FOLDERS
......@@ -124,7 +123,7 @@ RESOLUTION_DEG = 0.008333333333333333
RESOLUTION_M = 1000.0
# GIMP Resolution
# half the GEBCO resolution
# half the grid resolution
GIMP_RESOLUTION = RESOLUTION_DEG / 2
# Hillshade z factor / vertical exaggeration
......@@ -243,7 +242,9 @@ EPSG_ANTARCTIC = 'EPSG:3031' # WGS 84 / Antarctic Polar Stereographic
# the final results, however, are specified in the last python script.
# Python executable
PYTHON = 'python3'
#PYTHON = 'python'
#PYTHON = 'python3'
PYTHON = sys.executable
# GDAL creation options
GDAL_CREATE_OPTIONS = '-co COMPRESS=NONE -co BIGTIFF=IF_NEEDED'
......
@echo off
rem PYTHON executable
set PYTHON=python3
%PYTHON% 1_process_add.py
%PYTHON% 2_process_gimp.py
%PYTHON% 3_process_glims.py
%PYTHON% 4_process_gebco.py
%PYTHON% 5_create_shading_layers.py
%PYTHON% 6_burn_vector_layers.py
%PYTHON% 7_create_basemaps.py
echo.
echo All done!
echo.
set /p DONE=Press Enter to exit!
echo.
\ 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