Skip to content

Commit

Permalink
refactor(prediction): remove bbox feature removal logic
Browse files Browse the repository at this point in the history
refactor(vectorizer): filter out background polygons during vectorization
  • Loading branch information
kshitijrajsharma committed Nov 26, 2024
1 parent a8d1b66 commit a442cb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 0 additions & 8 deletions predictor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ def predict(
if remove_metadata:
shutil.rmtree(base_path)

if (
"features" in prediction_geojson_data
and len(prediction_geojson_data["features"]) > 0
):
prediction_geojson_data["features"].pop(
-1
) # Remove the last feature explicitly for the removal of whole bbox

for feature in prediction_geojson_data["features"]:
feature["properties"]["building"] = "yes"
feature["properties"]["source"] = "fAIr"
Expand Down
9 changes: 7 additions & 2 deletions predictor/vectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ def vectorize(
resampling=Resampling.nearest,
)

# Close raster files after merging
for raster in rasters:
raster.close()

polygons = [shape(s) for s, _ in shapes(mosaic, transform=output)]
polygons = []

for s, value in shapes(mosaic, transform=output):

if value != 0: # value 0 is background
polygons.append(shape(s))

gs = gpd.GeoSeries(polygons, crs=kwargs["crs"])

# Explode MultiPolygons
Expand Down

0 comments on commit a442cb6

Please sign in to comment.