Skip to content

Commit 8bdcbeb

Browse files
authored
Merge pull request #19 from giswqs/develop
Update to use WBT backend v1.3.1
2 parents 35e3eb8 + f9cbf35 commit 8bdcbeb

File tree

7 files changed

+175
-20
lines changed

7 files changed

+175
-20
lines changed

.github/workflows/py-check.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
branches:
7+
- master
8+
9+
name: py-check
10+
jobs:
11+
py-check:
12+
runs-on: ${{ matrix.config.os }}
13+
name: ${{ matrix.config.os }} (${{ matrix.config.py }})
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
config:
18+
- {os: windows-latest, py: '3.7'}
19+
- {os: macOS-latest, py: '3.7'}
20+
- {os: ubuntu-latest, py: '3.6'}
21+
- {os: ubuntu-latest, py: '3.7'}
22+
- {os: ubuntu-latest, py: '3.8'}
23+
24+
env:
25+
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
26+
steps:
27+
- name: CHECKOUT CODE
28+
uses: actions/checkout@v2
29+
- name: SETUP PYTHON
30+
uses: actions/setup-python@v1
31+
with:
32+
python-version: ${{ matrix.config.py }}
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install --user -r requirements_dev.txt
37+
- name: WBT-TEST
38+
run: |
39+
python -m unittest discover tests/

