Creating the hillshade

We can run this data through the same hillshade algorithm used in the Creating a shaded relief section, in Chapter 7, Python and Elevation Data:

# Hillshade the elevation image log.info("Hillshading elevation data") im = Image.open(elv_img + ".jpg").convert("L") dem = np.asarray(im) # Set up structure for a 3x3 window to # process the slope throughout the grid window = [] # x, y resolutions xres = (maxx-minx)/w yres = (maxy-miny)/h # Create the windows for row in range(3): for col in range(3): window.append(dem[row:(row + dem.shape[0]-2), col:(col + dem.shape[1]-2)]) # Process each cell x = ((z * window[0] + z * window[3] + z * window[3] + z * window[6]) - (z * window[2] + z * window[5] + z * window[5] + z * window[8])) \ ...

Get Learning Geospatial Analysis with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.