|
41 | 41 | from processing.algs.gdal.GridInverseDistanceNearestNeighbor import GridInverseDistanceNearestNeighbor
|
42 | 42 | from processing.algs.gdal.GridLinear import GridLinear
|
43 | 43 | from processing.algs.gdal.GridNearestNeighbor import GridNearestNeighbor
|
| 44 | +from processing.algs.gdal.hillshade import hillshade |
44 | 45 | from processing.algs.gdal.ogr2ogr import ogr2ogr
|
45 | 46 | from processing.algs.gdal.proximity import proximity
|
46 | 47 | from processing.algs.gdal.rasterize import rasterize
|
@@ -926,6 +927,101 @@ def testOgr2Ogr(self):
|
926 | 927 | '-f "LIBKML" "d:/temp/my out/check.kml" ' +
|
927 | 928 | source + ' polys2'])
|
928 | 929 |
|
| 930 | + def testHillshade(self): |
| 931 | + context = QgsProcessingContext() |
| 932 | + feedback = QgsProcessingFeedback() |
| 933 | + source = os.path.join(testDataPath, 'dem.tif') |
| 934 | + alg = hillshade() |
| 935 | + alg.initAlgorithm() |
| 936 | + |
| 937 | + self.assertEqual( |
| 938 | + alg.getConsoleCommands({'INPUT': source, |
| 939 | + 'BAND': 1, |
| 940 | + 'Z_FACTOR': 5, |
| 941 | + 'SCALE': 2, |
| 942 | + 'AZIMUTH': 90, |
| 943 | + 'ALTITUDE': 20, |
| 944 | + 'OUTPUT': 'd:/temp/check.tif'}, context, feedback), |
| 945 | + ['gdaldem', |
| 946 | + 'hillshade ' + |
| 947 | + source + ' ' + |
| 948 | + 'd:/temp/check.tif -of GTiff -b 1 -z 5.0 -s 2.0 -az 90.0 -alt 20.0']) |
| 949 | + |
| 950 | + #paths with space |
| 951 | + source_with_space = os.path.join(testDataPath, 'raster with spaces.tif') |
| 952 | + self.assertEqual( |
| 953 | + alg.getConsoleCommands({'INPUT': source_with_space, |
| 954 | + 'BAND': 1, |
| 955 | + 'Z_FACTOR': 5, |
| 956 | + 'SCALE': 2, |
| 957 | + 'AZIMUTH': 90, |
| 958 | + 'ALTITUDE': 20, |
| 959 | + 'OUTPUT': 'd:/temp/check out.tif'}, context, feedback), |
| 960 | + ['gdaldem', |
| 961 | + 'hillshade ' + |
| 962 | + '"' + source_with_space + '" ' + |
| 963 | + '"d:/temp/check out.tif" -of GTiff -b 1 -z 5.0 -s 2.0 -az 90.0 -alt 20.0']) |
| 964 | + |
| 965 | + # compute edges |
| 966 | + self.assertEqual( |
| 967 | + alg.getConsoleCommands({'INPUT': source, |
| 968 | + 'BAND': 1, |
| 969 | + 'Z_FACTOR': 5, |
| 970 | + 'SCALE': 2, |
| 971 | + 'AZIMUTH': 90, |
| 972 | + 'ALTITUDE': 20, |
| 973 | + 'COMPUTE_EDGES': True, |
| 974 | + 'OUTPUT': 'd:/temp/check.tif'}, context, feedback), |
| 975 | + ['gdaldem', |
| 976 | + 'hillshade ' + |
| 977 | + source + ' ' + |
| 978 | + 'd:/temp/check.tif -of GTiff -b 1 -z 5.0 -s 2.0 -az 90.0 -alt 20.0 -compute_edges']) |
| 979 | + |
| 980 | + # with ZEVENBERGEN |
| 981 | + self.assertEqual( |
| 982 | + alg.getConsoleCommands({'INPUT': source, |
| 983 | + 'BAND': 1, |
| 984 | + 'Z_FACTOR': 5, |
| 985 | + 'SCALE': 2, |
| 986 | + 'AZIMUTH': 90, |
| 987 | + 'ALTITUDE': 20, |
| 988 | + 'ZEVENBERGEN': True, |
| 989 | + 'OUTPUT': 'd:/temp/check.tif'}, context, feedback), |
| 990 | + ['gdaldem', |
| 991 | + 'hillshade ' + |
| 992 | + source + ' ' + |
| 993 | + 'd:/temp/check.tif -of GTiff -b 1 -z 5.0 -s 2.0 -az 90.0 -alt 20.0 -alg ZevenbergenThorne']) |
| 994 | + |
| 995 | + # with COMBINED |
| 996 | + self.assertEqual( |
| 997 | + alg.getConsoleCommands({'INPUT': source, |
| 998 | + 'BAND': 1, |
| 999 | + 'Z_FACTOR': 5, |
| 1000 | + 'SCALE': 2, |
| 1001 | + 'AZIMUTH': 90, |
| 1002 | + 'ALTITUDE': 20, |
| 1003 | + 'COMBINED': True, |
| 1004 | + 'OUTPUT': 'd:/temp/check.tif'}, context, feedback), |
| 1005 | + ['gdaldem', |
| 1006 | + 'hillshade ' + |
| 1007 | + source + ' ' + |
| 1008 | + 'd:/temp/check.tif -of GTiff -b 1 -z 5.0 -s 2.0 -az 90.0 -alt 20.0 -combined']) |
| 1009 | + |
| 1010 | + # with multidirectional - "az" argument is not allowed! |
| 1011 | + self.assertEqual( |
| 1012 | + alg.getConsoleCommands({'INPUT': source, |
| 1013 | + 'BAND': 1, |
| 1014 | + 'Z_FACTOR': 5, |
| 1015 | + 'SCALE': 2, |
| 1016 | + 'AZIMUTH': 90, |
| 1017 | + 'ALTITUDE': 20, |
| 1018 | + 'MULTIDIRECTIONAL': True, |
| 1019 | + 'OUTPUT': 'd:/temp/check.tif'}, context, feedback), |
| 1020 | + ['gdaldem', |
| 1021 | + 'hillshade ' + |
| 1022 | + source + ' ' + |
| 1023 | + 'd:/temp/check.tif -of GTiff -b 1 -z 5.0 -s 2.0 -alt 20.0 -multidirectional']) |
| 1024 | + |
929 | 1025 | def testProximity(self):
|
930 | 1026 | context = QgsProcessingContext()
|
931 | 1027 | feedback = QgsProcessingFeedback()
|
|
0 commit comments