Skip to content

Add legends for MapFeatureExplorer layer options #2513

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

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

mohitb35
Copy link
Collaborator

@mohitb35 mohitb35 commented May 6, 2025

Introduce legends for different layer options in the MapFeatureExplorer, enhancing the user interface with visual representations of data ranges and categories. Update localization files and styles to support these changes.

Pending:

  • Regenerate maps for biomass potential, soil bulk density, soil pH, tree species density
  • Update legend for soil nitrogen
  • Reverse default tenant change

Copy link

vercel bot commented May 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
planet-webapp-multi-tenancy-setup ✅ Ready (Inspect) Visit Preview May 9, 2025 4:36am

Copy link
Contributor

coderabbitai bot commented May 6, 2025

"""

Walkthrough

This update introduces a new map layer legend system. It adds a LayerLegend React component and supporting CSS, updates the layer configuration to include legend metadata, and modifies the layer option UI to conditionally render legends. The changes are limited to styling, configuration, and UI presentation, with no changes to business logic.

Changes

File(s) Change Summary
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss Modified .singleLayerOption layout from horizontal to vertical with reduced gap. Added new .layerControls (horizontal flex, spacing), .layerLegend (vertical flex, background, padding, rounded corners), and related sub-classes for styling legend bars and values. Added .legendVisible modifier to remove bottom border when legend is shown.
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx Introduced new default-exported LayerLegend React component. Includes internal RangeLegend and CategoryLegend subcomponents for rendering range gradient and category legends, respectively. Uses CSS modules and internationalization for category labels.
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/SingleLayerOption.tsx Refactored to check for layerConfig.isAvailable early and use isOptionSelected for selection state. Wrapped label and switch in .layerControls div. Conditionally renders LayerLegend when a legend is defined and the option is selected. Adds dynamic class for legend visibility. Minor formatting and structure adjustments.
src/utils/mapsV2/mapSettings.config.ts Added new LegendData type system, including RangeLegendData and CategoryLegendData. Extended LayerConfig to support an optional legend property. Populated several map layers with legend metadata for range (continuous) and category (discrete) data, specifying min/max values, units, gradients, and category colors as appropriate. Adjusted canShow flags for some layers. No changes to logic or control flow.
src/utils/multiTenancy/helpers.ts Updated exported constant DEFAULT_TENANT value from 'planet' to 'ttc'. No other changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SingleLayerOption
    participant LayerLegend

    User->>SingleLayerOption: Toggle map layer option
    SingleLayerOption->>SingleLayerOption: Check if option is selected
    alt Option is selected and has legend
        SingleLayerOption->>LayerLegend: Render legend (with legend data)
        LayerLegend->>LayerLegend: Determine legend type (range/category)
        LayerLegend->>User: Display legend UI
    end
Loading

Suggested labels

PR: reviewed-approved

Suggested reviewers

  • sunilsabatp

Poem

🐇
On maps where layers softly glow,
Legends tell the tales we know.
Colors blend and ranges show,
A rabbit’s touch makes it so!
Flip the switch, watch info grow,
In CSS and code we flow!
🌿✨
"""

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx (1)

40-66: Categorical legend implementation with proper i18n support.

The CategoryLegend component correctly renders categorical data as color blocks and uses the translation system for internationalized category labels.

One minor suggestion: consider showing all category labels instead of just the first and last for better user understanding, especially if the number of categories is small.

src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss (1)

151-181: Comprehensive styling for legends.

The legend styles provide a clean and consistent visual presentation for both range and categorical legends. The use of flexbox for layouts and proper spacing ensures good visual hierarchy.

Consider increasing the font size for legend values from 10px to at least 12px to improve readability and accessibility.

.legendValues {
-  font-size: 10px;
+  font-size: 12px;
}
src/utils/mapsV2/mapSettings.config.ts (1)

380-390: Well-structured categorical legend for fire risk.

The fire risk legend uses a categorical approach with six distinct categories and a logical color progression from yellow to dark red, representing increasing risk levels.

Consider extracting the category colors to a shared constant or theme if these colors might be reused elsewhere in the application.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb00f2e and 1216516.

