Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
koettert committed Feb 3, 2024
1 parent ce55ece commit 4ac5ecc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
1 change: 0 additions & 1 deletion knime_extension/geospatial_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ dependencies:
- pip=23.2.1
- pygeoda=0.0.8
- pointpats=2.3.0
- h3-py=3.7.6
- pip:
- ipinfo==4.4.3
55 changes: 0 additions & 55 deletions knime_extension/src/nodes/spatialtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,6 @@ def execute(self, exec_context: knext.ExecutionContext, input_table):
)
@knext.input_table(
name="Input Table",
<<<<<<< Upstream, based on main
description="Input table with the geometry to fill with the H3 grid.",
)
@knext.output_table(
Expand Down Expand Up @@ -1286,60 +1285,6 @@ def execute(self, exec_context: knext.ExecutionContext, input_table):
geometry=[
Polygon(h3.h3_to_geo_boundary(h3_hex, geo_json=True))
for h3_hex in h3_hexes
=======
description="Input table of Create H3 Grid, should be a polygon with WGS-84/EPSG:4326 projection",
)
@knext.output_table(
name="Output Table",
description="Output table of Created H3 Grid",
)
class CreateH3Grid:
"""Create H3 Grid node.
This node creates hexagonal grid inside the input polygon using [H3](https://h3geo.org/).
"""

geo_col = knut.geo_col_parameter()

zoom = knext.IntParameter(
"Zoom",
"The zoom level of the grid from 0 to 15. Default value is 8, the bigger the zoom level, the smaller the hexagon. If the zoom level is too small, the hexagon will be too big to fit in the input polygon, and it can cause error.",
default_value=8,
)

_COL_ID = "Grid ID"
_COL_GEOMETRY = "geometry"

def configure(self, configure_context, input_schema):
self.geo_col = knut.column_exists_or_preset(
configure_context, self.geo_col, input_schema, knut.is_geo
)
return None

def execute(self, exec_context: knext.ExecutionContext, input_table):
import h3
from shapely.geometry import Polygon
import geopandas as gpd
import pandas as pd

gdf_boundary = knut.load_geo_data_frame(input_table, self.geo_col, exec_context)

h3_hexes = h3.polyfill_geojson(
gdf_boundary.geometry.__geo_interface__["features"][0]["geometry"],
self.zoom,
)
grid = gpd.GeoDataFrame(
pd.DataFrame(h3_hexes, columns=["h3_hex"]),
geometry=[
Polygon(h3.h3_to_geo_boundary(h3_hex, geo_json=True))
<<<<<<< Upstream, based on main
for h3_hex in h3.polyfill_geojson(
gdf_boundary.geometry.__geo_interface__["features"][0]["geometry"],
self.zoom,
)
>>>>>>> 3b2b1a2 add h3 grid
=======
for h3_hex in h3_hexes
>>>>>>> 65cd1d3 add h3 hex
],
crs=gdf_boundary.crs,
)
Expand Down

0 comments on commit 4ac5ecc

Please sign in to comment.