CosmiQ / solaris

CosmiQ Works Geospatial Machine Learning Analysis Toolkit
https://solaris.readthedocs.io
Apache License 2.0
411 stars 112 forks source link

[FEATURE]: (short description) #470

Open 6tronl opened 1 year ago

6tronl commented 1 year ago

Hello, I'm facing an issue when cropping an orthomosaic into tiles with solaris.tile.raster_tile.RasterTiler(). My orthomosaics covers a small area (155 m2) and when I crop it into smaller pieces, files are saved in a folder with the following name format : [src-filename]_[longitude]_[latitude].tif. However, longitude and latitude within the file name gets 3 numbers after the coma which is annoying to me because my orthomosaic doesn't cover a large area so, with 3 numbers after the coma, I only get 2 different longitude/latitude values. When saving after cropping, tiles then get the same dest name and are overwritten.

I would like to choose the accucary of longitude and latitude with an argument like dest_fname in the tile() function.

Currently, I have edited the save_tile() in raster_file.py to take 7 numbers after the coma in order to be able to get all my files saved and not overwritten:

            dest_fname = "{}_{}_{}.tif".format(
                dest_fname_root,
                np.round(profile["transform"][2], 7),
                np.round(profile["transform"][5], 7),
            )
6tronl commented 1 year ago

Same comment when saving vector.

I have edited the tile() in vector_file.py :

dest_path = os.path.join(
                    self.dest_dir,
                    "{}_{}_{}{}".format(
                        dest_fname_base,
                        np.round(tb[0], 7),
                        np.round(tb[3], 7),
                        output_ext,
                    ),