Skip to content

Commit

Permalink
Merge pull request #205 from WorldCereal/204-croptype-picker-replace-…
Browse files Browse the repository at this point in the history
…warning

replaced warning with error and helper message
  • Loading branch information
kvantricht authored Oct 17, 2024
2 parents df60a25 + b03a0d6 commit 2a074c8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion notebooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ def select_landcover(df: pd.DataFrame):

def pick_croptypes(df: pd.DataFrame, samples_threshold: int = 100):
import ipywidgets as widgets
from IPython.display import Markdown

nodata_helper_message = """
### What to do?
1. **Increase the buffer size**: Try increasing the buffer size by passing the `buffer` parameter to the `query_public_extractions` function (to a reasonable extent).
2. **Consult the WorldCereal Reference Data Module portal**: Assess data density in the selected region by visiting the [WorldCereal Reference Data Module portal](https://ewoc-rdm-ui.iiasa.ac.at/map).
3. **Pick another area**: Consult RDM portal (see above) to find areas with more data density.
4. **Contribute data**: Collect some data and contribute to our global database! 🌍🌾 [Learn how to contribute here.](https://worldcereal.github.io/worldcereal-documentation/rdm/upload.html)
"""

# CREATING A HIERARCHICAL LAYOUT OF OPTIONS
# ==========================================
Expand Down Expand Up @@ -240,9 +249,13 @@ def pick_croptypes(df: pd.DataFrame, samples_threshold: int = 100):
)

if len(class_counts) == 1:
logger.warning(
logger.error(
f"Only one class remained after aggregation with threshold {samples_threshold}. Consider lowering the threshold."
)
Markdown(nodata_helper_message)
raise ValueError(
"Only one class remained after aggregation. Please lower the threshold."
)

# Convert to a hierarchically arranged dictionary
class_counts = class_counts[class_counts["label_level3"] != "other_temporary_crops"]
Expand Down

0 comments on commit 2a074c8

Please sign in to comment.