Skip to content

Commit

Permalink
Merge pull request #3575 from WikiWatershed/tt/switch-to-correct-nlcd…
Browse files Browse the repository at this point in the history
…-layers

Closes #3571
  • Loading branch information
rajadain authored Oct 18, 2022
2 parents 273af42 + 3fd4244 commit 97a33e8
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/mmw/apps/geoprocessing_api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@
)

nlcd_override_allowed_values = '", "'.join([
'nlcd-2019-30m-epsg5070-512-byte',
'nlcd-2016-30m-epsg5070-512-byte',
'nlcd-2011-30m-epsg5070-512-byte',
'nlcd-2006-30m-epsg5070-512-byte',
'nlcd-2001-30m-epsg5070-512-byte',
'nlcd-2019-30m-epsg5070-512-uint8raw',
'nlcd-2016-30m-epsg5070-512-uint8raw',
'nlcd-2011-30m-epsg5070-512-uint8raw',
'nlcd-2006-30m-epsg5070-512-uint8raw',
'nlcd-2001-30m-epsg5070-512-uint8raw',
'nlcd-2011-30m-epsg5070-512-int8',
])
LAYER_OVERRIDES = Schema(
Expand All @@ -209,12 +209,12 @@
properties={
'__LAND__': Schema(
type=TYPE_STRING,
example='nlcd-2019-30m-epsg5070-512-byte',
example='nlcd-2019-30m-epsg5070-512-uint8raw',
description='The NLCD layer to use. Valid options are: '
f'"{nlcd_override_allowed_values}". All "-byte" '
f'"{nlcd_override_allowed_values}". All "-uint8raw" '
'layers are from the NLCD19 product. The "-int8" '
'layer is from the NLCD11 product. The default value '
'is NLCD19 2019 "nlcd-2019-30m-epsg5070-512-byte".',
'is NLCD19 2019 "nlcd-2019-30m-epsg5070-512-uint8raw".'
),
'__STREAMS__': Schema(
type=TYPE_STRING,
Expand Down
2 changes: 1 addition & 1 deletion src/mmw/apps/geoprocessing_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def start_analyze_land(request, nlcd_year, format=None):

nlcd, year = nlcd_year.split('_')
if nlcd == '2019' and year in ['2019', '2016', '2011', '2006', '2001']:
layer_overrides['__LAND__'] = f'nlcd-{year}-30m-epsg5070-512-byte'
layer_overrides['__LAND__'] = f'nlcd-{year}-30m-epsg5070-512-uint8raw'

return start_celery_job([
geoprocessing.run.s('nlcd_ara', geop_input, wkaoi,
Expand Down
2 changes: 1 addition & 1 deletion src/mmw/apps/modeling/calcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def get_layer_value(layer, layer_overrides=dict):
If the default config is something like:
{
'__LAND__': 'nlcd-2019-30m-epsg5070-512-byte',
'__LAND__': 'nlcd-2019-30m-epsg5070-512-uint8raw',
'__SOIL__': 'ssurgo-hydro-groups-30m-epsg5070-512-int8',
'__STREAMS__': 'nhd',
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 3.2.13 on 2022-10-17 13:47

from django.db import migrations


def clear_nlcd2019_gwlfe_results(apps, schema_editor):
"""
Clear the results for all scenarios belonging to GWLF-E projects made after
the release of 1.33.0, which had incorrectly aligned NLCD19 2019 on
2022-01-17:
https://github.com/WikiWatershed/model-my-watershed/releases/tag/1.33.0
These results will be recalculated with the correclty aligned NLCD19 values
when these projects are accessed again.
"""
Project = apps.get_model('modeling', 'Project')
Scenario = apps.get_model('modeling', 'Scenario')

Project.objects.filter(
model_package='gwlfe',
created_at__gte='2022-01-17',
).update(
gis_data=None,
mapshed_job_uuid=None,
subbasin_mapshed_job_uuid=None,
)

Scenario.objects.filter(
project__model_package='gwlfe',
project__created_at__gte='2022-01-17',
).update(
results='[]',
modification_hash='',
)


class Migration(migrations.Migration):

dependencies = [
('modeling', '0040_clear_nlcd2019_tr55_results'),
]

operations = [
migrations.RunPython(clear_nlcd2019_gwlfe_results),
]
10 changes: 5 additions & 5 deletions src/mmw/js/src/modeling/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ module.exports = {
layerOverrideToDefaultLandCoverType: function(layer_overrides) {
var raster = layer_overrides && _.get(layer_overrides, "__LAND__"),
mapping = {
"nlcd-2019-30m-epsg5070-512-byte": "land_2019_2019",
"nlcd-2016-30m-epsg5070-512-byte": "land_2019_2016",
"nlcd-2011-30m-epsg5070-512-byte": "land_2019_2011",
"nlcd-2006-30m-epsg5070-512-byte": "land_2019_2006",
"nlcd-2001-30m-epsg5070-512-byte": "land_2019_2001",
"nlcd-2019-30m-epsg5070-512-uint8raw": "land_2019_2019",
"nlcd-2016-30m-epsg5070-512-uint8raw": "land_2019_2016",
"nlcd-2011-30m-epsg5070-512-uint8raw": "land_2019_2011",
"nlcd-2006-30m-epsg5070-512-uint8raw": "land_2019_2006",
"nlcd-2001-30m-epsg5070-512-uint8raw": "land_2019_2001",
"nlcd-2011-30m-epsg5070-512-int8": "land_2011_2011",
};

Expand Down
2 changes: 1 addition & 1 deletion src/mmw/mmw/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def get_env_setting(setting):
'__BFI__': 'bfi48grd-epsg5070',
'__GWN__': 'us-groundwater-nitrogen-30m-epsg5070-512',
'__KFACTOR__': 'us-ssugro-kfactor-30m-epsg5070-512',
'__LAND__': 'nlcd-2019-30m-epsg5070-512-byte',
'__LAND__': 'nlcd-2019-30m-epsg5070-512-uint8raw',
'__NED__': 'ned-nhdplus-30m-epsg5070-512',
'__PROTECTED_LANDS__': 'protected-lands-30m-epsg5070-512',
'__SLOPE__': 'us-percent-slope-30m-epsg5070-512',
Expand Down

0 comments on commit 97a33e8

Please sign in to comment.