Skip to content

Commit a686f59

Browse files
committed
Harmonize and update node descriptions
1 parent 62e1c22 commit a686f59

File tree

11 files changed

+625
-620
lines changed

11 files changed

+625
-620
lines changed

knime_extension/src/nodes/calculation.py

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,18 @@ def execute(self, exec_context: knext.ExecutionContext, input_1):
327327
name="Transformed geo table",
328328
description="Transformed Geo input table",
329329
)
330+
@knut.geo_node_description(
331+
short_description="This node generate rectangles representing the envelope of each geometry.",
332+
description="""This node generate rectangles representing the envelope of each geometry.
333+
That is, the point or smallest rectangular polygon (with sides parallel to the coordinate axes)
334+
that contains each of the geometries.""",
335+
references={
336+
"Envelop": "https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoSeries.envelope.html",
337+
},
338+
)
330339
class BoundingBoxNode:
331-
"""
332-
This node generate rectangles representing the envelope of each geometry.
333-
"""
334-
335-
geo_col = knext.ColumnParameter(
336-
"Geometry column",
337-
"Select the geometry column to transform.",
338-
# Allow only GeoValue compatible columns
339-
column_filter=knut.is_geo,
340-
include_row_key=False,
341-
include_none_column=False,
340+
geo_col = knut.geo_col_parameter(
341+
description="Select the geometry column to compute the bounding box."
342342
)
343343

344344
def configure(self, configure_context, input_schema_1):
@@ -373,21 +373,22 @@ def execute(self, exec_context: knext.ExecutionContext, input_1):
373373
description="Table with geometry column to transform",
374374
)
375375
@knext.output_table(
376-
name="Transformed geo table",
376+
name="Transformed Geo table",
377377
description="Transformed Geo input table",
378378
)
379+
@knut.geo_node_description(
380+
short_description="This node generate the smallest convex Polygon containing all the points in each geometry.",
381+
description="""This node generate the smallest convex Polygon containing all the points in each geometry.
382+
The convex hull of a geometry is the smallest convex Polygon containing all the points in each geometry,
383+
unless the number of points in the geometric object is less than three. For two points, the convex hull
384+
collapses to a LineString; for 1, a Point.""",
385+
references={
386+
"Convex hull": "https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoSeries.convex_hull.html",
387+
},
388+
)
379389
class ConvexHullNode:
380-
"""
381-
This node generate the smallest convex Polygon containing all the points in each geometry.
382-
"""
383-
384-
geo_col = knext.ColumnParameter(
385-
"Geometry column",
386-
"Select the geometry column to transform.",
387-
# Allow only GeoValue compatible columns
388-
column_filter=knut.is_geo,
389-
include_row_key=False,
390-
include_none_column=False,
390+
geo_col = knut.geo_col_parameter(
391+
description="Select the geometry column to compute the convex hull."
391392
)
392393

393394
def configure(self, configure_context, input_schema_1):
@@ -425,18 +426,16 @@ def execute(self, exec_context: knext.ExecutionContext, input_1):
425426
name="Transformed geo table",
426427
description="Transformed Geo input table",
427428
)
429+
@knut.geo_node_description(
430+
short_description="This node returns a geometry containing the union of all geometries in the input column.",
431+
description="This node returns a geometry containing the union of all geometries in the input column.",
432+
references={
433+
"Unary union": "https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoSeries.unary_union.html",
434+
},
435+
)
428436
class UnaryUnionNode:
429-
"""
430-
This node generate the smallest convex Polygon containing all the points in each geometry.
431-
"""
432-
433-
geo_col = knext.ColumnParameter(
434-
"Geometry column",
435-
"Select the geometry column to transform.",
436-
# Allow only GeoValue compatible columns
437-
column_filter=knut.is_geo,
438-
include_row_key=False,
439-
include_none_column=False,
437+
geo_col = knut.geo_col_parameter(
438+
description="Select the geometry column to compute the unary union."
440439
)
441440

442441
def configure(self, configure_context, input_schema_1):

knime_extension/src/nodes/conversion.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,16 @@
2525
# Conversion helper methods
2626
########################################################################################
2727

28-
DEFAULT_CRS = "epsg:4326"
29-
"""Default coordinate reference system."""
30-
31-
__DEF_CRS_DESCRIPTION = """[Coordinate reference system (CRS)](https://en.wikipedia.org/wiki/Spatial_reference_system) column
32-
Supports the following input types:
33-
34-
- PROJ string
35-
- JSON string with PROJ parameters
36-
- CRS WKT string
37-
- An authority string [i.e. 'epsg:4326']
38-
- An EPSG integer code [i.e. 4326]
39-
- A tuple of ('auth_name': 'auth_code') [i.e ('epsg', '4326')]
40-
"""
41-
4228

4329
def crs_input_parameter(
4430
label: str = "CRS",
45-
description: str = __DEF_CRS_DESCRIPTION,
31+
description: str = knut.DEF_CRS_DESCRIPTION,
4632
) -> knext.StringParameter:
4733
"""Returns a CRS (coordinate reference system) string input parameter."""
4834
return knext.StringParameter(
4935
label=label,
5036
description=description,
51-
default_value=DEFAULT_CRS,
37+
default_value=knut.DEFAULT_CRS,
5238
)
5339

5440

@@ -153,7 +139,7 @@ def execute(self, exec_context, input_table):
153139
class WKTtoGeoNode(_ToGeoConverter):
154140

155141
input_column = knext.ColumnParameter(
156-
label="WKT Column",
142+
label="WKT column",
157143
description="[Well-known-text (WKT)](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) column to convert",
158144
column_filter=knut.is_string,
159145
include_row_key=False,
@@ -192,7 +178,7 @@ def __init__(self):
192178
# class WKBtoGeoNode(_ToGeoConverter):
193179

194180
# input_column = knext.ColumnParameter(
195-
# label="WKB Column",
181+
# label="WKB column",
196182
# description="[Well-known-binary (WKB)](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) column to convert",
197183
# column_filter=knut.is_binary,
198184
# include_row_key=False,
@@ -227,7 +213,7 @@ def __init__(self):
227213
class GeoJSONtoGeoNode(_ToGeoConverter):
228214

229215
input_column = knext.ColumnParameter(
230-
label="GeoJSON Column",
216+
label="GeoJSON column",
231217
description="[GeoJSON](https://en.wikipedia.org/wiki/GeoJSON) column to convert",
232218
column_filter=knut.is_string,
233219
include_row_key=False,
@@ -308,6 +294,13 @@ def configure(self, configure_context, input_schema_1):
308294
f"Output column '{_ToGeoConverter.DEF_GEO_COL_NAME}' exists in input table",
309295
)
310296
validate_crs(self.crs)
297+
from shapely.geometry import Point
298+
299+
return input_schema_1.append(
300+
knext.Column(
301+
ktype=knext.logical(Point), name=_ToGeoConverter.DEF_GEO_COL_NAME
302+
)
303+
)
311304

312305
def execute(self, exec_context: knext.ExecutionContext, input_table):
313306
# https://geopandas.org/en/stable/docs/user_guide/projections.html#the-axis-order-of-a-crs
@@ -564,6 +557,8 @@ def execute(self, exec_context: knext.ExecutionContext, input_1):
564557
gs = gdf.loc[:, self.geo_col]
565558
# https://geopandas.org/en/stable/docs/user_guide/projections.html#the-axis-order-of-a-crs
566559
# In GeoPandas the coordinates are always stored as (x, y), and thus as (lon, lat) order, regardless of the CRS
567-
gdf[self.col_lon] = gs.x
560+
# However the standard order for EPSG:4326 is latitude, longitude which is why we use this order in the output
561+
# Also the ISO 6709 standard (https://en.wikipedia.org/wiki/ISO_6709) uses this order
568562
gdf[self.col_lat] = gs.y
563+
gdf[self.col_lon] = gs.x
569564
return knut.to_table(gdf, exec_context)

knime_extension/src/nodes/io.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,23 @@
3131
)
3232
@knext.output_table(
3333
name="Geodata table",
34-
description="Geodata from the input file path.",
34+
description="Geodata from the input file.",
3535
)
3636
@knut.geo_node_description(
3737
short_description="Read single layer GeoFile.",
38-
description="""This node reads a single geofile from the path to the file or URL with geopandas.read_file().
39-
The support file formats contain the popular data type such as ESRI Shapefile (.shp), zipped Shapefiles(.zip),single-layer GeoPackage file, or GeoJSON.
40-
The standard Lcoal File path in KNIME Explorer,e.g.,'E:\KNIMEworkspace\test.geojson', can work as a file path without quotaion marks.
38+
description="""This node reads a single geospatial file from the path to the file or URL.
39+
The supported file formats are the popular data types such as ESRI Shapefile (.shp), zipped Shapefiles(.zip),
40+
single-layer GeoPackage file, or GeoJSON.
41+
Example of a standard local file path would be *C:/KNIMEworkspace/test.geojson*.
4142
""",
4243
references={
4344
"Reading Spatial Data": "https://geopandas.org/en/stable/docs/user_guide/io.html",
45+
"Read file": "https://geopandas.org/en/stable/docs/reference/api/geopandas.read_file.html",
4446
},
4547
)
4648
class GeoFileReaderNode:
4749
data_url = knext.StringParameter(
48-
"Input File Path",
50+
"Input file path",
4951
"The file path for reading data.",
5052
"",
5153
)
@@ -78,9 +80,11 @@ def execute(self, exec_context: knext.ExecutionContext):
7880
)
7981
@knut.geo_node_description(
8082
short_description="Write single layer GeoFile.",
81-
description="This node writes the data in the format of Shapefile or GeoJSON with geopandas.to_file().",
83+
description="""This node writes the data in the format of Shapefile or GeoJSON.
84+
Example of a standard local file path would be *C:/KNIMEworkspace/test.geojson*.""",
8285
references={
8386
"Writing Spatial Data": "https://geopandas.org/en/stable/docs/user_guide/io.html",
87+
"To file": "https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.to_file.html",
8488
},
8589
)
8690
class GeoFileWriterNode:
@@ -94,13 +98,13 @@ class GeoFileWriterNode:
9498
)
9599

96100
data_url = knext.StringParameter(
97-
"Output file path and file name",
101+
"Output file path",
98102
"The file path for writing data without the file format or extension.",
99103
"",
100104
)
101105

102106
dataformat = knext.StringParameter(
103-
"Output File Format",
107+
"Output file format",
104108
"The file path to save the data in the format of .shp or .geojson.",
105109
"Shapefile",
106110
enum=["Shapefile", "GeoJSON"],
@@ -141,18 +145,19 @@ def execute(self, exec_context: knext.ExecutionContext, input_1):
141145
)
142146
@knut.geo_node_description(
143147
short_description="Read GeoPackage layer",
144-
description="""This node reads the GeoPackage, GeoDatabase(GDB) data with geopandas.read_file().
148+
description="""This node reads the GeoPackage, GeoDatabase(GDB) data.
145149
Using this node needs to specify the layer name, if set empty or wrong, the node will read the first layer.
146150
The number as a layer order can also be applied, such as 0, 1, or other integer numbers .
147151
The node will export the names of all layers as a table, which can be utilized to revise the name of target layer.
148152
""",
149153
references={
150154
"Reading Spatial Data": "https://geopandas.org/en/stable/docs/user_guide/io.html",
155+
"Read file": "https://geopandas.org/en/stable/docs/reference/api/geopandas.read_file.html",
151156
},
152157
)
153158
class GeoPackageReaderNode:
154159
data_url = knext.StringParameter(
155-
"Input File Path",
160+
"Input file path",
156161
"The file path for reading data.",
157162
"",
158163
)
@@ -168,21 +173,20 @@ def configure(self, configure_context):
168173
return None
169174

170175
def execute(self, exec_context: knext.ExecutionContext):
171-
layerlist=fiona.listlayers(self.data_url)
172-
pnumber = pd.Series(range(0,100)).astype(str).to_list()
173-
if self.data_layer in layerlist:
176+
layerlist = fiona.listlayers(self.data_url)
177+
pnumber = pd.Series(range(0, 100)).astype(str).to_list()
178+
if self.data_layer in layerlist:
174179
gdf = gp.read_file(self.data_url, layer=self.data_layer)
175-
elif self.data_layer in pnumber :
176-
nlayer=int(self.data_layer)
177-
gdf = gp.read_file(self.data_url,layer=nlayer)
180+
elif self.data_layer in pnumber:
181+
nlayer = int(self.data_layer)
182+
gdf = gp.read_file(self.data_url, layer=nlayer)
178183
else:
179-
gdf = gp.read_file(self.data_url,layer=0)
184+
gdf = gp.read_file(self.data_url, layer=0)
180185
gdf = gdf.reset_index(drop=True)
181-
listtable = pd.DataFrame({'layerlist': layerlist})
186+
listtable = pd.DataFrame({"layerlist": layerlist})
182187
return knext.Table.from_pandas(gdf), knext.Table.from_pandas(listtable)
183188

184189

185-
186190
############################################
187191
# GeoPackage Writer
188192
############################################
@@ -199,11 +203,12 @@ def execute(self, exec_context: knext.ExecutionContext):
199203
)
200204
@knut.geo_node_description(
201205
short_description="Write GeoPackage layer.",
202-
description="""This node writes the data as a layer into a GeoPackage data with geopandas.to_file().
203-
If the layer is already in the GeoPackage data, the orginal data of the target layer will be written by the new data.
206+
description="""This node writes the data as a layer into a GeoPackage data.
207+
If the layer is already in the GeoPackage data, the original data of the target layer will be written by the new data.
204208
""",
205209
references={
206210
"Writing Spatial Data": "https://geopandas.org/en/stable/docs/user_guide/io.html",
211+
"To file": "https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.to_file.html",
207212
},
208213
)
209214
class GeoPackageWriterNode:
@@ -217,7 +222,9 @@ class GeoPackageWriterNode:
217222
)
218223

219224
data_url = knext.StringParameter(
220-
"Input File Path", "The file path for saving data.", "",
225+
"Input file path",
226+
"The file path for saving data.",
227+
"",
221228
)
222229

223230
data_layer = knext.StringParameter(

knime_extension/src/nodes/locationanalysis.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class PmedianNode:
7171

7272
DemandPopu = knext.ColumnParameter(
7373
"Column for demand population",
74-
"The populaiton of demand",
74+
"The population of demand",
7575
# port_index=2,
7676
column_filter=knut.is_numeric,
7777
include_row_key=False,
@@ -425,16 +425,16 @@ def getIndex(s):
425425
)
426426
@knext.input_table(
427427
name="Input OD list with geometries ",
428-
description="Table with geometry information of demand and supply ",
428+
description="Table with geometry information of demand and supply",
429429
)
430430
@knext.output_table(
431431
name="Demand table with MCLP result",
432432
description="Demand table with assigned supply point and link",
433433
)
434434
@knut.pulp_node_description(
435435
short_description="Solve MCLP problem to Maximize Capacitated Coverage by setting an impedance cutoff.",
436-
description="The MCLP model, maximum covering location problem (MCLP), aims to Locate p facilities,"
437-
+ " and demand is covered ifit is within a specifieddistance (time) of a facility. "
436+
description="The MCLP model, maximum covering location problem (MCLP), aims to Locate p facilities,"
437+
+ " and demand is covered if it is within a specified distance (time) of a facility. "
438438
+ "The P-Median problem will be solved by PuLP package. ",
439439
references={
440440
"Pulp.Solver": "https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html",
@@ -462,7 +462,7 @@ class MCLPNode:
462462

463463
DemandPopu = knext.ColumnParameter(
464464
"Column for demand population",
465-
"The populaiton of demand",
465+
"The population of demand",
466466
# port_index=2,
467467
column_filter=knut.is_numeric,
468468
include_row_key=False,

0 commit comments

Comments
 (0)