Пример #1
0
    def write_bbox(self, filename):
        """write the bbox to a txt file on disk

        Parameters
        ----------
        filename : str
            path and filename to store txt output

        Returns
        -------
        None
        """
        write_bbox(self.get_human_bbox(), filename)
Пример #2
0
    def test_subset_tif_conus2(self):
        data_array = file_io_tools.read_file(test_files.conus2_dem.as_posix())
        my_mask = SubsetMask(
            test_files.huc10190004.get('conus2_mask').as_posix())
        clipper = MaskClipper(subset_mask=my_mask, no_data_threshold=-1)
        return_arr, new_geom, new_mask, bbox = clipper.subset(data_array)
        file_io_tools.write_array_to_geotiff("conus_2_clip_dem_test.tif",
                                             return_arr, new_geom,
                                             my_mask.mask_tif.GetProjection())
        self.assertIsNone(
            np.testing.assert_array_equal(
                file_io_tools.read_file(
                    test_files.huc10190004.get('conus2_dem').as_posix()),
                file_io_tools.read_file('conus_2_clip_dem_test.tif')),
            'Clipping DEM matches reference')
        os.remove('conus_2_clip_dem_test.tif')

        file_io_tools.write_bbox(bbox, 'bbox_conus2_full.txt')
        self.assertSequenceEqual(
            file_io_tools.read_bbox('bbox_conus2_full.txt'),
            test_files.huc10190004.get('conus2_bbox'),
            'Subset writes correct bounding box file')
        os.remove('bbox_conus2_full.txt')
Пример #3
0
 def test_write_read_bbox(self):
     bbox = [10, 15, 20, 25]
     file_io_tools.write_bbox(bbox, 'bbox_test.txt')
     self.assertSequenceEqual(bbox, file_io_tools.read_bbox('bbox_test.txt'),
                              'writing and reading a bbox does not change values')
     os.remove('bbox_test.txt')