def test_make_mask(self): """test creating a basic mask using a csv input.""" output_mask = footprint_mask(os.path.join(data_dir, 'sample.csv'), geom_col="PolygonWKT_Pix") truth_mask = skimage.io.imread( os.path.join(data_dir, 'sample_fp_mask.tif')) assert np.array_equal(output_mask, truth_mask)
def test_make_mask_infer_do_transform_true(self): output_mask = footprint_mask( os.path.join(data_dir, 'geotiff_labels.geojson'), reference_im=os.path.join(data_dir, 'sample_geotiff.tif'), out_file=os.path.join(data_dir, 'test_out.tif')) truth_mask = skimage.io.imread( os.path.join(data_dir, 'sample_fp_mask_from_geojson.tif')) saved_output_mask = skimage.io.imread( os.path.join(data_dir, 'test_out.tif')) assert np.array_equal(output_mask, truth_mask) assert np.array_equal(saved_output_mask, truth_mask) # clean up os.remove(os.path.join(data_dir, 'test_out.tif'))
def test_make_mask_w_file_and_transform(self): """Test creating a mask using a geojson and an affine xform.""" output_mask = footprint_mask( os.path.join(data_dir, 'geotiff_labels.geojson'), reference_im=os.path.join(data_dir, 'sample_geotiff.tif'), do_transform=True, out_file=os.path.join(data_dir, 'test_out.tif')) truth_mask = skimage.io.imread( os.path.join(data_dir, 'sample_fp_mask_from_geojson.tif')) saved_output_mask = skimage.io.imread( os.path.join(data_dir, 'test_out.tif')) assert np.array_equal(output_mask, truth_mask) assert np.array_equal(saved_output_mask, truth_mask) # clean up os.remove(os.path.join(data_dir, 'test_out.tif'))
def test_make_mask_w_output_file(self): """test creating a basic mask and saving the output to a file.""" output_mask = footprint_mask( os.path.join(data_dir, 'sample.csv'), geom_col="PolygonWKT_Pix", reference_im=os.path.join(data_dir, "sample_geotiff.tif"), out_file=os.path.join(data_dir, 'test_out.tif')) truth_mask = skimage.io.imread( os.path.join(data_dir, 'sample_fp_mask.tif')) saved_output_mask = skimage.io.imread( os.path.join(data_dir, 'test_out.tif')) assert np.array_equal(output_mask, truth_mask) assert np.array_equal(saved_output_mask, truth_mask) # clean up os.remove(os.path.join(data_dir, 'test_out.tif'))