Skip to content

Commit 34053a9

Browse files
committed
Fix .grid call that escaped replacing to .get_grid()
1 parent 9f5f574 commit 34053a9

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

gridkit-py/examples/cell_centric_operations/downslope_path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
def downslope_path(cell_id):
5959
visited_cells.append(cell_id)
6060
# add new neigbours and their values to their respective lists
61-
neighbours = dem.grid.neighbours(cell_id, connect_corners=True)
61+
neighbours = dem.get_grid().neighbours(cell_id, connect_corners=True)
6262
for cell, value in zip(neighbours, dem.value(neighbours)):
6363
cell = tuple(cell.index)
6464
if not cell in visited_cells and not cell in all_neighbours:
@@ -80,7 +80,7 @@ def downslope_path(cell_id):
8080

8181
# %%
8282
# Determine the starting cell and call the function
83-
start_cell_id = dem.grid.cell_at_point((29330, 167848))
83+
start_cell_id = dem.get_grid().cell_at_point((29330, 167848))
8484
downslope_path(tuple(start_cell_id.index))
8585

8686

gridkit-py/examples/raster_operations/ndvi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@
6161
fig.colorbar(im_ndvi, ax=ax, fraction=0.022, pad=0.01)
6262
ax.set_xlabel("lon")
6363
ax.set_ylabel("lat")
64-
ax.set_title(f"NDVI of scene in the alps \n EPSG:{ndvi.grid.crs.to_epsg()}")
64+
ax.set_title(f"NDVI of scene in the alps \n EPSG:{ndvi.get_grid().crs.to_epsg()}")
6565

6666
plt.show()

gridkit-py/examples/raster_operations/resampling.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
dem = raster_to_data_tile(
2626
"../../tests/data/alps_dem.tiff", bounds=(28300, 167300, 28700, 167700)
2727
)
28-
print(f"Original resolution in (dx, dy): ({dem.grid.dx}, {dem.grid.dy})")
28+
print(f"Original resolution in (dx, dy): ({dem.get_grid().dx}, {dem.get_grid().dy})")
2929

3030

3131
# %%
@@ -49,8 +49,10 @@
4949
# Let's define a rectangular grid with a cell size of 10x10 degrees.
5050
# I am calling it rectdem for later on I will define hexagonal ones as well.
5151
# To make sure it worked we can print out the cellsize after resampling
52-
rectdem = dem.resample(RectGrid(dx=10, dy=10, crs=dem.grid.crs), method="linear")
53-
print(f"Downsampled resolution in (dx, dy): ({rectdem.grid.dx}, {rectdem.grid.dy})")
52+
rectdem = dem.resample(RectGrid(dx=10, dy=10, crs=dem.get_grid().crs), method="linear")
53+
print(
54+
f"Downsampled resolution in (dx, dy): ({rectdem.get_grid().dx}, {rectdem.get_grid().dy})"
55+
)
5456

5557
# %%
5658
#
@@ -71,10 +73,12 @@
7173
# for a fair visual comparison.
7274
#
7375
hexdem_flat = dem.resample(
74-
HexGrid(area=rectdem.grid.area, shape="flat", crs=dem.grid.crs), method="linear"
76+
HexGrid(area=rectdem.get_grid().area, shape="flat", crs=dem.get_grid().crs),
77+
method="linear",
7578
)
7679
hexdem_pointy = dem.resample(
77-
HexGrid(area=rectdem.grid.area, shape="pointy", crs=dem.grid.crs), method="linear"
80+
HexGrid(area=rectdem.get_grid().area, shape="pointy", crs=dem.get_grid().crs),
81+
method="linear",
7882
)
7983

8084

gridkit-py/gridkit/tile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ def resample(self, alignment_grid, method="nearest", **interp_kwargs):
995995
tile_is_given = isinstance(alignment_grid, Tile)
996996
if tile_is_given:
997997
tile = alignment_grid
998-
alignment_grid = alignment_grid.grid
998+
alignment_grid = alignment_grid.get_grid()
999999

10001000
if self.get_grid().crs is None or alignment_grid.crs is None:
10011001
warnings.warn(

0 commit comments

Comments
 (0)