r.import: Fix the -e flag for estimating the resolution without importing
Problem Summary
When using r.import with the -e flag to estimate the resolution of a raster file without performing a full import, the following issues were observed:
- The estimated resolution is not calculated or displayed if no reprojection is required.
- A temporary raster map (rimport_tmp) remains in the mapset, which should be cleaned up.
Root Cause
The issue arises due to improper handling of cases where the raster input is already in the same projection as the current GRASS GIS session. There is no code for -e flag behavior when no reprojection is required. Additionally, the temporary raster map is not deleted.
Fixes
Resolution Estimation Logic:
Added a -e flag behavior when reprojection is not required. Applied the logic to ensure the resolution is calculated and displayed even when no reprojection is required.
Temporary Map Cleanup:
Created a new flag TMP_EST_FILE to hold the temporary file. Ensured that the temporary map (rimport_tmp) is deleted after the resolution estimation process.
I am not entirely sure this is needed. The resolution needs to be estimated because of the reprojection, when you don't reproject, the resolution is not 'estimated'. But I agree, that having consistent behavior of the e flag would make sense (for automated workflows for example). But in that case, wouldn't using r.external work better, so that you avoid the import, which can take a long time. With r.external, the raster is only linked and I believe you can get correct resolution with r.info.
I am not entirely sure this is needed. The resolution needs to be estimated because of the reprojection, when you don't reproject, the resolution is not 'estimated'. But I agree, that having consistent behavior of the e flag would make sense (for automated workflows for example). But in that case, wouldn't using r.external work better, so that you avoid the import, which can take a long time. With r.external, the raster is only linked and I believe you can get correct resolution with r.info.
I think this flag needs to be fixed for consistency, but you're right about r.external. I think this PR can be improved for -e without reprojection using r.external?
@KandelN, you want to look into this possibility?