Annual NLCD geeViz Viewer#

  • This script provides a view of annual NLCD: https://gee-community-catalog.org/projects/annual_nlcd/

  • It displays the land cover/land use and impervious products as well as change products


Copyright 2024 Ian Housman

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Open in Colab

import os,sys
sys.path.append(os.getcwd())

#Module imports
try:
    import geeViz.geeView as gv
except:
    !python -m pip install geeViz
    import geeViz.geeView as gv



ee = gv.ee
Map = gv.Map

print('Done')
Done

View and explore NLCD Land Cover and Land Use#

Adapted from: https://code.earthengine.google.com/?scriptPath=users%2Fsat-io%2Fawesome-gee-catalog-examples%3Aregional-landuse-landcover%2FNLCD-ANNUAL-LANDCOVER

This example allows you to quickly visualize and summarize Annual NLCD Land Cover and Land Use outputs

Map.clearMap()

nlcd_landcover = ee.ImageCollection("projects/sat-io/open-datasets/USGS/ANNUAL_NLCD/LANDCOVER")
# Zoom somewhere with a lot of change
Map.setCenter(-115.1393, 36.1408,10)

# Use the GEE built-in properties for symbology by setting the properties as follows
landCoverVizProps = {'LC_class_values': [11, 12, 21, 22, 23, 24, 31, 41, 42, 43, 52, 71, 81, 82, 90, 95],
'LC_class_palette' : [
  '466b9f', 'd1def8', 'dec5c5', 'd99282', 'eb0000', 'ab0000',
  'b3ac9f', '68ab5f', '1c5f2c', 'b5c58f', 'ccb879', 'dfdfc2', 
  'dcd939', 'ab6c28', 'b8d9eb', '6c9fb8'
],
'LC_class_names' : [
  "Open Water", "Perennial Ice/Snow", "Developed, Open Space", "Developed, Low Intensity", 
  "Developed, Medium Intensity", "Developed, High Intensity", "Barren Land", 
  "Deciduous Forest", "Evergreen Forest", "Mixed Forest", "Shrub/Scrub", 
  "Grassland/Herbaceous", "Pasture/Hay", "Cultivated Crops", "Woody Wetlands", 
  "Emergent Herbaceous Wetlands"
]
}

lc_vizParams = {'reducer':ee.Reducer.mode(),'autoViz':True,'canAreaChart':True,'areaChartParams':{'line':True,'sankey':True,'sankeyMinPercentage':0.1}}

nlcd_landcover = nlcd_landcover.map(lambda img:img.rename('LC').set(landCoverVizProps))

addLayerFun = Map.addTimeLapse # Specify Map.addLayer or Map.addTimeLapse
addLayerFun(nlcd_landcover,lc_vizParams,'Annual NLCD Land Cover and Land Use')


# Map.turnOnInspector()
Map.turnOnAutoAreaCharting()
Map.view()
Adding layer: Annual NLCD Land Cover and Land Use
Starting webmap
Using default refresh token for geeView
Local web server at: http://localhost:8001/geeView/ already serving.
cwd a:\GEE\gee_py_modules_package\geeViz\examples
geeView URL: http://localhost:8001/geeView/?projectID=lcms-292214&accessToken=ya29.a0AeDClZBUBXezc6xttXaCq0WuwuuEp5720zhPBMybcBmwQcFMbs_NecpObnotAUQz6ZHGFZ48wJI1Sri6U099apNO2Cgr-zs940pb6t4v8czb374-eD9fZu0D6mnKFhj4D0DWsnyoivzJlirxwJxJhRCs5vFiWg7G59sfUI1hr5waCgYKAXsSARESFQHGX2MiJ3qogLz8PseDAi4ikMdTJg0178

View and explore Annual NLCD Fractional Impervious Surface#

This will show a time-lapse of the Annual NLCD Fractional Impervious Surface and Impervious Descriptor datasets. It will also provide zonal summaries as charts.

Map.clearMap()

# Set up visualization parameters 
fractional_impervious_surface_vizParams= {'canAreaChart':True,'min': 1, 'max': 100, 'palette': ['#d3d3d3', '#c9b1b1', '#b38484', '#e75454', '#ff7fbf', '#cc66cc', '#9933cc', '#660099']}
impervious_descriptor_vizParams = {'reducer':ee.Reducer.mode(),'autoViz':True,'canAreaChart':True,'areaChartParams':{'line':True,'sankey':True,'sankeyMinPercentage':0.1}}

