def test_join_results_to_baseline(): known = resource_filename('tidegates.testing.join_results', 'merge_result.shp') with utils.OverwriteState(True): test = utils.join_results_to_baseline( resource_filename('tidegates.testing.join_results', 'merge_result.shp'), resource_filename('tidegates.testing.join_results', 'merge_join.shp'), resource_filename('tidegates.testing.join_results', 'merge_baseline.shp') ) nt.assert_true(isinstance(test, arcpy.mapping.Layer)) tgtest.assert_shapefiles_are_close(test.dataSource, known) utils.cleanup_temp_results(test)
def finish_results(outputname, results, **kwargs): """ Merges and cleans up compiled output from `analyze`. Parameters ---------- outputname : str Path to where the final file sould be saved. results : list of str Lists of all of the floods, flooded wetlands, and flooded buildings, respectively, that will be merged and deleted. sourcename : str, optional Path to the original source file of the results. If provided, its attbutes will be spatially joined to the concatenated results. Returns ------- None """ sourcename = kwargs.pop('sourcename', None) cleanup = kwargs.pop('cleanup', True) if outputname is not None: if sourcename is not None: tmp_fname = utils.create_temp_filename(outputname, filetype='shape') utils.concat_results(tmp_fname, *results) utils.join_results_to_baseline( outputname, utils.load_data(tmp_fname, 'layer'), utils.load_data(sourcename, 'layer') ) utils.cleanup_temp_results(tmp_fname) else: utils.concat_results(outputname, *results) if cleanup: utils.cleanup_temp_results(*results)
def test_join_results_to_baseline(): known = resource_filename('tidegates.testing.join_results', 'merge_result.shp') with utils.OverwriteState(True): test = utils.join_results_to_baseline( resource_filename('tidegates.testing.join_results', 'merge_result.shp'), resource_filename('tidegates.testing.join_results', 'merge_join.shp'), resource_filename('tidegates.testing.join_results', 'merge_baseline.shp')) nt.assert_true(isinstance(test, arcpy.mapping.Layer)) tgtest.assert_shapefiles_are_close(test.dataSource, known) utils.cleanup_temp_results(test)