forked from SciTools/cartopy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request SciTools#396 from pelson/srtm_shading
Elevation filling & shading by @ThomasLecocq.
- Loading branch information
Showing
4 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
__tags__ = ['Scalar data'] | ||
""" | ||
This example illustrates the automatic download of | ||
STRM data, gap filling (using gdal) and adding shading | ||
to create a so-called "Shaded Relief SRTM" | ||
Contributed by: Thomas Lecocq (http://geophysique.be) | ||
""" | ||
|
||
import cartopy.crs as ccrs | ||
from cartopy.io import srtm | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
def main(): | ||
ax = plt.axes(projection=ccrs.PlateCarree()) | ||
|
||
# Get the 1x1 degree SRTM tile for 12E, 47N | ||
elev, crs, extent = srtm.srtm_composite(12, 47, 1, 1) | ||
|
||
# Fill the gaps present in the elevation data | ||
elev_filled = srtm.fill_gaps(elev, 15) | ||
|
||
# Add shading simulating the Sun at 10am (South-East) | ||
# and with a low angle (15 degrees above horizon) | ||
shaded = srtm.add_shading(elev_filled, 135.0, 15.0) | ||
|
||
# The plot the result : | ||
plt.imshow(shaded, extent=extent, transform=crs, | ||
cmap='Greys', origin='lower') | ||
|
||
plt.title("SRTM Shaded Relief Map") | ||
|
||
gl = ax.gridlines(draw_labels=True,) | ||
gl.xlabels_top = False | ||
gl.ylabels_left = False | ||
|
||
plt.show() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters