Why does my hillshade look different when I use a tool vs. a function?
Your hillshade results will look different because your hillshade is applied to the data at a different scale.
The Hillshade tool is applied at the source pixel size of the data; then the resulting raster is resampled as you zoom out on your display. In contrast, the Hillshade function is applied at the scale in which you are viewing the imagery, first resampling the DEM to that resolution before applying the hillshade effect.
When you apply hillshading at the source pixel size, the two hillshaded images will appear the same.
Functions are applied on your data after the images have been resampled, whereas geoprocessing tools are applied at the source pixel size of your data.
resampling + process ≠ process + resampling
Resampling the pixel size then applying a process, such as hillshading, will not always provide the same results as applying the process then resampling.
How to apply a hillshade
When you use the Hillshade tool, found in the Spatial Analyst or 3D Analyst toolboxes, the hillshade is applied on the DEM at the source pixel size of the raster dataset.
The source pixel can be affected by the Cell Size parameter in the Environment Settings.
The Hillshade function is applied on-the-fly; therefore, it can be affected by the scale, mosaic methods, selected images, and so on. When you use the Hillshade function the hillshade is applied on the DEM at the displayed resolution of the raster.
Both the Hillshade tool and Hillshade function use the azimuth and altitude parameters and sometimes a z factor.
The diagrams below represent a profile taken across a hill in a DEM. The DEM has been resampled from 30 m to 120 m and to 300 m, but the profile line has not changed.
At the highest resolution (30 m), the profile results in the most detail that can be attained from this dataset to represent the shape of the hill along the line.
When the pixel of the DEM is resampled to be four times greater, the pixel size increases to 120 m and you can see there is a loss of detail along the profile line. As you continue to increase the pixel size of the DEM to 10 times the original (300 m), many of the features present in the higher resolution DEM are no longer represented. For example, between 500 and 1,000 the peaks and valleys in the profile are degraded from the 30 m to the 120 m, and the valley is completely removed from the 300 m representation. Also, the peak present at approximately 1,900 is much higher in the more detailed image than it is in the others.
Resampling the pixel size is similar to what happens when you zoom out to a smaller scale. For example, if your display is 100x100 pixels, and the full size of your data is 1000x1000 pixels, you would have to pan across the image several times to see the entire image. But if you zoom out at a factor of 10, to fit your 1,000 pixels into 100 pixels, you are essentially resampling your image from 1000x to 100x. Therefore, a pixel size of 1 becomes 10.
Depending on the azimuth and altitude of the sun in the hillshading equation, the valley between the 500–1,000 area will be very bright and dark in the 30 m representation. If this representation is then resampled to lower resolutions, this feature will be altered as the pixels are resampled. Depending on the resampling method, this feature may still exist in the hillshaded image when the feature would not exist at a specific scale, as shown in the bottom image. This is one reason why the hillshaded images produced using functions versus tools is different at different scales.
In the examples below, the stretch used to compare is a Minimum/ Maximum stretch using the same parameters.
The first table shows the displayed difference in a hillshade applied at very small scales using a function and using a tool. The second table shows the same image at the full resolution, where you can see the images are identical.
Hillshade scale 1:10,000,00
Hillshade scale 1:1,000,00
Hillshade scale 1:116,740; Full resolution
In these three examples, you can see that the pixel size of the DEM at the time the hillshade is applied makes a significant difference, thereby enforcing resampling + hillshading ≠ hillshading + resampling.
In this example, where the hillshading is applied at the source pixel size of the DEM, the results are the same. This is because resampling is taken out of the equation and only the hillshading process is applied to the data.
The z factor is a scaling factor used to convert the elevation values. This value is often overlooked, but it is important to consider when creating a hillshade, because it has a significant impact on the appearance of the output. The scaling factor is used for two purposes: first, to convert the elevation units (such as meters or feet) to the horizontal coordinate units of the dataset, which may be feet, meters, or degrees, and second, to add vertical exaggeration for visual effect
To convert from feet to meters or vice versa, see the table below. For example, if your DEM's elevation units are feet and your mosaic dataset's units are meters, you would use a value of 0.3048 to convert your elevation units from feet to meters (1 foot = 0.3048 meters).
This is also useful when you have geographic data (such as DTED in GCS_WGS 84 using latitude and longitude coordinates) where the elevation units are in meters. In this case, you need to convert from meters to degrees (0.00001; see below). The value for degree conversions are approximations.
To apply vertical exaggeration, you must multiply the conversion factor by the exaggeration factor. For example, if both elevation and dataset coordinates are meters and you want to exaggerate by a multiple of 10, the scaling factor would be unit conversion factor (1.0 from the table) multiplied by the vertical exaggeration factor (10.0), or 10. As another example, if the elevations are meters and the dataset is geographic (degrees), you would multiply the units conversion factor (0.00001) by 10 to get 0.0001.
Applying the function to achieve the tool-like results
In the examples above the results are compared using the Hillshade function, generally on a mosaic dataset, versus using the Hillshade tool. As already noted, the main difference occurs as a result of when the resampling and hillshading is applied. In the diagrams below you can see that where the function is inserted in a mosaic dataset can impact the results. To attain the same results the resampling and hillshading process variables need to be the same. Therefore, only when you are viewing the image at a 1:1 resolution will the function provide the same visual results as the tool. You can achieve these tool-like results if you insert the function on the raster dataset within the mosaic dataset, as long as there are no pyramids for the raster dataset. This is because the function is applied before the resampling to create the mosaicked image. This will also result in longer processing times as more pixels are being processed than required to create the final mosaicked image. (You can reduce these processing times, by generating overviews after adding the function.)
The vertical arrows in the diagrams below identify the level (image, pyramids, or overview) where the function is applied.
In this diagram, the function is added to the mosaic dataset. Therefore, it will be applied after the imagery is resampled to the display scale. To do this, it will use the layer in the dataset that applies (either image or pyramid). For the bottom dashed line display scale, the top pyramid is used to create the displayed scale. To do this it resamples this level to the appropriate scale then applies the function. For the top dashed line, one of the overviews is used.
In this scenario, the pyramids are generated from the image and the overviews are generated from the pyramids. Any function processing is applied after the resampling.
In this diagram the function is added to the raster dataset contained within the mosaic dataset. What makes this different than what is described above is the overviews are created after the function is applied. Therefore, the pyramids are generated from the image, the function is applied, then the overviews are generated. So there is still some resampling from the original image before the function is applied, because the pyramids are generated from the original image.
In this diagram, there are no pyramids; therefore, the function is applied on the original image, then the overviews are generated.
You can also apply a function on a raster layer (including mosaic dataset layer or image server layer) using the Image Analysis window. This function is applied on the raster dataset. Like above, depending on the level being displayed, the function is applied to either the source image pixels or to the pixels in the pyramids. Therefore, when using the Hillshade function, there may be some resampling before the function is applied.