Skip to content

Commit a758dac

Browse files
committed
Can't use 'import' as a function parameter name in Python
Can't use 'import' as a function parameter name in Python
1 parent f8af226 commit a758dac

6 files changed

Lines changed: 44 additions & 32 deletions

File tree

WhiteboxToolsManual.pdf

-626 Bytes
Binary file not shown.

manual/WhiteboxToolsManual.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,8 @@ derived. The *foreign key* (`--fkey` flag), the identifying field within the
692692
second table that corresponds with the data contained within the primary key in the table, must be
693693
specified. Both the primary and foreign keys should either be strings (text) or integer values.
694694
*Fields containing decimal values are not good candidates for keys.* Lastly, the names of the field
695-
within the second file to include in the merge operation can also be input (`--import`). If the
696-
`--import` field is not input, all fields in the attribute table of the second file, that are not
695+
within the second file to include in the merge operation can also be input (`--import_field`). If the
696+
`--import_field` field is not input, all fields in the attribute table of the second file, that are not
697697
the foreign key nor FID, will be imported to the first table.
698698
699699
Merging works for one-to-one and many-to-one database relations. A *one-to-one* relations exists when
@@ -723,7 +723,7 @@ will correspond to only one foreign key containing the population and area data.
723723
-\-pkey Primary key field
724724
-\-i2, -\-input2 Input foreign vector file (i.e. source of data to be imported)
725725
-\-fkey Foreign key field
726-
-\-import Imported field (all fields will be imported if not specified)
726+
-\-import_field Imported field (all fields will be imported if not specified)
727727
728728
729729
*Python function*:
@@ -734,7 +734,7 @@ join_tables(
734734
pkey,
735735
input2,
736736
fkey,
737-
import,
737+
import_field,
738738
callback=default_callback)
739739
~~~~
740740
@@ -743,7 +743,7 @@ join_tables(
743743
```
744744
>>./whitebox_tools -r=JoinTables -v --wd="/path/to/data/" ^
745745
--i1=properties.shp --pkey=TYPE --i2=land_class.shp ^
746-
--fkey=VALUE --import=NEW_VALUE
746+
--fkey=VALUE --import_field=NEW_VALUE
747747

748748

749749
```
@@ -803,7 +803,7 @@ header row, i.e. the first row must contain information about the names of the v
803803
CSV file that corresponds with the data contained within the *primary key* in the table, must also
804804
be specified. Both the primary and foreign keys should either be strings (text) or integer values.
805805
*Fields containing decimal values are not good candidates for keys.* Lastly, the user may optionally
806-
specify the name of a field within the CSV file to import in the merge operation (`--import` flag).
806+
specify the name of a field within the CSV file to import in the merge operation (`--import_field` flag).
807807
If this flag is not specified, all of the fields within the CSV, with the exception of the foreign
808808
key, will be appended to the attribute table.
809809
@@ -834,7 +834,7 @@ will correspond to only one foreign key containing the population and area data.
834834
-\-pkey Primary key field
835835
-\-csv Input CSV file (i.e. source of data to be imported)
836836
-\-fkey Foreign key field
837-
-\-import Imported field (all fields will be imported if not specified)
837+
-\-import_field Imported field (all fields will be imported if not specified)
838838
839839
840840
*Python function*:
@@ -845,7 +845,7 @@ merge_table_with_csv(
845845
pkey,
846846
csv,
847847
fkey,
848-
import=None,
848+
import_field=None,
849849
callback=default_callback)
850850
~~~~
851851
@@ -855,9 +855,9 @@ merge_table_with_csv(
855855
>>./whitebox_tools -r=MergeTableWithCsv -v ^
856856
--wd="/path/to/data/" -i=properties.shp --pkey=TYPE ^
857857
--csv=land_class.csv --fkey=VALUE ^
858-
--import=NEW_VALUE
859-
>>./whitebox_tools -r=MergeTableWithCsv -v ^
860-
--wd="/path/to/data/" -i=properties.shp --pkey=TYPE ^
858+
--import_field=NEW_VALUE
859+
>>./whitebox_tools -r=MergeTableWithCsv ^
860+
-v --wd="/path/to/data/" -i=properties.shp --pkey=TYPE ^
861861
--csv=land_class.csv --fkey=VALUE
862862

863863

@@ -3458,6 +3458,7 @@ resulting from the overlay operation.
34583458
-i, -\-input Input vector file
34593459
-\-overlay Input overlay vector file
34603460
-o, -\-output Output vector file
3461+
-\-snap Snap tolerance
34613462
34623463
34633464
*Python function*:
@@ -3467,14 +3468,16 @@ intersect(
34673468
i,
34683469
overlay,
34693470
output,
3471+
snap=0.0,
34703472
callback=default_callback)
34713473
~~~~
34723474
34733475
*Command-line Interface*:
34743476
34753477
```
34763478
>>./whitebox_tools -r=Intersect -v --wd="/path/to/data/" ^
3477-
-input=layer1.shp --overlay=layer2.shp -o=out_file.shp
3479+
-input=layer1.shp --overlay=layer2.shp -o=out_file.shp ^
3480+
--snap=0.0000001
34783481

34793482

34803483
```
@@ -3975,6 +3978,7 @@ resulting from the overlay operation.
39753978
-i, -\-input Input vector file
39763979
-\-overlay Input overlay vector file
39773980
-o, -\-output Output vector file
3981+
-\-snap Snap tolerance
39783982
39793983
39803984
*Python function*:
@@ -3984,6 +3988,7 @@ symmetrical_difference(
39843988
i,
39853989
overlay,
39863990
output,
3991+
snap=0.0,
39873992
callback=default_callback)
39883993
~~~~
39893994
@@ -3992,7 +3997,7 @@ symmetrical_difference(
39923997
```
39933998
>>./whitebox_tools -r=SymmetricalDifference -v ^
39943999
--wd="/path/to/data/" -input=layer1.shp --overlay=layer2.shp ^
3995-
-o=out_file.shp
4000+
-o=out_file.shp --snap=0.0000001
39964001

39974002

39984003
```
@@ -15509,6 +15514,8 @@ tributary_identifier(
1550915514
1551015515
1551115516
15517+
15518+
1551215519
1551315520
1551415521

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ for more details.
5656
* Release Notes: *
5757
******************
5858

59-
Version 0.12.0 (XX-XX-2018)
59+
Version 0.12.0 (22-11-2018)
6060
- The following tools were added to the project:
6161
BlockMaximumGridding
6262
BlockMinimumGridding

src/tools/data_tools/join_tables.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This tool is part of the WhiteboxTools geospatial analysis library.
33
Authors: Prof. John Lindsay
44
Created: 07/10/2018
5-
Last Modified: 12/10/2018
5+
Last Modified: 22/11/2018
66
License: MIT
77
*/
88

@@ -23,8 +23,8 @@ use vector::{FieldData, Shapefile};
2323
/// second table that corresponds with the data contained within the primary key in the table, must be
2424
/// specified. Both the primary and foreign keys should either be strings (text) or integer values.
2525
/// *Fields containing decimal values are not good candidates for keys.* Lastly, the names of the field
26-
/// within the second file to include in the merge operation can also be input (`--import`). If the
27-
/// `--import` field is not input, all fields in the attribute table of the second file, that are not
26+
/// within the second file to include in the merge operation can also be input (`--import_field`). If the
27+
/// `--import_field` field is not input, all fields in the attribute table of the second file, that are not
2828
/// the foreign key nor FID, will be imported to the first table.
2929
///
3030
/// Merging works for one-to-one and many-to-one database relations. A *one-to-one* relations exists when
@@ -111,7 +111,7 @@ impl JoinTables {
111111

112112
parameters.push(ToolParameter {
113113
name: "Imported Field".to_owned(),
114-
flags: vec!["--import".to_owned()],
114+
flags: vec!["--import_field".to_owned()],
115115
description: "Imported field (all fields will be imported if not specified)."
116116
.to_owned(),
117117
parameter_type: ParameterType::VectorAttributeField(
@@ -134,7 +134,7 @@ impl JoinTables {
134134
short_exe += ".exe";
135135
}
136136
let usage = format!(
137-
">>.*{0} -r={1} -v --wd=\"*path*to*data*\" --i1=properties.shp --pkey=TYPE --i2=land_class.shp --fkey=VALUE --import=NEW_VALUE",
137+
">>.*{0} -r={1} -v --wd=\"*path*to*data*\" --i1=properties.shp --pkey=TYPE --i2=land_class.shp --fkey=VALUE --import_field=NEW_VALUE",
138138
short_exe, name
139139
).replace("*", &sep);
140140

@@ -228,7 +228,7 @@ impl WhiteboxTool for JoinTables {
228228
} else {
229229
args[i + 1].to_string()
230230
};
231-
} else if flag_val == "-import" {
231+
} else if flag_val == "-import_field" {
232232
import_field = if keyval {
233233
vec[1].to_string()
234234
} else {

src/tools/data_tools/merge_table_with_csv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This tool is part of the WhiteboxTools geospatial analysis library.
33
Authors: Prof. John Lindsay
44
Created: 11/10/2018
5-
Last Modified: 12/10/2018
5+
Last Modified: 22/11/2018
66
License: MIT
77
*/
88

@@ -29,7 +29,7 @@ use vector::{AttributeField, FieldData, FieldDataType, Shapefile};
2929
/// CSV file that corresponds with the data contained within the *primary key* in the table, must also
3030
/// be specified. Both the primary and foreign keys should either be strings (text) or integer values.
3131
/// *Fields containing decimal values are not good candidates for keys.* Lastly, the user may optionally
32-
/// specify the name of a field within the CSV file to import in the merge operation (`--import` flag).
32+
/// specify the name of a field within the CSV file to import in the merge operation (`--import_field` flag).
3333
/// If this flag is not specified, all of the fields within the CSV, with the exception of the foreign
3434
/// key, will be appended to the attribute table.
3535
///
@@ -114,7 +114,7 @@ impl MergeTableWithCsv {
114114

115115
parameters.push(ToolParameter {
116116
name: "Imported Field".to_owned(),
117-
flags: vec!["--import".to_owned()],
117+
flags: vec!["--import_field".to_owned()],
118118
description: "Imported field (all fields will be imported if not specified)."
119119
.to_owned(),
120120
parameter_type: ParameterType::VectorAttributeField(
@@ -137,7 +137,7 @@ impl MergeTableWithCsv {
137137
short_exe += ".exe";
138138
}
139139
let usage = format!(
140-
">>.*{0} -r={1} -v --wd=\"*path*to*data*\" -i=properties.shp --pkey=TYPE --csv=land_class.csv --fkey=VALUE --import=NEW_VALUE
140+
">>.*{0} -r={1} -v --wd=\"*path*to*data*\" -i=properties.shp --pkey=TYPE --csv=land_class.csv --fkey=VALUE --import_field=NEW_VALUE
141141
>>.*{0} -r={1} -v --wd=\"*path*to*data*\" -i=properties.shp --pkey=TYPE --csv=land_class.csv --fkey=VALUE",
142142
short_exe, name
143143
).replace("*", &sep);

whitebox_tools.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ def list_tools(self, keywords=[]):
362362

363363

364364

365+
365366
##############
366367
# Data Tools #
367368
##############
@@ -422,7 +423,7 @@ def export_table_to_csv(self, i, output, headers=True, callback=None):
422423
if headers: args.append("--headers")
423424
return self.run_tool('export_table_to_csv', args, callback) # returns 1 if error
424425

425-
def join_tables(self, input1, pkey, input2, fkey, import, callback=None):
426+
def join_tables(self, input1, pkey, input2, fkey, import_field, callback=None):
426427
"""Merge a vector's attribute table with another table based on a common field.
427428
428429
Keyword arguments:
@@ -431,15 +432,15 @@ def join_tables(self, input1, pkey, input2, fkey, import, callback=None):
431432
pkey -- Primary key field.
432433
input2 -- Input foreign vector file (i.e. source of data to be imported).
433434
fkey -- Foreign key field.
434-
import -- Imported field (all fields will be imported if not specified).
435+
import_field -- Imported field (all fields will be imported if not specified).
435436
callback -- Custom function for handling tool text outputs.
436437
"""
437438
args = []
438439
args.append("--input1='{}'".format(input1))
439440
args.append("--pkey='{}'".format(pkey))
440441
args.append("--input2='{}'".format(input2))
441442
args.append("--fkey='{}'".format(fkey))
442-
args.append("--import='{}'".format(import))
443+
args.append("--import_field='{}'".format(import_field))
443444
return self.run_tool('join_tables', args, callback) # returns 1 if error
444445

445446
def lines_to_polygons(self, i, output, callback=None):
@@ -456,7 +457,7 @@ def lines_to_polygons(self, i, output, callback=None):
456457
args.append("--output='{}'".format(output))
457458
return self.run_tool('lines_to_polygons', args, callback) # returns 1 if error
458459

459-
def merge_table_with_csv(self, i, pkey, csv, fkey, import=None, callback=None):
460+
def merge_table_with_csv(self, i, pkey, csv, fkey, import_field=None, callback=None):
460461
"""Merge a vector's attribute table with a table contained within a CSV text file.
461462
462463
Keyword arguments:
@@ -465,15 +466,15 @@ def merge_table_with_csv(self, i, pkey, csv, fkey, import=None, callback=None):
465466
pkey -- Primary key field.
466467
csv -- Input CSV file (i.e. source of data to be imported).
467468
fkey -- Foreign key field.
468-
import -- Imported field (all fields will be imported if not specified).
469+
import_field -- Imported field (all fields will be imported if not specified).
469470
callback -- Custom function for handling tool text outputs.
470471
"""
471472
args = []
472473
args.append("--input='{}'".format(i))
473474
args.append("--pkey='{}'".format(pkey))
474475
args.append("--csv='{}'".format(csv))
475476
args.append("--fkey='{}'".format(fkey))
476-
if import is not None: args.append("--import='{}'".format(import))
477+
if import_field is not None: args.append("--import_field='{}'".format(import_field))
477478
return self.run_tool('merge_table_with_csv', args, callback) # returns 1 if error
478479

479480
def merge_vectors(self, inputs, output, callback=None):
@@ -1560,20 +1561,22 @@ def highest_position(self, inputs, output, callback=None):
15601561
args.append("--output='{}'".format(output))
15611562
return self.run_tool('highest_position', args, callback) # returns 1 if error
15621563

1563-
def intersect(self, i, overlay, output, callback=None):
1564+
def intersect(self, i, overlay, output, snap=0.0, callback=None):
15641565
"""Identifies the parts of features in common between two input vector layers.
15651566
15661567
Keyword arguments:
15671568
15681569
i -- Input vector file.
15691570
overlay -- Input overlay vector file.
15701571
output -- Output vector file.
1572+
snap -- Snap tolerance.
15711573
callback -- Custom function for handling tool text outputs.
15721574
"""
15731575
args = []
15741576
args.append("--input='{}'".format(i))
15751577
args.append("--overlay='{}'".format(overlay))
15761578
args.append("--output='{}'".format(output))
1579+
args.append("--snap={}".format(snap))
15771580
return self.run_tool('intersect', args, callback) # returns 1 if error
15781581

15791582
def line_intersections(self, input1, input2, output, callback=None):
@@ -1770,20 +1773,22 @@ def sum_overlay(self, inputs, output, callback=None):
17701773
args.append("--output='{}'".format(output))
17711774
return self.run_tool('sum_overlay', args, callback) # returns 1 if error
17721775

1773-
def symmetrical_difference(self, i, overlay, output, callback=None):
1776+
def symmetrical_difference(self, i, overlay, output, snap=0.0, callback=None):
17741777
"""Outputs the features that occur in one of the two vector inputs but not both, i.e. no overlapping features.
17751778
17761779
Keyword arguments:
17771780
17781781
i -- Input vector file.
17791782
overlay -- Input overlay vector file.
17801783
output -- Output vector file.
1784+
snap -- Snap tolerance.
17811785
callback -- Custom function for handling tool text outputs.
17821786
"""
17831787
args = []
17841788
args.append("--input='{}'".format(i))
17851789
args.append("--overlay='{}'".format(overlay))
17861790
args.append("--output='{}'".format(output))
1791+
args.append("--snap={}".format(snap))
17871792
return self.run_tool('symmetrical_difference', args, callback) # returns 1 if error
17881793

17891794
def union(self, i, overlay, output, snap=0.0, callback=None):

0 commit comments

Comments
 (0)