Skip to content

Commit 739a3e8

Browse files
changes from code review
1 parent c9fb584 commit 739a3e8

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ import geopandas as gpd
219219
import a5
220220
from shapely.geometry import Polygon
221221

222-
o = pd.read_parquet('./tests/data/output/7/sample_tif_s2')
222+
o = pd.read_parquet('./tests/data/output/7/sample_tif_a5')
223223
o['geometry'] = o.index.map(lambda a: Polygon(a5.cell_to_boundary(a5.hex_to_u64(a))))
224224

225225
gpd.GeoDataFrame(o, geometry="geometry", crs="EPSG:4326").to_file('tests/data/output/7/sample_tif_a5.gpkg')

raster2dggs/a5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"--parent_res",
2828
required=False,
2929
type=click.Choice(list(map(str, range(const.MIN_A5, const.MAX_A5 + 1)))),
30-
help="A3 parent resolution to index and aggregate to. Defaults to resolution - 6",
30+
help="A5 parent resolution to index and aggregate to. Defaults to resolution - 6",
3131
)
3232
@click.option(
3333
"-u",

raster2dggs/indexers/a5rasterindexer.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
from raster2dggs.interfaces import RasterIndexer
1717

1818

19+
def is_valid_a5_cell(cell: str, min_resolution: int, max_resolution: int):
20+
cell = a5py.hex_to_u64(cell)
21+
try:
22+
c: a5py.A5Cell = a5py.core.serialization.deserialize(cell)
23+
except TypeError:
24+
return False
25+
if not (min_resolution <= c["resolution"] <= max_resolution):
26+
return False
27+
return True
28+
29+
1930
class A5RasterIndexer(RasterIndexer):
2031
"""
2132
Provides integration for the A5 DGGS.
@@ -106,15 +117,6 @@ def cell_to_children_size(self, cell: int, desired_resolution: int) -> int:
106117
cell_level = a5py.get_resolution(cell)
107118
return 4 ** (desired_resolution - cell_level)
108119

109-
def is_valid_cell(self, cell: str, min_resolution: int, max_resolution: int):
110-
cell = a5py.hex_to_u64(cell)
111-
try:
112-
c: a5py.A5Cell = a5py.core.serialization.deserialize(cell)
113-
except TypeError:
114-
return False
115-
if not (min_resolution <= c["resolution"] <= max_resolution):
116-
return False
117-
return True
118120

119121
def compaction(
120122
self, df: pd.DataFrame, resolution: int, parent_res: int
@@ -130,7 +132,7 @@ def compaction(
130132
unprocessed_indices = set(
131133
filter(
132134
lambda c: (not pd.isna(c))
133-
and self.is_valid_cell(c, parent_res, resolution),
135+
and is_valid_a5_cell(c, parent_res, resolution),
134136
set(df.index),
135137
),
136138
)

0 commit comments

Comments
 (0)