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

grass.temporal: Do not fail when registering maps with missing range file #2382

Merged
merged 2 commits into from
Sep 8, 2022

Conversation

ninsbl
Copy link
Member

@ninsbl ninsbl commented May 19, 2022

If maps are linked to the GRASS GIS database with r.external -r those maps do not have a range file.
When trying to register them in a STRDS, the process fails because no map info is returned at all, meaning no north, south, ... info either. In consequence, NON-NULL constraints of the TGIS DB are violated.

This PR fixes the inconsistency, so I tagged it as a bug and added a backport label. If others feel different about it, please feel free to change the labels.

In case of a missing range file, now None/NULL is returned as range of map values together with a valid spatial extent.

@ninsbl ninsbl added bug Something isn't working backport_needed temporal Related to temporal data processing Python Related code is in Python labels May 19, 2022
@ninsbl ninsbl added this to the 8.0.3 milestone May 19, 2022
@ninsbl ninsbl requested review from neteler and metzm May 19, 2022 13:14
@ninsbl
Copy link
Member Author

ninsbl commented Jun 17, 2022

The failing OSGeo4W test is unrelated.
If there are no objections, I will merge and backport next week...

return None
if ret == 2:
if ret < 0 or ret == 2:
logging.warning(_("Unable to read range file"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the values seems fine, but the warning text is technically not correct for ret == 2:
https://grass.osgeo.org/programming7/defs_2raster_8h.html#a9efe2d261c71822b99f546c6d740395c
I know this is fairly minor, but still...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Addressed in faab6c1. Could probably be solved with less code duplication, but I am not sure it is worth doing bigger changes here...

@metzm
Copy link
Contributor

metzm commented Jul 1, 2022

Why exactly do you want to support r.external -r for TGIS? A missing or empty range file can cause all sorts of problems with other modules. Particularly with temporal modules, often calling other modules for actual raster processing, error messages eventually caused by an empty range file might be difficult to interpret.

@ninsbl
Copy link
Member Author

ninsbl commented Aug 4, 2022

Why exactly do you want to support r.external -r for TGIS?

When using GDALs /vsicurl/ to link online raster data resources, even the -m flag for just reading metadata causes the the dataset to be read entirely if metadata is missing. For larger datasets that is a) time consuming and b) (almost) the same as downloading the whole thing.
I use r.external -r for NetCDF files on Thredds servers, but that can be equally releveant for COGs or the like if metadata is missing...

For the addon I have been working on (https://github.com/ninsbl/t.rast.import.netcdf) I may be able to create a range file from a known "valid range" of the data. Could that be helpful to avoid processing errors down the road?

A missing or empty range file can cause all sorts of problems with other modules. Particularly with temporal modules, often calling other modules for actual raster processing, error messages eventually caused by an empty range file might be difficult to interpret.

Is there somewhere documentation which kinds of modules require a range file? My usecase is having a set of linked data in a time series to spatio-temporal select from it for further processing. Do e.g. r.mapcalc, r.series, r.univar have problems when a range file is missing? I can imagine that r.colors can run into issues...

Maybe with a warning, we can allow people to risk shooting themselfs in the foot also here, as r.external -r probably does anyway?

@wenzeslaus
Copy link
Member

...even the -m flag for just reading metadata causes the the dataset to be read entirely if metadata is missing...

See #2381 for some tests and analysis.

@ninsbl ninsbl merged commit e856aaa into OSGeo:main Sep 8, 2022
ninsbl added a commit that referenced this pull request Sep 8, 2022
)

* dont fail with missing range file

* handle empty range separate
ninsbl added a commit that referenced this pull request Sep 8, 2022
)

* dont fail with missing range file

* handle empty range separate
@ninsbl
Copy link
Member Author

ninsbl commented Sep 8, 2022

Backported in bf0c12f and ecb6c22

ninsbl added a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
…Geo#2382)

* dont fail with missing range file

* handle empty range separate
ninsbl added a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
…Geo#2382)

* dont fail with missing range file

* handle empty range separate
@wenzeslaus wenzeslaus changed the title temporal: dont fail when registering maps with missing range file grass.temporal: Do not fail when registering maps with missing range file Jun 6, 2023
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
…Geo#2382)

* dont fail with missing range file

* handle empty range separate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Related code is in Python temporal Related to temporal data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants