limitations under the License. """ if __name__ == "__main__": from pydem.test_pydem import get_test_data from pydem.dem_processing import DEMProcessor from pydem.test_pydem import make_file_names import sys if len(sys.argv) <= 1: testnum = 30 # Default test number NN = 64 # Resolution of tile # Get test data and create DEMProcessor elev, ang, test_data = get_test_data(testnum, NN) filename = make_file_names(testnum, NN)['fel'] dem_proc = DEMProcessor(filename, dx_dy_from_file=False) # Calculate magnitude and direction of slopes mag, direction = dem_proc.calc_slopes_directions() # Calculate UCA/TWI on entire tile area1 = dem_proc.calc_uca(0) twi1 = dem_proc.calc_twi() # Calculate UCA/TWI on chunks dem_proc.resolve_edges = True # If false, won't do edge resolution dem_proc.chunk_size_uca = 9 # Chunk size dem_proc.chunk_overlap_uca = 3 #Overlap between chunks area2 = dem_proc.calc_uca(0)
help="if set, will create a non-" "uniform grid on the elevation", action="store_true", ) args = parser.parse_args() testnum = args.testnum dx_dy_from_file = args.variable_coords testnum += dx_dy_from_file NN = 511 # The resolution of the grid (N x N) if testnum >= 28: filename = make_file_names(testnum, NN)["elev"] else: filename = make_file_names(testnum, NN)["fel"] elev, ang, test_data = get_test_data(testnum, NN) # Make the filenames of the results filename2 = make_file_names(testnum, NN)["uca"] if os.path.exists(filename2): uca_file = GdalReader(file_name=filename2) uca, = uca_file.raster_layers # Make the pydem Processor object and process the elevation dem_proc = DEMProcessor(filename, dx_dy_from_file=dx_dy_from_file) mag, direction = dem_proc.calc_slopes_directions() area = dem_proc.calc_uca(0) twi = dem_proc.calc_twi() # # Now process using tauDEM
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ if __name__ == "__main__": import os from pydem.processing_manager import ProcessManager path = r'testtiff' # Make at least one test file if len(os.listdir(path)) == 0: from pydem.test_pydem import get_test_data get_test_data(13, 64) from pydem.utils import rename_files elev_source_files = [os.path.join(path, fn) for fn in os.listdir(path) if os.path.splitext(fn)[-1] in ['.tif', '.tiff'] and '_elev' in fn] other_source_files = [os.path.join(path, fn) for fn in os.listdir(path) if os.path.splitext(fn)[-1] in ['.tif', '.tiff'] and '_elev' not in fn] rename_files(elev_source_files) for fil in other_source_files: os.remove(fil) savepath = os.path.join('testtiff', 'processed_data')
See the License for the specific language governing permissions and limitations under the License. """ if __name__ == "__main__": from pydem.test_pydem import get_test_data from pydem.dem_processing import DEMProcessor from pydem.test_pydem import make_file_names import sys, os if len(sys.argv) <= 1: testnum = 13 # Default test number NN = 64 # Resolution of tile # Get test data and create DEMProcessor elev, ang, test_data = get_test_data(testnum, NN) elev = elev.raster_data dem_proc1 = DEMProcessor(elev) # Calculate TWI twi1 = dem_proc1.calc_twi() # Stretch the latitude direction lats = [0, 2] # degrees lons = [0, 1] # degrees dem_proc2 = DEMProcessor((elev, lats, lons)) twi2 = dem_proc2.calc_twi() # plot results import matplotlib.pyplot as plt plt.matshow(twi1); plt.colorbar()
help='if set, will create a non-' 'uniform grid on the elevation', action="store_true") args = parser.parse_args() testnum = args.testnum dx_dy_from_file = args.variable_coords testnum += dx_dy_from_file NN = 64 # The resolution of the grid (N x N) if testnum >= 28: filename = make_file_names(testnum, NN)['elev'] else: filename = make_file_names(testnum, NN)['fel'] elev, ang, test_data = get_test_data(testnum, NN) # Make the filenames of the results filename2 = make_file_names(testnum, NN)['uca'] if os.path.exists(filename2): uca_file = GdalReader(file_name=filename2) uca, = uca_file.raster_layers # Make the pydem Processor object and process the elevation dem_proc = DEMProcessor(filename, dx_dy_from_file=dx_dy_from_file) mag, direction = dem_proc.calc_slopes_directions() area = dem_proc.calc_uca(0) twi = dem_proc.calc_twi() # # Now process using tauDEM
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ if __name__ == "__main__": import os from pydem.processing_manager import ProcessManager path = r'testtiff' # Make at least one test file if len(os.listdir(path)) == 0: from pydem.test_pydem import get_test_data get_test_data(13, 64) from pydem.utils import rename_files elev_source_files = [ os.path.join(path, fn) for fn in os.listdir(path) if os.path.splitext(fn)[-1] in ['.tif', '.tiff'] and '_elev' in fn ] other_source_files = [ os.path.join(path, fn) for fn in os.listdir(path) if os.path.splitext(fn)[-1] in ['.tif', '.tiff'] and '_elev' not in fn ] rename_files(elev_source_files) for fil in other_source_files: os.remove(fil) savepath = os.path.join('testtiff', 'processed_data')