Skip to content

Conversation

FranzEricSchneider
Copy link
Contributor

Creates a visualization that allows you to see which detections were filtered out by a mask and why (by checking which detections different components of the mask overlaps with.

Tested using this code which resulted in images like this.

"use_rds,geo_extension",
([True, None], [False, ".gpkg"], [False, ".geojson"], [False, ".shp"]),
)
def test_empty(self, tmp_path, use_rds, geo_extension):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into an error with an empty GDF, this test replicated the error and then started passing when the error was fixed.

Returns:
gpd.GeoDataFrame: Detections in the requested CRS
RegionDetections: Detections in the requested CRS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updating the docstring to match what the code is doing

mask_iterator: Iterable[np.ndarray],
threshold: float = 0.4,
) -> List[RegionDetectionsSet]:
) -> Union[List[RegionDetectionsSet], List[gpd.GeoDataFrame]]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a change in behavior, just correcting the hint to match the behavior

(x0, y0) center of the ellipse in x and y (pixels)
axes (Tuple[int, int]):
(a, b) semi-major and semi-minor axis lengths in pixels
(a, b) x and y axis lengths (before rotation) in pixels
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more correct description

@FranzEricSchneider FranzEricSchneider marked this pull request as ready for review August 27, 2025 22:02
Copy link
Contributor

@amrithasp02 amrithasp02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice visualization tool!

detection_overlay = Image.new("RGBA", image.size, (0, 0, 0, 0))
detection_draw = ImageDraw.Draw(detection_overlay, "RGBA")
for idx, row in gdf1.iterrows():
has_match = row["unique_ID"] in gdf2["unique_ID"].values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "unique_id" column gets created whenever merge() is done on a RegionDetectionsSet. So if the detections are being read from a .gpkg/.geojson file is it expected by the file to have the "unique_ID" column? If so should that be specified in the documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, the files that I was using (documented in the PR description) came from TDF and had that column so I assumed it would generally be available. I suppose

  1. Is there a better column available?
  2. If not, we can add id_column as an argument with unique_ID as the default

Copy link
Contributor

@amrithasp02 amrithasp02 Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. Any files created using TDF is guaranteed to have the unique_ID column. I was only asking for use cases where this could get input vector files generated outside of TDF. But I guess there isn't a possibility of that happening.

If needed, I think it would be good to add id_column as an argument with unique_ID default like you suggested, just to keep it more flexible.

Copy link
Contributor

@russelldj russelldj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants