-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdk_tutorial_4.py
More file actions
34 lines (27 loc) · 1.01 KB
/
pdk_tutorial_4.py
File metadata and controls
34 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import tatukgis_pdk as pdk
from PIL import Image
import io
gis = pdk.TGIS_ViewerBmp(638, 424)
sample_data = pdk.TGIS_Utils.GisSamplesDataDirDownload()
# open raster with DEM
dem: pdk.TGIS_LayerPixel = pdk.TGIS_Utils().GisCreateLayer(
"dem",
f"{sample_data}/World/Countries/USA/States/California/San Bernardino/NED/w001001.adf")
gis.Add(dem)
gis.VisibleExtent = dem.Extent
# use the "DEMScreen" color ramp to make your visualization more attractive
color_ramp = pdk.TGIS_Utils().GisColorRampList.ByName(pdk.TGIS_ColorRampNames().DEMScreen)
dem.Params.Pixel.ColorRamp = color_ramp.RealizeColorMap(
pdk.TGIS_ColorMapMode().Continuous, 0, False)
# prepare slope layer
slope = pdk.TGIS_LayerPixel()
slope.Build(True, dem.CS, dem.Extent, dem.BitWidth, dem.BitHeight)
slope.Name = "slope layer"
# run Slope tool
slope_tool = pdk.TGIS_SlopeMap()
slope_tool.Generate(dem, dem.Extent, slope, True)
gis.Add(slope)
# show map as png
gis.InvalidateWholeMap()
img = Image.open(io.BytesIO(gis.GIS_Bitmap.AsPng()))
img.show()