Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threshold too high! Using maximum threshold -23.0 db #93

Open
falahfakhri-Iraq opened this issue Jan 17, 2022 · 2 comments
Open

Threshold too high! Using maximum threshold -23.0 db #93

falahfakhri-Iraq opened this issue Jan 17, 2022 · 2 comments

Comments

@falahfakhri-Iraq
Copy link

Hi,
I did many attempts of the parameters altering, however, I got the following error,

Threshold too high! Using maximum threshold -23.0 db
Traceback (most recent call last):
File "", line 1, in
File "C:\anaconda\envs\SAR\lib\site-packages\asf_tools\water_map.py", line 265, in make_water_map
write_cog(str(out_raster).replace('.tif', f'_{pol}_initial.tif'), water_map, transform=out_transform,
File "C:\anaconda\envs\SAR\lib\site-packages\asf_tools\composite.py", line 208, in write_cog
temp_geotiff = driver.Create(temp_file.name, data.shape[1], data.shape[0], 1, dtype)
File "C:\anaconda\envs\SAR\lib\site-packages\osgeo\gdal.py", line 1997, in Create
return _gdal.Driver_Create(self, *args, **kwargs)
RuntimeError: Attempt to create new tiff file `C:\Users\FALAH FAKHRI\AppData\Local\Temp\tmp21abpre2' failed: Permission denied

following is the script,

import asf_tools
from asf_tools.water_map import make_water_map

dirpath = 'D:/Australia_Project/image_data/WATER_MAP_TEST/'

vh = dirpath + 'VH/S1A_IW_GRDH_1SDV_20210324T191554_045F93_21DF_VH_NR_Orb_TC_res.tif'

vv = dirpath + 'VV/S1A_IW_GRDH_1SDV_20210324T191554_045F93_21DF_VV_NR_Orb_TC_res.tif'

out_raster = dirpath + 'water_map_20210324T191554_045F93_21DF.tif'

make_water_map(
out_raster,
vv,
vh,
hand_raster=None,
tile_shape=(200, 200), # also (100, 100) has been tried out.
max_vv_threshold=9.7,
max_vh_threshold=-23.0,
hand_threshold=15.0,
hand_fraction=0.8,
membership_threshold=0.45
)

It's worth mentioning that I got a result, despite the error!

@jhkennedy jhkennedy transferred this issue from ASFHyP3/ASFHyP3.github.io Jan 19, 2022
@jhkennedy
Copy link
Contributor

@falahfakhri-Iraq the Threshold too high! Using maximum threshold -23.0 db message is just a warning saying the max VH threshold you specified (max_vh_threshold=-23.0) is lower than the calculated threshold using the Expectation Maximization approach. You may want to play with raising/lowering the threshold for you scene.

The actual error you're seeing is due to a file permission error:

RuntimeError: Attempt to create new tiff file `C:\Users\FALAH FAKHRI\AppData\Local\Temp\tmp21abpre2' failed: Permission denied

asf_tools is trying to make temporary raster in C:\Users\FALAH FAKHRI\AppData\Local\Temp\tmp21abpre2 during the COG creation step, and doesn't have the permissions to do so. In the code, asf_tools is using Python's NamedTemporaryFile for creating the files, and this is likely a Windows vs Unix issue -- we haven't fully tested the package on windows and it'll take a bit of time for me to troubleshoot.

@falahfakhri-Iraq
Copy link
Author

falahfakhri-Iraq commented Jan 20, 2022

Dear Joseph,
Thanks a lot for your kind response,
I have other question with this regard,
Do you have any hints of calculating vh, vv, threshold?

Is it possible to use Otsu's method for threshold calculation related to intensity our case in here?
https://muthu.co/otsus-method-for-image-thresholding-explained-and-implemented/

After run Otus's method, I got the threshold as below, and I also tired to solve the error related to tempfile, however I got an error as well,

import tempfile
out_raster = tempfile.NamedTemporaryFile(delete=False)

make_water_map(
out_raster,
vv,
vh,
hand_raster=None,
tile_shape=(200, 200),
max_vv_threshold=21,
max_vh_threshold=18,

hand_threshold=15.0,
hand_fraction=0.8,
membership_threshold=0.45
)
Traceback (most recent call last):
File "", line 1, in
File "C:\anaconda\envs\SAR\lib\site-packages\asf_tools\water_map.py", line 265, in make_water_map
write_cog(str(out_raster).replace('.tif', f'_{pol}_initial.tif'), water_map, transform=out_transform,
File "C:\anaconda\envs\SAR\lib\site-packages\asf_tools\composite.py", line 208, in write_cog
temp_geotiff = driver.Create(temp_file.name, data.shape[1], data.shape[0], 1, dtype)
File "C:\anaconda\envs\SAR\lib\site-packages\osgeo\gdal.py", line 1997, in Create
return _gdal.Driver_Create(self, *args, **kwargs)
RuntimeError: Attempt to create new tiff file `C:\Users\FALAH FAKHRI\AppData\Local\Temp\tmp7win4xiu' failed: Permission denied

Thanks a lot for you time,
With my best wishes,
Falah,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants