Skip to content

Commit

Permalink
prep for v2.0...
Browse files Browse the repository at this point in the history
  • Loading branch information
jblindsay committed Aug 30, 2021
1 parent dabf037 commit 78a3a00
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017-2020 John Lindsay
Copyright (c) 2017-2021 John Lindsay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ for more details.
* Release Notes: *
******************

Version 1.6.0 (XX-XX-2021)
Version 2.0.0 (30-08-2021)
- The most important feature in this release is the addition of support for reading and writing the LAZ
compressed LiDAR format for all of the LiDAR tools in WBT.
- Added the RasterCalculator tool for performing complex mathematical operations on input rasters.
Expand All @@ -80,7 +80,7 @@ Version 1.6.0 (XX-XX-2021)
z_factor conversion value for each row in the raster, rather than using a single value based on the raster
mid-point latitude. This should help improve the accuracy of these shape indices on large-extent rasters
in geographic coordinate systems.
- Fixed several bugs in the isobasins tool.
- Fixed several bugs in the isobasins and D8 flow accumulation tool.
- The NewRasterFromBase tool now accepts a vector base file (and grid cell size) as well as a raster.
- The WhiteboxTools user manual has had a refresh and is now hosted at:
https://www.whiteboxgeo.com/manual/wbt_book/intro.html
Expand Down
77 changes: 75 additions & 2 deletions whitebox_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ def list_tools(self, keywords=[]):