.github/workflows/pypi-publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_USERS }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
twine upload dist/*

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ When using ``import whitebox``, if you get an error that says ``No module named
182182

183183
Available Tools
184184
---------------
185-
The library currently contains **440** tools, which are each grouped based on their main function into one of the following categories: Data Tools, GIS Analysis, Hydrological Analysis, Image Analysis, LiDAR Analysis, Mathematical and Statistical Analysis, Stream Network Analysis, and Terrain Analysis. For a listing of available tools, complete with documentation and usage details, please see the `WhiteboxTools User Manual`_.
185+
The library currently contains **443** tools, which are each grouped based on their main function into one of the following categories: Data Tools, GIS Analysis, Hydrological Analysis, Image Analysis, LiDAR Analysis, Mathematical and Statistical Analysis, Stream Network Analysis, and Terrain Analysis. For a listing of available tools, complete with documentation and usage details, please see the `WhiteboxTools User Manual`_.
186186

187187

188188
Supported Data Formats

requirements_dev.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
pip==9.0.1
2-
bumpversion==0.5.3
3-
wheel==0.30.0
4-
watchdog==0.8.3
5-
flake8==3.5.0
6-
tox==2.9.1
7-
coverage==4.5.1
8-
Sphinx==1.7.1
9-
twine==1.10.0
10-
11-
1+
pip
2+
bump2version
3+
wheel
4+
watchdog
5+
flake8
6+
tox
7+
coverage
8+
Sphinx
9+
twine
10+
Click

whitebox/wb_runner.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ def select_file(self):
101101
ftypes = [('All files', '*.*')]
102102
if 'RasterAndVector' in self.file_type:
103103
ftypes = [("Shapefiles", "*.shp"), ('Raster files', ('*.dep', '*.tif',
104-
'*.tiff', '*.flt',
104+
'*.tiff', '*.bil', '*.flt',
105105
'*.sdat', '*.rdc',
106106
'*.asc'))]
107107
elif 'Raster' in self.file_type:
108108
ftypes = [('Raster files', ('*.dep', '*.tif',
109-
'*.tiff', '*.flt',
109+
'*.tiff', '*.bil', '*.flt',
110110
'*.sdat', '*.rdc',
111111
'*.asc'))]
112112
elif 'Lidar' in self.file_type:
@@ -255,12 +255,12 @@ def select_file(self):
255255
ftypes = [('All files', '*.*')]
256256
if 'RasterAndVector' in self.file_type:
257257
ftypes = [("Shapefiles", "*.shp"), ('Raster files', ('*.dep', '*.tif',
258-
'*.tiff', '*.flt',
258+
'*.tiff', '*.bil', '*.flt',
259259
'*.sdat', '*.rdc',
260260
'*.asc'))]
261261
elif 'Raster' in self.file_type:
262262
ftypes = [('Raster files', ('*.dep', '*.tif',
263-
'*.tiff', '*.flt',
263+
'*.tiff', '*.bil', '*.flt',
264264
'*.sdat', '*.rdc',
265265
'*.asc'))]
266266
elif 'Lidar' in self.file_type:
@@ -410,12 +410,12 @@ def select_file(self):
410410
ftypes = [('All files', '*.*')]
411411
if 'RasterAndVector' in self.file_type:
412412
ftypes = [("Shapefiles", "*.shp"), ('Raster files', ('*.dep', '*.tif',
413-
'*.tiff', '*.flt',
413+
'*.tiff', '*.bil', '*.flt',
414414
'*.sdat', '*.rdc',
415415
'*.asc'))]
416416
elif 'Raster' in self.file_type:
417417
ftypes = [('Raster files', ('*.dep', '*.tif',
418-
'*.tiff', '*.flt',
418+
'*.tiff', '*.bil', '*.flt',
419419
'*.sdat', '*.rdc',
420420
'*.asc'))]
421421
elif 'Lidar' in self.file_type:

whitebox/whitebox_example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def main():
3535
if os.path.isfile(wbt_win_bin) or os.path.isfile(wbt_linux_bin):
3636
wbt.set_whitebox_dir(root_dir)
3737
else:
38-
wbt.set_whitebox_dir(root_dir + "/target/release/") # or simply wbt.exe_path = ...
38+
# or simply wbt.exe_path = ...
39+
wbt.set_whitebox_dir(root_dir + "/target/release/")
3940

4041
# Set the working directory. This is the path to the folder containing the data,
4142
# i.e. files sent to tools as input/output parameters. You don't need to set
@@ -130,7 +131,7 @@ def my_callback(out_str):
130131
print("Elapsed time: {0}{1}".format(elapsed_time, units))
131132
my_callback.prev_line_progress = False
132133
else:
133-
if callback.prev_line_progress:
134+
if my_callback.prev_line_progress:
134135
print('\n{0}'.format(out_str))
135136
my_callback.prev_line_progress = False
136137
else:

whitebox/whitebox_tools.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ def list_tools(self, keywords=[]):
504504

505505

506506

507+
507508

508509

509510
##############
@@ -2764,6 +2765,36 @@ def hypsometric_analysis(self, inputs, output, watershed=None, callback=None):
27642765
args.append("--output='{}'".format(output))
27652766
return self.run_tool('hypsometric_analysis', args, callback) # returns 1 if error
27662767

2768+
def hypsometrically_tinted_hillshade(self, dem, output, altitude=45.0, hs_weight=0.5, brightness=0.5, atmospheric=0.0, palette="atlas", reverse=False, zfactor=1.0, full_mode=False, callback=None):
2769+
"""Creates an colour shaded relief image from an input DEM.
2770+
2771+
Keyword arguments:
2772+
2773+
dem -- Input raster DEM file.
2774+
output -- Output raster file.
2775+
altitude -- Illumination source altitude in degrees.
2776+
hs_weight -- Weight given to hillshade relative to relief (0.0-1.0).
2777+
brightness -- Brightness factor (0.0-1.0).
2778+
atmospheric -- Atmospheric effects weight (0.0-1.0).
2779+
palette -- Options include 'atlas', 'high_relief', 'arid', 'soft', 'muted', 'purple', 'viridi', 'gn_yl', 'pi_y_g', 'bl_yl_rd', and 'deep.
2780+
reverse -- Optional flag indicating whether to use reverse the palette.
2781+
zfactor -- Optional multiplier for when the vertical and horizontal units are not the same.
2782+
full_mode -- Optional flag indicating whether to use full 360-degrees of illumination sources.
2783+
callback -- Custom function for handling tool text outputs.
2784+
"""
2785+
args = []
2786+
args.append("--dem='{}'".format(dem))
2787+
args.append("--output='{}'".format(output))
2788+
args.append("--altitude={}".format(altitude))
2789+
args.append("--hs_weight={}".format(hs_weight))
2790+
args.append("--brightness={}".format(brightness))
2791+
args.append("--atmospheric={}".format(atmospheric))
2792+
args.append("--palette={}".format(palette))
2793+
if reverse: args.append("--reverse")
2794+
args.append("--zfactor={}".format(zfactor))
2795+
if full_mode: args.append("--full_mode")
2796+
return self.run_tool('hypsometrically_tinted_hillshade', args, callback) # returns 1 if error
2797+
27672798
def max_anisotropy_dev(self, dem, out_mag, out_scale, max_scale, min_scale=3, step=2, callback=None):
27682799
"""Calculates the maximum anisotropy (directionality) in elevation deviation over a range of spatial scales.
27692800
@@ -2918,6 +2949,26 @@ def min_downslope_elev_change(self, dem, output, callback=None):
29182949
args.append("--output='{}'".format(output))
29192950
return self.run_tool('min_downslope_elev_change', args, callback) # returns 1 if error
29202951

2952+
def multidirectional_hillshade(self, dem, output, altitude=45.0, zfactor=1.0, full_mode=False, callback=None):
2953+
"""Calculates a multi-direction hillshade raster from an input DEM.
2954+
2955+
Keyword arguments:
2956+
2957+
dem -- Input raster DEM file.
2958+
output -- Output raster file.
2959+
altitude -- Illumination source altitude in degrees.
2960+
zfactor -- Optional multiplier for when the vertical and horizontal units are not the same.
2961+
full_mode -- Optional flag indicating whether to use full 360-degrees of illumination sources.
2962+
callback -- Custom function for handling tool text outputs.
2963+
"""
2964+
args = []
2965+
args.append("--dem='{}'".format(dem))
2966+
args.append("--output='{}'".format(output))
2967+
args.append("--altitude={}".format(altitude))
2968+
args.append("--zfactor={}".format(zfactor))
2969+
if full_mode: args.append("--full_mode")
2970+
return self.run_tool('multidirectional_hillshade', args, callback) # returns 1 if error
2971+
29212972
def multiscale_elevation_percentile(self, dem, out_mag, out_scale, sig_digits=3, min_scale=4, step=1, num_steps=10, step_nonlinearity=1.0, callback=None):
29222973
"""Calculates surface roughness over a range of spatial scales.
29232974
@@ -6248,6 +6299,40 @@ def lidar_remove_outliers(self, i, output, radius=2.0, elev_diff=50.0, use_media
62486299
if classify: args.append("--classify")
62496300
return self.run_tool('lidar_remove_outliers', args, callback) # returns 1 if error
62506301

6302+
def lidar_rooftop_analysis(self, buildings, output, i=None, radius=2.0, num_iter=50, num_samples=10, threshold=0.15, model_size=15, max_slope=65.0, norm_diff=10.0, azimuth=180.0, altitude=30.0, callback=None):
6303+
"""Identifies roof segments in a LiDAR point cloud.
6304+
6305+
Keyword arguments:
6306+
6307+
i -- Input LiDAR file.
6308+
buildings -- Input vector build footprint polygons file.
6309+
output -- Output vector polygon file.
6310+
radius -- Search Radius.
6311+
num_iter -- Number of iterations.
6312+
num_samples -- Number of sample points on which to build the model.
6313+
threshold -- Threshold used to determine inlier points.
6314+
model_size -- Acceptable model size.
6315+
max_slope -- Maximum planar slope.
6316+
norm_diff -- Maximum difference in normal vectors, in degrees.
6317+
azimuth -- Illumination source azimuth in degrees.
6318+
altitude -- Illumination source altitude in degrees.
6319+
callback -- Custom function for handling tool text outputs.
6320+
"""
6321+
args = []
6322+
if i is not None: args.append("--input='{}'".format(i))
6323+
args.append("--buildings='{}'".format(buildings))
6324+
args.append("--output='{}'".format(output))
6325+
args.append("--radius={}".format(radius))
6326+
args.append("--num_iter={}".format(num_iter))
6327+
args.append("--num_samples={}".format(num_samples))
6328+
args.append("--threshold={}".format(threshold))
6329+
args.append("--model_size={}".format(model_size))
6330+
args.append("--max_slope={}".format(max_slope))
6331+
args.append("--norm_diff={}".format(norm_diff))
6332+
args.append("--azimuth={}".format(azimuth))
6333+
args.append("--altitude={}".format(altitude))
6334+
return self.run_tool('lidar_rooftop_analysis', args, callback) # returns 1 if error
6335+
62516336
def lidar_segmentation(self, i, output, radius=2.0, num_iter=50, num_samples=10, threshold=0.15, model_size=15, max_slope=80.0, norm_diff=10.0, maxzdiff=1.0, classes=False, ground=False, callback=None):
62526337
"""Segments a LiDAR point cloud based on differences in the orientation of fitted planar surfaces and point proximity.
62536338

0 commit comments

Comments
 (0)