imperviousDescriptorVizProps = {'ID_class_values':[0,1,2],'ID_class_palette':['000000', '2171b5', 'f6ec27'],'ID_class_names':['No Data','Roads','Urban']}

# Bring in collections and set viz properties
nlcd_fractional_impervious_surface = ee.ImageCollection("projects/sat-io/open-datasets/USGS/ANNUAL_NLCD/FRACTIONAL_IMPERVIOUS_SURFACE")
nlcd_impervious_descriptor = ee.ImageCollection("projects/sat-io/open-datasets/USGS/ANNUAL_NLCD/IMPERVIOUS_DESCRIPTOR")
nlcd_impervious_descriptor = nlcd_impervious_descriptor.select([0],['ID']).map(lambda img:img.set(imperviousDescriptorVizProps))

# Add layers to the map
addLayerFun = Map.addTimeLapse # Specify Map.addLayer or Map.addTimeLapse
addLayerFun(nlcd_fractional_impervious_surface,fractional_impervious_surface_vizParams,'NLCD Percent Impervious')
addLayerFun(nlcd_impervious_descriptor,impervious_descriptor_vizParams,'NLCD Percent Impervious Descriptor')


# View the map
Map.turnOnAutoAreaCharting()
# Map.turnOnInspector()
Map.view()
Adding layer: NLCD Percent Impervious
Adding layer: NLCD Percent Impervious Descriptor
Starting webmap
Using default refresh token for geeView
Local web server at: http://localhost:8001/geeView/ already serving.
cwd a:\GEE\gee_py_modules_package\geeViz\examples
geeView URL: http://localhost:8001/geeView/?projectID=lcms-292214&accessToken=ya29.a0AeDClZD51cbEj3BJuT9MD_VxnDbdGkYhZFeNitx1pjG3DRra8E21GR7sKMbDUJ9LLJIfSNWwe2Rm6ieJS2grQZMClatlPl0RchGFD0WjkH0NOQv9__NpP85uK3amyw1SCDhSswdYUKgUsswxRlVroGEGhTw9zBQsDrh0RBracyMaCgYKATQSARESFQHGX2Mif6k2SMZW3mIcAtMHOBR9NA0178

View and explore Annual NLCD Spectral Change#

This example will show the day of year of spectral change

Note that 0 is not set to null by default, and therefore will be resampled as actual data as you zoom out. While it is masked in this example, you will have to zoom in to zoom level ~12 or so to start seeing 0 values all being set to null.

Map.clearMap()
spectral_change_doy_vizParams= {'canAreaChart':True,'areaChartParams':{'reducer':ee.Reducer.mode()},'min': 1, 'max': 366, 'palette': ['#6a0dad', '#483d8b', '#1e90ff', '#00fa9a', '#32cd32', '#ffff00', '#ff8c00', '#ff4500', '#ff0000']}

nlcd_spectral_change_doy = ee.ImageCollection("projects/sat-io/open-datasets/USGS/ANNUAL_NLCD/SPECTRAL_CHANGE_DOY")

# Mask out 0 values since they are not masked out by default - does not work with lower zoom levels
nlcd_spectral_change_doy  = nlcd_spectral_change_doy.map(lambda img:img.selfMask())

addLayerFun = Map.addTimeLapse
addLayerFun(nlcd_spectral_change_doy,spectral_change_doy_vizParams,'Spectral Change DOY')

Map.turnOnInspector()
Map.view()
Adding layer: Spectral Change DOY
Starting webmap
Using default refresh token for geeView
Local web server at: http://localhost:8001/geeView/ already serving.
cwd a:\GEE\gee_py_modules_package\geeViz\examples
geeView URL: http://localhost:8001/geeView/?projectID=lcms-292214&accessToken=ya29.a0AeDClZDOw7snwA-nBYiE9b1EYSE5gLHZS7wxuTGzHtNlrm7LMHDDrPJMpMLs1O6FjS44_v_FUUrpXNiJc-SpQralQG3SVNhqb-l_PV0NPLpwUKO6xwodCOdL7nHVvlKtWxD5WFl6H17z9FH1h5RsyvMsZAK6yBJzHXbkiB2o7OUaCgYKAZ8SARESFQHGX2MiE0KOlcU1Ti8H6feVwDu-LA0178