In waterresources management the sizing of reservoirs depend
In water-resources management, the sizing of reservoirs depends on accurate estimates of water flow in the river that is being impounded. For some rivers, long-term historical records of such flow data are difficult to obtain. In contrast, meteorological data on precipitation are often available for many years past. Therefore, it is often useful to determine a relationship between flow and precipitation. This relationship can then be used to estimate flows for years when only precipitation measurements were made.
The following data are available for a river that is to be dammed:
Precipitation (cm/yr)
Annual average flow (m3/s)
88.9
14.6
108.5
16.7
104.1
15.3
139.7
23.2
127
19.5
94
16.1
116.8
18.1
99.1
16.6
If the drainage area is 1100 km2, estimate using MATLAB what percent of the precipitation is lost via processes such as evaporation, deep groundwater infiltration, and consumptive use.
| Precipitation (cm/yr) | Annual average flow (m3/s) |
| 88.9 | 14.6 |
| 108.5 | 16.7 |
| 104.1 | 15.3 |
| 139.7 | 23.2 |
| 127 | 19.5 |
| 94 | 16.1 |
| 116.8 | 18.1 |
| 99.1 | 16.6 |
Solution
DEM_basename = \'Pozo_DTM_noveg_UTM11_NAD83\'; DEM_basename_no_underscore = strrep(DEM_basename,\'_\',\'\\_\');
area_threshold = 5e3;
min_drainage_area_to_process = 1e5;
min_dbasins_stats_to_process = 1e6;
stream_order = [2 3];
%a stream order of 4 (30-m DEM): 28-1100 km2 (mean: 200 km2)
relief_values_m = [10 25 50];
str_area1 = 1e6;
str_area2 = 1e6;
min_max_DA_fits = [1e5 1e8 100];
segL = 10;
min_str_gradient = 0.001;
MISC_FILES = 1;
REGEN = 0;
show_figs = 1;
PaperType_size = \'A4\';
min_trib_size = 100;
smoothing_window = 201;
sgolayfilt_order = 11;
lumping_search_distance = 125;min_kp_size1 = 1.5;
min_kp_size2 = 3;
min_kp_slope = 0.001;
if strcmp(computer_system, \'PCWIN64\')
if exist(\'C:\\OSGeo4W64\\bin\\gdalsrsinfo.exe\', \'file\') == 2
gdalsrsinfo_cmd = \'!C:\\OSGeo4W64\\bin\\gdalsrsinfo.exe\';
elseif exist(\'C:\\OSGeo4W\\bin\\gdalsrsinfo.exe\', \'file\') == 2
gdalsrsinfo_cmd = \'!C:\\OSGeo4W\\bin\\gdalsrsinfo.exe\';
else
fprintf(1,\'Can not find \'\'gdalsrsinfo\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
gdalsrsinfo_cmd = \'!C:\\OSGeo4W64\\bin\\gdalsrsinfo.exe\';
end
if exist(\'C:\\OSGeo4W64\\bin\\ogr2ogr.exe\', \'file\') == 2
ogr2ogr_cmd = \'!C:\\OSGeo4W64\\bin\\ogr2ogr.exe\';
elseif exist(\'C:\\OSGeo4W\\bin\\ogr2ogr.exe\', \'file\') == 2
ogr2ogr_cmd = \'!C:\\OSGeo4W\\bin\\ogr2ogr.exe\';
else
fprintf(1,\'Can not find \'\'ogr2ogr\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
ogr2ogr_cmd = \'!C:\\OSGeo4W64\\bin\\ogr2ogr.exe\';
end
if exist(\'C:\\OSGeo4W64\\bin\\gdaldem.exe\', \'file\') == 2
gdaldem_cmd = \'!C:\\OSGeo4W64\\bin\\gdaldem.exe\';
elseif exist(\'C:\\OSGeo4W\\bin\\gdaldem.exe\', \'file\') == 2
gdaldem_cmd = \'!C:\\OSGeo4W\\bin\\gdaldem.exe\';
else
fprintf(1,\'Can not find \'\'gdaldem\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
gdaldem_cmd = \'!C:\\OSGeo4W64\\bin\\gdaldem.exe\';
end
if exist(\'C:\\OSGeo4W64\\bin\\gdal_polygonize.py\', \'file\') == 2
polygonize_cmd = \'!C:\\OSGeo4W64\\bin\\gdal_polygonize.py\';
elseif exist(\'C:\\OSGeo4W\\bin\\gdal_polygonize.py\', \'file\') == 2
polygonize_cmd = \'!C:\\OSGeo4W\\bin\\gdal_polygonize.py\';
else
fprintf(1,\'Can not find \'\'gdal_polygonize.py\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
polygonize_cmd = \'!C:\\OSGeo4W64\\bin\\gdal_polygonize.py\';
end
remove_cmd = \'!del\';
mv_cmd = \'!move\';
dir_sep = \'\\\';
end
if strcmp(computer_system, \'GLNXA64\')
if exist(\'/usr/bin/gdalsrsinfo\', \'file\') == 2
gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /usr/bin/gdalsrsinfo\';
elseif exist(\'/usr/local/bin/gdalsrsinfo\', \'file\') == 2
gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdalsrsinfo\';
else
fprintf(1,\'Can not find \'\'gdalsrsinfo\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/gdalsrsinfo\';
end
if exist(\'/usr/bin/gdaldem\', \'file\') == 2
gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/gdaldem\';
elseif exist(\'/usr/local/bin/gdaldem.exe\', \'file\') == 2
gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdaldem\';
else
fprintf(1,\'Can not find \'\'gdaldem\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/gdaldem\';
end
if exist(\'/usr/bin/ogr2ogr\', \'file\') == 2
ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /usr/bin/ogr2ogr\';
elseif exist(\'/usr/local/bin/ogr2ogr\', \'file\') == 2
ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/ogr2ogr\';
else
fprintf(1,\'Can not find \'\'ogr2ogr\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/ogr2ogr\';
end
if exist(\'/usr/bin/gdal_polygonize.py\', \'file\') == 2
polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /usr/bin/gdal_polygonize.py\';
elseif exist(\'/usr/local/bin/gdal_polygonize.py\', \'file\') == 2
polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdal_polygonize.py\';
else
fprintf(1,\'Can not find \'\'gdal_polygonize.py\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/gdal_polygonize.py\';
end
remove_cmd = \'!rm\';
mv_cmd = \'!mv\';
dir_sep = \'/\';
end
if strcmp(computer_system, \'MACI64\')
if exist(\'/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdalsrsinfo\', \'file\') == 2
gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdalsrsinfo\';
elseif exist(\'/usr/local/bin/gdalsrsinfo\', \'file\') == 2
gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdalsrsinfo\';
else
fprintf(1,\'Can not find \'\'gdalsrsinfo\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdalsrsinfo\';
end
if exist(\'/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdaldem\', \'file\') == 2
gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdaldem\';
elseif exist(\'/usr/local/bin/gdaldem\', \'file\') == 2
gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdaldem\';
else
fprintf(1,\'Can not find \'\'gdaldem\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdaldem\';
end
if exist(\'/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/ogr2ogr\', \'file\') == 2
ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/ogr2ogr\';
elseif exist(\'/usr/local/bin/ogr2ogr\', \'file\') == 2
ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/ogr2ogr\';
else
fprintf(1,\'Can not find \'\'ogr2ogr\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/ogr2ogr\';
end
if exist(\'/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdal_polygonize.py\', \'file\') == 2
polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdal_polygonize.py\';
elseif exist(\'/usr/local/bin/gdal_polygonize.py\', \'file\') == 2
polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdal_polygonize.py\';
else
fprintf(1,\'Can not find \'\'gdal_polygonize.py\'\'. Please add path manually in knickpoints_parameters.m file\ \');
%SET the PATH to the gdalsrsinfo_cmd in the next line
polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdal_polygonize.py\';
end
remove_cmd = \'!rm\';
mv_cmd = \'!mv\';
dir_sep = \'/\';
end
%% Usually no changes necessary below this line
theta = -0.45; % reference concavity
max_knickpointsize2plot = 40;
[v d] = version;
if str2num(v(end-5:end-2)) < 2014
%running old Matlab
MATLABV = 0;
elseif str2num(v(end-5:end-2)) >= 2014
MATLABV = 1;
end
clear v d
%strsplit only works on newer Matlab version
if MATLABV == 1
foo = strsplit(DEM_basename, \'/\');
DEM_basename_nodir = foo{end};
else
foo = textscan(DEM_basename,\'%s\');
DEM_basename_nodir = char(foo{end});
end
clear foo
TIF_DIR_basename = strcat(\'geotiff/\', DEM_basename);
SHP_DIR_basename = strcat(\'shapefiles/\', DEM_basename);
%filtering options for diffusion filtering
difkernelWidth = 5;
difSSquared = 0.05;
difFilterI = 10;
difMethod = \'PeronaMalik2\';
difTimeIncrement = 0.02;
DEM_fname = strcat(DEM_basename, \'.tif\'); % filename of DEM
DEM_MAT_fname = strcat(DEM_basename, \'.mat\'); % filename for DEM in Matlab MAT file
DEM_HYD_MAT_fname = strcat(DEM_basename, \'_HYD.mat\'); % filename for hydrologically corrected DEM and derivatives
DEM_STR_MAT_fname = strcat(DEM_basename, \'_STR.mat\'); % filename for streamobjs in vector format
DEM_FIL_fname = strcat(TIF_DIR_basename, \'_FIL.tif\'); % filename of filled DEM
DEM_FAC_fname = strcat(TIF_DIR_basename, \'_FAC.tif\'); % filename of FlowAccumulation Grid
DEM_dbasin_fname = strcat(TIF_DIR_basename, \'_DBASIN.tif\'); % filename of DrainageBasin Grid
foo = sprintf(\'_rel_%d_m.tif\', relief_values_m(1));
DEM_rel_1_fname = strcat(TIF_DIR_basename, foo); % filename of Relief_1 Grid
foo = sprintf(\'_rel_%d_m.tif\', relief_values_m(2));
DEM_rel_2_fname = strcat(TIF_DIR_basename, foo); % filename of Relief_2 Grid
foo = sprintf(\'_rel_%d_m.tif\', relief_values_m(3));
DEM_rel_3_fname = strcat(TIF_DIR_basename, foo); % filename of Relief_3 Grid
clear foo
AOI_DEM_curv_profc_fname = strcat(TIF_DIR_basename, \'_curv_profc.tif\'); % filename of profile curvature
AOI_DEM_curv_planc_fname = strcat(TIF_DIR_basename, \'_curv_planc.tif\'); % filename of planform curvature
AOI_DEM_curv_meanc_fname = strcat(TIF_DIR_basename, \'_curv_meanc.tif\'); % filename of planform curvature
AOI_DEM_diff_fname = strcat(TIF_DIR_basename, \'_diffusionf.tif\'); % filename of diffusion filtered DEM
AOI_DEM_wienerf_fname = strcat(TIF_DIR_basename, \'_wienerf.tif\'); % filename of Wiener filtered DEM
DEM_gradient8_fname = strcat(TIF_DIR_basename, \'_gradient8.tif\'); % filename of Gradient of DEM
DEM_SSP_fname = strcat(TIF_DIR_basename, \'_SSP.tif\'); % filename of Gradient of DEM
DEM_ksn045_fname = strcat(TIF_DIR_basename, \'_Ksn045.tif\'); % filename of Gradient of DEM
DEM_ks_adj_fname = strcat(TIF_DIR_basename, \'_Ks_adj.tif\'); % filename of Gradient of DEM
AOI_dbasins_stats_fname = strcat(TIF_DIR_basename, \'_dbasins_stats.tif\'); % filename of Gradient of DEM
AOI_dbasins_stats_vector_fname = strcat(SHP_DIR_basename, \'_dbasins_stats_shp.shp\'); % filename of Gradient of DEM
AOI_dbasins_stats_CNTR_csv_fname = strcat(DEM_basename, \'_db_stats_CNTR.csv\'); % filename of Gradient of DEM
AOI_dbasins_stats_OUT_csv_fname = strcat(DEM_basename, \'_db_stats_OUT.csv\'); % filename of Gradient of DEM
%set quality flag for output to PDF/JPG
quality_flag = \'-q75\';
| if strcmp(computer_system, \'PCWIN64\') | |
| if exist(\'C:\\OSGeo4W64\\bin\\gdalsrsinfo.exe\', \'file\') == 2 | |
| gdalsrsinfo_cmd = \'!C:\\OSGeo4W64\\bin\\gdalsrsinfo.exe\'; | |
| elseif exist(\'C:\\OSGeo4W\\bin\\gdalsrsinfo.exe\', \'file\') == 2 | |
| gdalsrsinfo_cmd = \'!C:\\OSGeo4W\\bin\\gdalsrsinfo.exe\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdalsrsinfo\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| gdalsrsinfo_cmd = \'!C:\\OSGeo4W64\\bin\\gdalsrsinfo.exe\'; | |
| end | |
| if exist(\'C:\\OSGeo4W64\\bin\\ogr2ogr.exe\', \'file\') == 2 | |
| ogr2ogr_cmd = \'!C:\\OSGeo4W64\\bin\\ogr2ogr.exe\'; | |
| elseif exist(\'C:\\OSGeo4W\\bin\\ogr2ogr.exe\', \'file\') == 2 | |
| ogr2ogr_cmd = \'!C:\\OSGeo4W\\bin\\ogr2ogr.exe\'; | |
| else | |
| fprintf(1,\'Can not find \'\'ogr2ogr\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| ogr2ogr_cmd = \'!C:\\OSGeo4W64\\bin\\ogr2ogr.exe\'; | |
| end | |
| if exist(\'C:\\OSGeo4W64\\bin\\gdaldem.exe\', \'file\') == 2 | |
| gdaldem_cmd = \'!C:\\OSGeo4W64\\bin\\gdaldem.exe\'; | |
| elseif exist(\'C:\\OSGeo4W\\bin\\gdaldem.exe\', \'file\') == 2 | |
| gdaldem_cmd = \'!C:\\OSGeo4W\\bin\\gdaldem.exe\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdaldem\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| gdaldem_cmd = \'!C:\\OSGeo4W64\\bin\\gdaldem.exe\'; | |
| end | |
| | |
| if exist(\'C:\\OSGeo4W64\\bin\\gdal_polygonize.py\', \'file\') == 2 | |
| polygonize_cmd = \'!C:\\OSGeo4W64\\bin\\gdal_polygonize.py\'; | |
| elseif exist(\'C:\\OSGeo4W\\bin\\gdal_polygonize.py\', \'file\') == 2 | |
| polygonize_cmd = \'!C:\\OSGeo4W\\bin\\gdal_polygonize.py\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdal_polygonize.py\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| polygonize_cmd = \'!C:\\OSGeo4W64\\bin\\gdal_polygonize.py\'; | |
| end | |
| remove_cmd = \'!del\'; | |
| mv_cmd = \'!move\'; | |
| dir_sep = \'\\\'; | |
| end | |
| | |
| if strcmp(computer_system, \'GLNXA64\') | |
| if exist(\'/usr/bin/gdalsrsinfo\', \'file\') == 2 | |
| gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /usr/bin/gdalsrsinfo\'; | |
| elseif exist(\'/usr/local/bin/gdalsrsinfo\', \'file\') == 2 | |
| gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdalsrsinfo\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdalsrsinfo\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/gdalsrsinfo\'; | |
| end | |
| if exist(\'/usr/bin/gdaldem\', \'file\') == 2 | |
| gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/gdaldem\'; | |
| elseif exist(\'/usr/local/bin/gdaldem.exe\', \'file\') == 2 | |
| gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdaldem\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdaldem\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/gdaldem\'; | |
| end | |
| if exist(\'/usr/bin/ogr2ogr\', \'file\') == 2 | |
| ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /usr/bin/ogr2ogr\'; | |
| elseif exist(\'/usr/local/bin/ogr2ogr\', \'file\') == 2 | |
| ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/ogr2ogr\'; | |
| else | |
| fprintf(1,\'Can not find \'\'ogr2ogr\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/ogr2ogr\'; | |
| end | |
| if exist(\'/usr/bin/gdal_polygonize.py\', \'file\') == 2 | |
| polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /usr/bin/gdal_polygonize.py\'; | |
| elseif exist(\'/usr/local/bin/gdal_polygonize.py\', \'file\') == 2 | |
| polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdal_polygonize.py\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdal_polygonize.py\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/bin/gdal_polygonize.py\'; | |
| end | |
| remove_cmd = \'!rm\'; | |
| mv_cmd = \'!mv\'; | |
| dir_sep = \'/\'; | |
| end | |
| if strcmp(computer_system, \'MACI64\') | |
| if exist(\'/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdalsrsinfo\', \'file\') == 2 | |
| gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdalsrsinfo\'; | |
| elseif exist(\'/usr/local/bin/gdalsrsinfo\', \'file\') == 2 | |
| gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdalsrsinfo\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdalsrsinfo\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| gdalsrsinfo_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdalsrsinfo\'; | |
| end | |
| if exist(\'/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdaldem\', \'file\') == 2 | |
| gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdaldem\'; | |
| elseif exist(\'/usr/local/bin/gdaldem\', \'file\') == 2 | |
| gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdaldem\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdaldem\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| gdaldem_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdaldem\'; | |
| end | |
| if exist(\'/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/ogr2ogr\', \'file\') == 2 | |
| ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/ogr2ogr\'; | |
| elseif exist(\'/usr/local/bin/ogr2ogr\', \'file\') == 2 | |
| ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/ogr2ogr\'; | |
| else | |
| fprintf(1,\'Can not find \'\'ogr2ogr\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| ogr2ogr_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/ogr2ogr\'; | |
| end | |
| if exist(\'/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdal_polygonize.py\', \'file\') == 2 | |
| polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'/usr/lib\'\' /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdal_polygonize.py\'; | |
| elseif exist(\'/usr/local/bin/gdal_polygonize.py\', \'file\') == 2 | |
| polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdal_polygonize.py\'; | |
| else | |
| fprintf(1,\'Can not find \'\'gdal_polygonize.py\'\'. Please add path manually in knickpoints_parameters.m file\ \'); | |
| %SET the PATH to the gdalsrsinfo_cmd in the next line | |
| polygonize_cmd = \'!env LD_LIBRARY_PATH=\'\'\'\' /usr/local/bin/gdal_polygonize.py\'; | |
| end | |
| remove_cmd = \'!rm\'; | |
| mv_cmd = \'!mv\'; | |
| dir_sep = \'/\'; | |
| end | |
| | |
| | |
| %% Usually no changes necessary below this line | |
| theta = -0.45; % reference concavity | |
| | |
| max_knickpointsize2plot = 40; | |
| | |
| [v d] = version; | |
| if str2num(v(end-5:end-2)) < 2014 | |
| %running old Matlab | |
| MATLABV = 0; | |
| elseif str2num(v(end-5:end-2)) >= 2014 | |
| MATLABV = 1; | |
| end | |
| clear v d | |
| | |
| %strsplit only works on newer Matlab version | |
| if MATLABV == 1 | |
| foo = strsplit(DEM_basename, \'/\'); | |
| DEM_basename_nodir = foo{end}; | |
| else | |
| foo = textscan(DEM_basename,\'%s\'); | |
| DEM_basename_nodir = char(foo{end}); | |
| end | |
| clear foo | |
| TIF_DIR_basename = strcat(\'geotiff/\', DEM_basename); | |
| SHP_DIR_basename = strcat(\'shapefiles/\', DEM_basename); | |
| | |
| %filtering options for diffusion filtering | |
| difkernelWidth = 5; | |
| difSSquared = 0.05; | |
| difFilterI = 10; | |
| difMethod = \'PeronaMalik2\'; | |
| difTimeIncrement = 0.02; | |
| | |
| DEM_fname = strcat(DEM_basename, \'.tif\'); % filename of DEM | |
| DEM_MAT_fname = strcat(DEM_basename, \'.mat\'); % filename for DEM in Matlab MAT file | |
| DEM_HYD_MAT_fname = strcat(DEM_basename, \'_HYD.mat\'); % filename for hydrologically corrected DEM and derivatives | |
| DEM_STR_MAT_fname = strcat(DEM_basename, \'_STR.mat\'); % filename for streamobjs in vector format | |
| DEM_FIL_fname = strcat(TIF_DIR_basename, \'_FIL.tif\'); % filename of filled DEM | |
| DEM_FAC_fname = strcat(TIF_DIR_basename, \'_FAC.tif\'); % filename of FlowAccumulation Grid | |
| DEM_dbasin_fname = strcat(TIF_DIR_basename, \'_DBASIN.tif\'); % filename of DrainageBasin Grid | |
| foo = sprintf(\'_rel_%d_m.tif\', relief_values_m(1)); | |
| DEM_rel_1_fname = strcat(TIF_DIR_basename, foo); % filename of Relief_1 Grid | |
| foo = sprintf(\'_rel_%d_m.tif\', relief_values_m(2)); | |
| DEM_rel_2_fname = strcat(TIF_DIR_basename, foo); % filename of Relief_2 Grid | |
| foo = sprintf(\'_rel_%d_m.tif\', relief_values_m(3)); | |
| DEM_rel_3_fname = strcat(TIF_DIR_basename, foo); % filename of Relief_3 Grid | |
| clear foo | |
| AOI_DEM_curv_profc_fname = strcat(TIF_DIR_basename, \'_curv_profc.tif\'); % filename of profile curvature | |
| AOI_DEM_curv_planc_fname = strcat(TIF_DIR_basename, \'_curv_planc.tif\'); % filename of planform curvature | |
| AOI_DEM_curv_meanc_fname = strcat(TIF_DIR_basename, \'_curv_meanc.tif\'); % filename of planform curvature | |
| AOI_DEM_diff_fname = strcat(TIF_DIR_basename, \'_diffusionf.tif\'); % filename of diffusion filtered DEM | |
| AOI_DEM_wienerf_fname = strcat(TIF_DIR_basename, \'_wienerf.tif\'); % filename of Wiener filtered DEM | |
| DEM_gradient8_fname = strcat(TIF_DIR_basename, \'_gradient8.tif\'); % filename of Gradient of DEM | |
| DEM_SSP_fname = strcat(TIF_DIR_basename, \'_SSP.tif\'); % filename of Gradient of DEM | |
| DEM_ksn045_fname = strcat(TIF_DIR_basename, \'_Ksn045.tif\'); % filename of Gradient of DEM | |
| DEM_ks_adj_fname = strcat(TIF_DIR_basename, \'_Ks_adj.tif\'); % filename of Gradient of DEM | |
| AOI_dbasins_stats_fname = strcat(TIF_DIR_basename, \'_dbasins_stats.tif\'); % filename of Gradient of DEM | |
| AOI_dbasins_stats_vector_fname = strcat(SHP_DIR_basename, \'_dbasins_stats_shp.shp\'); % filename of Gradient of DEM | |
| AOI_dbasins_stats_CNTR_csv_fname = strcat(DEM_basename, \'_db_stats_CNTR.csv\'); % filename of Gradient of DEM | |
| AOI_dbasins_stats_OUT_csv_fname = strcat(DEM_basename, \'_db_stats_OUT.csv\'); % filename of Gradient of DEM | |
| | |
| %set quality flag for output to PDF/JPG | |
| quality_flag = \'-q75\'; |











