Processing NLCD for USA using Raster Calculator and tools in QGIS
Step By Step Procedure for Processing NLCD for the USA using the Raster Calculator, Up sampling and GRASS r.neighbors NOTE: This "raster calculator" process or method is considered suboptimal to the Python script method below. The Python script method below has newer smoothing processes. However, this method does contain useful knowledge on how to use the raster calculator. It needs to be updated to match the Python script method.
We will use a predetermined file naming convention throughout this procedure for simplicity. You can use a naming convention of your choice. The below python script produces more refined scenery than this method. I left this documentation though as it is a good starting point and has examples of how you can manipulate rasters using the calculator. It was the first steps I took to learn how all this stuff works. It could be updated to match all the steps used in the python script method.
Obtain your NLCD_2019_Land_Cover from source of choice, https://www.mrlc.gov/viewer/
NLCD_2019_Land_Cover data = NLCD_2019_Land_Cover_California-Southern.tiff
Obtain your NLCD_2016_Tree_Canopy from source of choice, https://www.mrlc.gov/viewer/
NLCD_2016_Tree_Canopy data = NLCD_2016_Tree_Canopy_California-Southern.tiff
Make Deciduous Layer 255 to 0 EPSG:5070 - NAD83 - Raster Calculator
("NLCD_2016_Tree_Canopy_California-Southern@1" = 255) * 0 + ("NLCD_2016_Tree_Canopy_California-Southern@1" != 255) * "NLCD_2016_Tree_Canopy_California-Southern@1"
Output CRS = EPSG:5070 - NAD83
Output Layer = California-Southern_deciduous-coast-clipped.tiff
OK
Make Tree Canopy Layer EPSG:5070 - NAD83 - Raster Calculator
Use the prevailing tree type, for Deciduous use * 41, for Evergreen use * 42, for MixedForest use 43.
Later we add this Tree Canopy layer to the raster where there is currently no trees in the NLCD
If ocean bordering with index 255 -
("California-Southern_deciduous-coast-clipped@1" != 0) * 42
Else
("NLCD_2016_Tree_Canopy_California-Southern@1" != 0) * 42
Output CRS = EPSG:5070 - NAD83
Output Layer = California-Southern_deciduous.tiff
OK
Make Clipped Ocean Frontage EPSG:5070 - NAD83 - GIMP
Source = NLCD_2019_Land_Cover_California-Southern.tiff
Flood fill index 11 (blue) with 0 (black)
Export tiff = California-Southern_coast-clipped.tiff
Warp NLCD Deciduous and Base NLCD from EPSG:5070 - NAD83 / Conus Albers NLCD to Project CRS: EPSG:4326 - WGS 84 - WARP
If ocean bordering with index 255
Warp California-Southern_coast-clipped.tiff
Else
Warp NLCD_2016_Tree_Canopy_California-Southern.tiff
and
Warp Deciduous NLCD from EPSG:5070 - NAD83 / Conus Albers NLCD to Project CRS: EPSG:4326 - WGS 84
Warp California-Southern_deciduous.tiff
Raster -> Projection - > Warp
Target CRS = EPSG:4326 - WGS 84
Resampling method to use = Nearest Neighbour
Output data type = byte
Reprojected = California-Southern_4326-84.tiff and California-Southern_deciduous_4326-84.tiff
Run
Combine "California-Southern_deciduous_4326-84.@1" and "California-Southern_4326-84@1" - Raster Calculator
This step adds the Tree Canopy layer to the existing NLCD raster only where there is currently no existing tree land cover.
(("California-Southern_4326-84@1" > 0 AND "California-Southern_4326-84@1" != 41 AND "California-Southern_4326-84@1" != 42 AND "California-Southern_4326-84@1" != 43) AND "California-Southern_deciduous_4326-84@1" > 0) * "California-Southern_deciduous_4326-84@1" + ("California-Southern_4326-84@1" = 41 OR "California-Southern_4326-84@1" = 42 OR "California-Southern_4326-84@1" = 43 OR "California-Southern_deciduous_4326-84@1" <= 0) * "California-Southern_4326-84@1"
Output CRS = EPSG:4326 - WGS 84
Output Layer = California-Southern_adjusted.tiff
OK
Re-class urban 21, 22, 23, 24 = grass 26 - Raster Calculator
This step is being used to erase all the man made clutter on the raster with grassland. Instead of grassland you can replace it with any type of prevailing groundcover in the area your processing.
For example this places a road easement of grass on all the road clutter that was originally in the raster. If your processing a desert area you might want to use dirt or sand instead of grassland. For Arctic areas maybe use tundra.
Part of the clutter gets replaced later in the process.
("California-Southern_adjusted@1" = 11) * 41 + ("California-Southern_adjusted@1" = 12) * 34 + ("California-Southern_adjusted@1" = 21) * 26 + ("California-Southern_adjusted@1" = 22) * 26 + ("California-Southern_adjusted@1" = 23) * 26 + ("California-Southern_adjusted@1" = 24) * 26 + ("California-Southern_adjusted@1" = 31) * 27 + ("California-Southern_adjusted@1" = 41) * 26 + ("California-Southern_adjusted@1" = 42) * 24 + ("California-Southern_adjusted@1" = 43) * 25 + ("California-Southern_adjusted@1" = 51) * 30 + ("California-Southern_adjusted@1" = 52) * 29 + ("California-Southern_adjusted@1" = 71) * 26 + ("California-Southern_adjusted@1" = 72) * 32 + ("California-Southern_adjusted@1" = 73) * 31 + ("California-Southern_adjusted@1" = 74) * 31 + ("California-Southern_adjusted@1" = 75) * 32 + ("California-Southern_adjusted@1" = 81) * 18 + ("California-Southern_adjusted@1" = 82) * 19 + ("California-Southern_adjusted@1" = 90) * 25 + ("California-Southern_adjusted@1" = 95) * 35
Output CRS = EPSG:4326 - WGS 84
Output Layer = California-Southern_reclass-grass.tiff
OK
Make Urban layer
("California-Southern_adjusted@1" = 21) * 10 + ("California-Southern_adjusted@1" = 22) * 1 + ("California-Southern_adjusted@1" = 23) * 1 + ("California-Southern_adjusted@1" = 24) * 2
Output CRS = EPSG:4326 - WGS 84
Output Layer = California-Southern_urban.tiff
OK
Remove the road clutter with r.neighbor
GRASS/Raster/r.neighbor
Neighborhood operation = median
Neighborhood size = 7
Neighbors = California-Southern_urban-only.tiff
Run
Combine "California-Southern_reclass-urban@1" and "California-Southern_reclass-grass@1"
This step replaces the "cleaned up" urban areas back into the raster.
("California-Southern_urban-only@1" < 1) * "California-Southern_reclass-grass@1" + ("California-Southern_urban-only@1" != 0) * "California-Southern_urban-only@1"
Output CRS = EPSG:4326 - WGS 84
Output Layer = California-Southern_adjusted-combined.tiff
OK
Up sample California-Southern_adjusted-combined.tiff 2x, 4x or 8x resolution 0.00008309125
Active Layer = California-Southern_adjusted-combined.tiff
Layer/Save As
2x Horizontal = 0.00008309125
2x Vertical = 0.00008309125
4x Horizontal = 0.00010637625
4x Vertical = 0.00010637625
8x Horizontal = 0.00005318812
8x Vertical = 0.00005318812
File Name = California-Southern_final-prep-4x.tiff
OK
Simplify California-Southern_4326-84-hd.tiff with r.neighbor
GRASS/Raster/r.neighbor
Neighborhood operation = median
Neighborhood size = 7
Neighbors = California-Southern_urban-only.tiff
Run
Reclass index 0 to 44, leave the rest the same
("California-Southern_4326-84-hd@1" = 0) * 44 + ("California-Southern_4326-84-hd@1" != 0) * "California-Southern_4326-84-hd@1"
Output CRS = EPSG:4326 - WGS 84
Output Layer = California-Southern_4326-84-hd-corrected.tiff
OK
Optional HD Fresh Water Option
Step 1 - Obtain and load hi resolution vector layer Make sure that the vector layer and the raster layer you will eventually merge to have the same projection. ** Extent can be different if you use the option below.
Use Top Menu: "Raster" -> "Conversion" -> "Rasterize (vector to raster)" or Processing Toolbox: GDAL -> "Vector conversion" -> "Rasterize (vector to raster)" Input layer = Southern-California_water_4326-84 Fixed value to burn = 41 (water) Output raster size units = "Georeferenced units" Width/Horizontal resolution = 0.00008309125 (4x the base NLCD resolution ) Height/Vertical resolution = 0.00008309125 (4x the base NLCD resolution)
- Output extent = Select the raster layer you will eventually merge with as the "Output extent".
Under "Rasterized" choose a new filename to save the new raster to. We'll use Southern-California_4326-84-hd-water.tiff.
Click "Run" to generate the hi resolution raster layer.
Step 2 - Reclass hi res, smoothed water to grass Open Raster Calculator Under "Output layer" choose a new filename to save the new raster to. We'll use Southern-California_4326-84-hd-nowater.tiff. Copy the following into the "Raster Calculator Expression" box. Where Southern-California_4326-84-hd is the name of your hi resolution, smoothed NLCD that includes the water data. "Southern-California_4326-84-hd@1" * ("Southern-California_4326-84-hd@1" != 41) + 26 * ("Southern-California_4326-84-hd@1 = 41")
Click on "OK". When finished you will have a new raster with the water layer changed to grassland. Another choice would be to change it to sand.
Step 3 - Combine the hi resolution no water raster and the hi resolution water raster. Use Top Menu: "Raster" -> "Miscellaneous" -> "Merge" or Processing Toolbax: GDAL -> Raster Miscellaneous -> Merge Input layers = Select "Southern-California_4326-84-hd-nowater@1" and Southern-California_4326-84-hd-water.tiff Output data type = "byte". Under "Merged" choose a new filename to save the new raster to. We'll use Southern-California_4326-84-hdwater.tiff.
Click "Run" to generate the new merged hi resolution raster layer.