Skip to content

Commit

Permalink
fixed duplicate handling for points
Browse files Browse the repository at this point in the history
  • Loading branch information
mhweber committed Apr 18, 2022
1 parent d197e00 commit 5b6a86b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion LakeCat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from border import makeBrdrPctFile
from lake_cat_config import LYR_DIR, NHD_DIR, OUT_DIR, STREAMCAT_DIR, FRAMEWORK
from LakeCat_functions import (Accumulation, NHDtblMerge, PointInPoly,
from LakeCat_functions import (Accumulation, NHDtblMerge, PointInPoly,dbf2DF,
chkColumnLength, doStats, getOnNetLakes, inputs,
makeBasins, makeNParrays, rpus)

Expand Down
9 changes: 4 additions & 5 deletions LakeCat_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,10 @@ def PointInPoly(points, inZoneData, pct_full, fld="GRIDCODE", summaryfield=None)
if not points.crs == polys.crs:
points = points.to_crs(polys.crs)
# Get list of lat/long fields in the table
latlon = [
s for s in points.columns if any(xs in s.upper() for xs in ["LONGIT", "LATIT"])
]
# Remove duplicate points for 'Count'
points2 = points.loc[~points.duplicated(latlon)]
points['lon'] = points['geometry'].x
points['lat'] = points['geometry'].y
# Remove duplicate points
points2 = points.drop_duplicates(subset=["lon", "lat"], keep='last')
try:
point_poly_join = sjoin(points2, polys, how="left", op="within")
except:
Expand Down

0 comments on commit 5b6a86b

Please sign in to comment.