Skip to content

Commit

Permalink
Update WB_ID column to 1-based indexing from 0-based indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
vikineema committed Nov 29, 2023
1 parent 895a18c commit 249deb0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deafrica_waterbodies/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def assign_unique_ids(polygons: gpd.GeoDataFrame, precision: int = 10) -> gpd.Ge
# Make an arbitrary numerical ID for each polygon. We will first sort the dataframe by geohash
# so that polygons close to each other are numbered similarly.
polygons_with_unique_ids_sorted = polygons_with_unique_ids.sort_values(by=["UID"]).reset_index()
polygons_with_unique_ids_sorted["WB_ID"] = polygons_with_unique_ids_sorted.index
polygons_with_unique_ids_sorted["WB_ID"] = polygons_with_unique_ids_sorted.index + 1

assert polygons_with_unique_ids_sorted["WB_ID"].min() > 0

# The step above creates an 'index' column, which we don't actually want, so drop it.
polygons_with_unique_ids_sorted.drop(columns=["index"], inplace=True)
Expand Down

0 comments on commit 249deb0

Please sign in to comment.