Skip to content

Commit b701793

Browse files
authored
Fix: Fix weighted centroid calculation (#393)
The third bug found when looking into #390. I can't believe I'd never hit this before, but I was using the x coordinate values to update the _y_ value of the weighted centroid. So you'd potentially get this error for any large datasets in the western hemisphere.
1 parent fcafdbf commit b701793

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

lonboard/_cli.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
from lonboard import viz
1313

14-
# path = Path("/Users/kyle/github/developmentseed/lonboard/DC_Wetlands.parquet")
15-
# path = Path("/Users/kyle/Downloads/UScounties.geojson")
16-
1714

1815
def read_pyogrio(path: Path) -> pa.Table:
1916
"""Read path using pyogrio and convert field metadata to geoarrow

lonboard/_geoarrow/ops/centroid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def update_coords(self, coords: pa.FixedSizeListArray):
7373
new_chunk_modifier = new_chunk_len / (self.num_items + new_chunk_len)
7474

7575
new_chunk_avg_x = np.mean(np_arr[:, 0])
76-
new_chunk_avg_y = np.mean(np_arr[:, 0])
76+
new_chunk_avg_y = np.mean(np_arr[:, 1])
7777

7878
existing_x_avg = self.x
7979
existing_y_avg = self.y

0 commit comments

Comments
 (0)