⛔ Files ignored due to path filters (1)
  • public/static/locales/en/maps.json is excluded by !**/*.json
📒 Files selected for processing (4)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss (2 hunks)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx (1 hunks)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/SingleLayerOption.tsx (3 hunks)
  • src/utils/mapsV2/mapSettings.config.ts (11 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/SingleLayerOption.tsx (1)
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/CustomSwitch.tsx (1)
  • StyledSwitch (34-43)
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx (1)
src/utils/mapsV2/mapSettings.config.ts (3)
  • RangeLegendData (33-39)
  • CategoryLegendData (49-52)
  • LegendData (54-54)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: ESLint on Ubuntu
🔇 Additional comments (14)
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/SingleLayerOption.tsx (4)

27-28: Good practice: Early return for unavailable layers.

Moving the availability check to the top of the component is a good practice that prevents unnecessary rendering and improves code readability.


33-33: Clean code: Extracted selection state into a variable.

Extracting the selection state into isOptionSelected improves readability and avoids repeating the same expression multiple times in the component.


57-80: Improved structure with layerControls wrapper.

The introduction of the layerControls wrapper div provides a clean separation between the controls and the legend, allowing for better styling and layout management.


81-83: Conditional legend rendering properly implemented.

The legend is correctly rendered only when two conditions are met: the layer is selected and a legend configuration exists for the layer.

src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx (2)

22-38: Well-implemented continuous range legend component.

The RangeLegend component effectively visualizes continuous data with a gradient color scale and displays the min/max values along with optional units.


68-71: Clean type discrimination for rendering different legend types.

The main LayerLegend component effectively uses TypeScript's type discrimination to render the appropriate legend type based on the type property.

src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss (2)

122-123: Updated layout to accommodate legends.

The SingleLayerOption component has been correctly updated to use a vertical layout, providing space for the legend below the controls.


144-149: Well-structured controls layout.

The new layerControls class maintains the previous horizontal layout for the label and switch, using space-between for alignment.

src/utils/mapsV2/mapSettings.config.ts (6)

33-39: Well-defined RangeLegendData interface.

The interface provides all necessary properties for continuous data legends, including min/max values, optional units, and gradient definition.


41-52: Comprehensive category type system.

The LegendCategoryKey type and CategoryLegendData interface provide a structured approach to defining categorical legends with proper typing.


54-63: Clean integration with existing configuration system.

The LegendData type and extension of the LayerConfig interface provide a clean way to add legend support without breaking existing functionality.


98-104: Forest cover legend implementation.

The legend configuration for forestCover is well-implemented with appropriate min/max values and gradient colors.


122-129: Biomass legend with appropriate units.

The forestBiomass legend correctly includes units (t/ha) which helps users understand the data being displayed.


207-214: Consistent implementation across data layers.

The legend configurations for soil and biodiversity layers maintain a consistent approach, with appropriate values and color gradients for each data type.

Also applies to: 231-237, 255-262, 280-287, 307-313

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss (5)

121-123: Validate vertical layout and replace hardcoded gap
Switching to flex-direction: column alters the item stacking (removing the previous horizontal alignment) and gap: 4px uses a literal value. Verify this change against the design mockups, and consider replacing the gap with a theme spacing token (e.g., $spacingXSmall) to maintain consistency.


148-153: Use theme spacing for gap in .layerControls
gap: 10px is a hardcoded value; swapping it for a semantic token (e.g., $spacingSmall) will keep control spacing consistent across the app.


155-161: Leverage theme tokens for padding and gap in .layerLegend
The declarations padding: 10px and gap: 8px are literal values. To align with the design system, replace these with the appropriate theme variables (for example, $spacingSmall or $spacingXSmall).


163-166: Refine border-radius for the legend bar
border-radius: 300px is excessive for an 8px-high element. A radius of 4px (half the height) is clearer, easier to understand, and more maintainable.


179-184: Replace hardcoded font-size and margins with tokens
The .legendValues block uses font-size: 10px and margin: 0 2px. Swap these for the corresponding font-size token (e.g., $fontXXSmall) and spacing variables, and consider adding a line-height for better vertical alignment.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216516 and f2617f8.

📒 Files selected for processing (2)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss (2 hunks)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/SingleLayerOption.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/SingleLayerOption.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ESLint on Ubuntu
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss (2)

127-129: Ensure .legendVisible modifier is toggled correctly
The .legendVisible class removes the bottom border when a legend is rendered. Confirm that the SingleLayerOption component only applies this class when the legend is present—otherwise you may inadvertently drop borders in unintended states.


167-172: Support data-driven widths for category bars
With .legendCategoryColor { flex: 1 }, all categories render equally. If your legend needs to reflect proportional data, ensure the React component injects inline flex or width styles, or extend the SCSS to accept dynamic modifiers for each category.

Also applies to: 174-176

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/utils/mapsV2/mapSettings.config.ts (1)

114-114: 🛠️ Refactor suggestion

Consider enabling the forestBiomass layer

The forestBiomass layer has a legend configuration added, but canShow is still set to false. This seems inconsistent with the other layers that have legends and are now visible.

-  canShow: false,
+  canShow: true,

Also applies to: 128-135

🧹 Nitpick comments (1)
src/utils/mapsV2/mapSettings.config.ts (1)

241-247: Consider adding pH unit label for clarity

While pH is technically unitless, adding "pH units" as the unit would improve clarity for users who may not be familiar with soil science.

  legend: {
    type: 'range',
    min: 3.5,
    max: 10,
    gradient:
      'linear-gradient(90deg, #FE4242 0%, #F3F7C7 45.5%, #6C8DFF 100%)',
+   unit: 'pH units',
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91cd8a7 and e07dfa7.

📒 Files selected for processing (4)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss (2 hunks)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx (1 hunks)
  • src/utils/mapsV2/mapSettings.config.ts (15 hunks)
  • src/utils/multiTenancy/helpers.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/utils/multiTenancy/helpers.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/MapFeatureExplorer.module.scss
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: ESLint on Ubuntu
🔇 Additional comments (11)
src/utils/mapsV2/mapSettings.config.ts (11)

33-62: Well-structured legend data interfaces

The new legend data type hierarchy with SimpleLegendData, RangeLegendData, and CategoryLegendData is well-designed. The interfaces provide a clear structure for different types of legends that might be needed for various map layers.


72-72: LGTM - Good integration of legend into LayerConfig

Extending LayerConfig with an optional legend property is a clean approach that allows legends to be defined only where needed.


107-110: Appropriate simple legend for forest cover

The green color (#036201) is an intuitive choice for representing forest cover on the map.


164-164: Good deforestation visualization enablement

Enabling the deforestation layer and adding a clear red legend color (#FE1717) provides users with important information about forest loss.

Also applies to: 177-180


217-224: Verify soil nitrogen gradient colors

The soil nitrogen gradient uses yellow-to-blue colors, which is different from most other soil properties that use earth tones. Confirm this is the intended color scheme for this property.


265-272: Appropriate legend for soil organic carbon

The legend configuration for soil organic carbon uses an appropriate range and color gradient that intuitively represents carbon content from low to high.


290-297: Verify soil bulk density maximum value

The maximum value for soil bulk density is set to 176 cg/cm³ (1.76 g/cm³). Typical soil bulk densities rarely exceed 2 g/cm³, so this range seems appropriate, but please verify with domain experts.


317-324: Good species density gradient

The gradient from light to dark green for tree species density is intuitive and visually appropriate for representing biodiversity levels.


328-348: Well-implemented biodiversity legends with distinct color schemes

Enabling the bird, mammal, and amphibian density layers with appropriate color gradients (blue, red, and green respectively) helps users distinguish between different biodiversity metrics while maintaining a consistent design pattern.

Also applies to: 352-371, 375-394


412-422: Excellent categorical legend for fire risk

The fire risk legend uses an intuitive progression from yellow to dark red across six categories, making it easy for users to understand the severity levels.


153-160:

❓ Verification inconclusive

Verify identical legend configurations

The biomassPotential legend has identical configuration (range, gradient, unit) as forestBiomass. Please verify this is intentional and not a copy-paste error.


🏁 Script executed:

#!/bin/bash
# Check if other layers have identical ranges and units that might need to be differentiated
echo "Checking for potentially identical legend configurations..."
grep -A 8 "legend: {" src/utils/mapsV2/mapSettings.config.ts | grep -E "min:|max:|unit:"

Length of output: 789


Verify duplicate legend configurations

It looks like both forestBiomass and biomassPotential in src/utils/mapsV2/mapSettings.config.ts use the exact same legend settings (min: 0, max: 376, gradient, unit: ‘t/ha’). Please confirm this is intentional and, if not, adjust the range/gradient/unit for the appropriate layer.

• Affected location:

  • src/utils/mapsV2/mapSettings.config.ts – legend entries for forestBiomass vs biomassPotential

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/utils/mapsV2/mapSettings.config.ts (1)

201-208: Consider adjusting soilNitrogen gradient colors

The soilNitrogen legend uses a yellow-blue gradient, which might not be the most intuitive color scheme for nitrogen content. Consider using a more standard color scale that better represents the data range.

-        gradient:
-          'linear-gradient(90deg, #FFF59A 0%, #FEFB27 48%, #6C8DFF 100%)',
+        gradient:
+          'linear-gradient(90deg, #FFF59A 0%, #A7DB54 48%, #38812F 100%)',
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e07dfa7 and ead8974.

📒 Files selected for processing (2)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx (1 hunks)
  • src/utils/mapsV2/mapSettings.config.ts (13 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/features/projectsV2/ProjectsMap/MapFeatureExplorer/microComponents/LayerLegend.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ESLint on Ubuntu
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (10)
src/utils/mapsV2/mapSettings.config.ts (10)

33-54: Well-structured legend interfaces

The new interfaces for legends are well-defined and provide good type safety. The RangeLegendData interface handles numeric ranges with min/max values, optional units, and CSS gradients, while CategoryLegendData handles categorical data with predefined keys and colors.


64-64: Clean interface extension

Adding the optional legend property to the LayerConfig interface is a non-breaking change that enhances functionality without disrupting existing code.


116-123: Good use of range legend for forestBiomass

The legend configuration includes appropriate min/max values, units (t/ha), and a color gradient that intuitively represents biomass levels from low (light yellow) to high (dark green).


152-152: Deforestation layer visibility changed

The canShow property for the deforestation layer has been changed from false to true. Ensure this is intentional and that the layer data is ready for public display.


225-231: Appropriate pH scale and color gradient

The soilPH legend correctly uses a range of 3.5-10 with a red-yellow-blue gradient that follows standard pH color conventions (acidic to alkaline). Also correctly omits units as pH is unitless.


326-332: Consistent unit definitions for biodiversity layers

Good job maintaining consistent unit formatting ("{species}/ha") across all biodiversity layers, which helps users understand and compare the data.

Also applies to: 349-355, 372-378


396-406: Clear categorical legend for fire risk

The fire risk legend effectively uses a categorical approach with six distinct levels, each with an appropriate color that intuitively represents increasing risk intensity from yellow to dark red.


312-312:

❓ Verification inconclusive

Multiple biodiversity layers made visible

The canShow property has been changed from false to true for birdDensity, mammalDensity, and amphibianDensity layers. Verify that these layers are ready for public display and the data is available.

Also applies to: 336-336, 359-359


🏁 Script executed:

#!/bin/bash
# Check if these layers are referenced in any documentation or API endpoints
grep -r "birdDensity\|mammalDensity\|amphibianDensity" --include="*.ts" --include="*.tsx" --include="*.md" .

Length of output: 502


Verify biodiversity layer readiness

A grep search shows that birdDensity, mammalDensity, and amphibianDensity only appear in
src/utils/mapsV2/mapSettings.config.ts (lines 312, 336, and 359) and aren’t referenced in any documentation or API endpoints.

• Please confirm with the data team that these layers are fully populated and suitable for public display.
• If needed, update any API definitions and documentation to include these new biodiversity layers.


274-281:

❓ Verification inconclusive

Verify soilBulkDensity max value

The max value for soilBulkDensity is set to 176 cg/cm³ (1.76 g/cm³), which seems low for some soil types. Typical soil bulk density ranges from 1.0 to 2.0+ g/cm³. Verify this maximum value against the actual data.


🌐 Web query:

What is the typical range for soil bulk density in g/cm³?

💡 Result:

Soil bulk density typically ranges from 1.0 to 1.8 g/cm³ for mineral soils, though this can vary depending on soil type, texture, depth, and management practices[8].

The bulk density of soil is defined as the mass of dry soil per unit of bulk volume, including the air space[8]. This measurement is important as it serves as an indicator of soil compaction and affects various soil properties such as infiltration, rooting depth, available water capacity, soil porosity, nutrient availability, and microbial activity[7].

Different sources report slightly varying ranges:

  • According to FAO's Global Soil Laboratory Network, typical values range from 1.0 to 1.7 g/cm³[10]
  • Generally, bulk densities in undisturbed soils range from about 1.0 to 1.4 g/cm³
  • A sampling study in Oklahoma from 47 fields reported an average bulk density of 1.45 g/cm³ up to 30 cm depth, with measurements ranging from 1.23 to 1.67 g/cm³[1][9]

Soil texture affects bulk density values:

  • Sandy soils usually have higher bulk densities (1.3–1.7 g/cm³) than fine silts and clays (1.1–1.6 g/cm³) because they have larger but fewer pore spaces[3]
  • Soils rich in organic matter, such as peaty soils, can have densities of less than 0.5 g/cm³[3]

The bulk density also varies based on soil depth, with subsurface layers typically having higher bulk density values than surface layers due to less organic matter, reduced aggregation, and fewer root penetrations[7][9].

Citations:


Verify soilBulkDensity max value

The legend’s max is currently set to 176 cg/cm³ (1.76 g/cm³), which aligns with typical mineral soil bulk densities (≈1.0–1.8 g/cm³). Please confirm that 1.76 g/cm³ matches the maximum in our underlying dataset, and adjust if your data exceed this value.

• File: src/utils/mapsV2/mapSettings.config.ts
Lines: 274–281 — legend.max should reflect the true maximum bulk density from your data.


141-148:

❓ Verification inconclusive

Ensure biomassPotential legend is accurate

The biomassPotential legend uses identical values and gradient as forestBiomass. Verify that these two datasets actually share the same range and scale.


🏁 Script executed:

#!/bin/bash
# Check if these two layers use the same data scale in the API or in any documentation
grep -r "biomassPotential.*range\|forestBiomass.*range" --include="*.ts" --include="*.tsx" .

Length of output: 94


🏁 Script executed:

#!/bin/bash
# Locate legend configurations for both layers in the config file
grep -R -nE "forestBiomass" --include="*.ts" src/utils/mapsV2/mapSettings.config.ts
grep -R -nE "biomassPotential" --include="*.ts" src/utils/mapsV2/mapSettings.config.ts

Length of output: 284


🏁 Script executed:

#!/bin/bash
# Extract legend configuration for forestBiomass from mapSettings.config.ts
grep -R -n -A7 -B3 "key: 'forestBiomass'" src/utils/mapsV2/mapSettings.config.ts

Length of output: 401


🏁 Script executed:

#!/bin/bash
# Extract legend configuration for forestBiomass
grep -R -n -A20 "key: 'forestBiomass'" src/utils/mapsV2/mapSettings.config.ts

# Extract legend configuration for biomassPotential
grep -R -n -A20 "key: 'biomassPotential'" src/utils/mapsV2/mapSettings.config.ts

Length of output: 1696


Verify biomassPotential legend range and gradient

Both forestBiomass (lines 117–120) and biomassPotential (lines 141–144) in src/utils/mapsV2/mapSettings.config.ts use an identical legend configuration:

  • type: 'range'
  • min: 0
  • max: 376
  • gradient: 'linear-gradient(90deg, #FFF59A 0%, #FEFB27 48%, #36670C 100%)'

Please confirm against the Walker et al. 2022 dataset (or API docs) that the potential biomass values truly span the same 0–376 t/ha range and use this color ramp. If the scale differs, update the min/max and/or gradient to reflect the correct potential biomass distribution.

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

Successfully merging this pull request may close these issues.

2 participants