Skip to content

Commit

Permalink
Merge pull request #152 from initze/rem_geemap
Browse files Browse the repository at this point in the history
removed geemap dependency from water masking
  • Loading branch information
initze authored Jul 15, 2024
2 parents 938b809 + 862cdf4 commit 39a18bc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/thaw_slump_segmentation/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import List, Optional, Union

import ee
import geemap
import geopandas as gpd
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -737,7 +736,7 @@ def filter_remove_water(gdf, threshold=0.2):
"""

# convert gdf to ee FC
rts_ee = geemap.gdf_to_ee(gdf)
rts_ee = ee.FeatureCollection(gdf.__geo_interface__)
# load gee layer
esri_lulc2020 = ee.ImageCollection('projects/sat-io/open-datasets/landcover/ESRI_Global-LULC_10m')
# filter to rts footprint
Expand All @@ -747,7 +746,7 @@ def filter_remove_water(gdf, threshold=0.2):
# reduce regions and get value
reduced = ee.Image.reduceRegions(water_layer, rts_ee, reducer=ee.Reducer.mean(), scale=10)
# convert to gdf
gdf_out = geemap.ee_to_gdf(reduced)
gdf_out = ee.data.computeFeatures({'expression': reduced, 'fileFormat': 'GEOPANDAS_GEODATAFRAME'})
# filter to no water
gdf_filtered = gdf.loc[gdf_out.query(f'mean <= {threshold}').index]

Expand Down

0 comments on commit 39a18bc

Please sign in to comment.