##############
Expand Down Expand Up @@ -681,7 +682,7 @@ def multi_part_to_single_part(self, i, output, exclude_holes=True, callback=None
if exclude_holes: args.append("--exclude_holes")
return self.run_tool('multi_part_to_single_part', args, callback) # returns 1 if error

def new_raster_from_base(self, base, output, value="nodata", data_type="float", callback=None):
def new_raster_from_base(self, base, output, value="nodata", data_type="float", cell_size=None, callback=None):
"""Creates a new raster using a base image.
Keyword arguments:
Expand All @@ -690,13 +691,15 @@ def new_raster_from_base(self, base, output, value="nodata", data_type="float",
output -- Output raster file.
value -- Constant value to fill raster with; either 'nodata' or numeric value.
data_type -- Output raster data type; options include 'double' (64-bit), 'float' (32-bit), and 'integer' (signed 16-bit) (default is 'float').
cell_size -- Optionally specified cell size of output raster. Not used when base raster is specified.
callback -- Custom function for handling tool text outputs.
"""
args = []
args.append("--base='{}'".format(base))
args.append("--output='{}'".format(output))
args.append("--value={}".format(value))
args.append("--data_type={}".format(data_type))
if cell_size is not None: args.append("--cell_size='{}'".format(cell_size))
return self.run_tool('new_raster_from_base', args, callback) # returns 1 if error

def polygons_to_lines(self, i, output, callback=None):
Expand Down Expand Up @@ -3918,7 +3921,7 @@ def d8_flow_accumulation(self, i, output, out_type="cells", log=False, clip=Fals
log -- Optional flag to request the output be log-transformed.
clip -- Optional flag to request clipping the display max by 1%.
pntr -- Is the input raster a D8 flow pointer rather than a DEM?.
esri_pntr -- Input D8 pointer uses the ESRI style scheme.
esri_pntr -- Input D8 pointer uses the ESRI style scheme.
callback -- Custom function for handling tool text outputs.
"""
args = []
Expand Down Expand Up @@ -4625,6 +4628,30 @@ def raise_walls(self, i, dem, output, breach=None, height=100.0, callback=None):
args.append("--height={}".format(height))
return self.run_tool('raise_walls', args, callback) # returns 1 if error

def rho8_flow_accumulation(self, i, output, out_type="specific contributing area", log=False, clip=False, pntr=False, esri_pntr=False, callback=None):
"""This tool calculates Fairfield and Leymarie (1991) flow accumulation.
Keyword arguments:
i -- Input DEM or Rho8 pointer file; if a DEM is used, it must be depressionless.
output -- Name of the output raster file.
out_type -- Output type; one of 'cells', 'specific contributing area' (default), and 'catchment area'.
log -- Log-transform the output values?.
clip -- Optional flag to request clipping the display max by 1%.
pntr -- Is the input raster a Rho8 flow pointer rather than a DEM?.
esri_pntr -- Does the input Rho8 pointer use the ESRI style scheme?.
callback -- Custom function for handling tool text outputs.
"""
args = []
args.append("--input='{}'".format(i))
args.append("--output='{}'".format(output))
args.append("--out_type={}".format(out_type))
if log: args.append("--log")
if clip: args.append("--clip")
if pntr: args.append("--pntr")
if esri_pntr: args.append("--esri_pntr")
return self.run_tool('rho8_flow_accumulation', args, callback) # returns 1 if error

def rho8_pointer(self, dem, output, esri_pntr=False, callback=None):
"""Calculates a stochastic Rho8 flow pointer raster from an input DEM.
Expand Down Expand Up @@ -8609,6 +8636,32 @@ def zonal_statistics(self, i, features, output=None, stat="mean", out_table=None
# Precision Agriculture #
#########################

def reconcile_multiple_headers(self, i, region_field, yield_field, output, radius=None, min_yield=None, max_yield=None, mean_tonnage=None, callback=None):
"""This tool can be used to normalize the yield points for a field.
Keyword arguments:
i -- Name of the input points shapefile.
region_field -- Name of the attribute containing region data.
yield_field -- Name of the attribute containing yield data.
output -- Name of the output points shapefile.
radius -- Optional search radius, in metres. Only specify this value if you want to calculate locally normalized yield.
min_yield -- Minimum yield value in output.
max_yield -- Maximum yield value in output.
mean_tonnage -- Use this optional parameter to force the output to have a certain overall average tonnage.
callback -- Custom function for handling tool text outputs.
"""
args = []
args.append("--input='{}'".format(i))
args.append("--region_field='{}'".format(region_field))
args.append("--yield_field='{}'".format(yield_field))
args.append("--output='{}'".format(output))
if radius is not None: args.append("--radius='{}'".format(radius))
if min_yield is not None: args.append("--min_yield='{}'".format(min_yield))
if max_yield is not None: args.append("--max_yield='{}'".format(max_yield))
if mean_tonnage is not None: args.append("--mean_tonnage='{}'".format(mean_tonnage))
return self.run_tool('reconcile_multiple_headers', args, callback) # returns 1 if error

def recreate_pass_lines(self, i, yield_field_name, output_lines, output_points, max_change_in_heading=25.0, ignore_zeros=False, callback=None):
"""This tool can be used to approximate the harvester pass lines from yield points.
Expand All @@ -8631,6 +8684,26 @@ def recreate_pass_lines(self, i, yield_field_name, output_lines, output_points,
if ignore_zeros: args.append("--ignore_zeros")
return self.run_tool('recreate_pass_lines', args, callback) # returns 1 if error

def remove_field_edge_points(self, i, output, dist=None, max_change_in_heading=25.0, flag_edges=False, callback=None):
"""This tool can be used to remove most of the points along the edges from a crop yield data set.
Keyword arguments:
i -- Name of the input points shapefile.
output -- Name of the output points shapefile.
dist -- Average distance between passes, in meters.
max_change_in_heading -- Max change in heading.
flag_edges -- Don't remove edge points, just flag them in the attribute table?.
callback -- Custom function for handling tool text outputs.
"""
args = []
args.append("--input='{}'".format(i))
args.append("--output='{}'".format(output))
if dist is not None: args.append("--dist='{}'".format(dist))
args.append("--max_change_in_heading={}".format(max_change_in_heading))
if flag_edges: args.append("--flag_edges")
return self.run_tool('remove_field_edge_points', args, callback) # returns 1 if error

def yield_filter(self, i, yield_field, pass_field, output, width=6.096, z_score_threshold=2.5, min_yield=0.0, max_yield=99999.9, callback=None):
"""Filters crop yield values of point data derived from combine harvester yield monitors.
Expand Down

0 comments on commit 78a3a00

Please sign in to comment.