added project argument to predict_tile for geo-coordinates#1250
added project argument to predict_tile for geo-coordinates#1250musaqlain wants to merge 2 commits intoweecology:mainfrom
project argument to predict_tile for geo-coordinates#1250Conversation
ethanwhite
left a comment
There was a problem hiding this comment.
Sorry this got lost in the queue @musaqlain. Everything looks really good. I've requested a couple of small changes to the docstring.
My one bigger question is what happens if someone sets project=True and passes a path to a non-georeferenced file. It would be good to make sure that we fail informatively in this case, which might happen automatically or might require a new check either in the new if project: block or in image_to_geo_coordinates
| - "batch" loads the entire image into GPU memory and creates views of an image as batch, requires in the entire tile to fit into GPU memory. CPU parallelization is possible for loading images. | ||
| - "window" loads only the desired window of the image from the raster dataset. Most memory efficient option, but cannot parallelize across windows. | ||
| crop_model: a deepforest.model.CropModel object to predict on crops | ||
| project (bool): If True, return a geopandas.GeoDataFrame with geometry column projected to the image CRS. Defaults to False. |
There was a problem hiding this comment.
It's not standard to declare the defaults in docstring so let's remove "Defaults to False." here.
|
|
||
| Returns: | ||
| pd.DataFrame or tuple: Predictions dataframe or (predictions, crops) tuple | ||
| pd.DataFrame or tuple: Predictions dataframe or (predictions, crops) tuple. If project=True, returns a geopandas.GeoDataFrame. |
There was a problem hiding this comment.
Change to "Predictions dataframe, geopandas.GeoDataFrame, or (predictions, crops) tuple." since I don't think it's standard to describe logic here, and we already have two possible types and we're not describing the difference between them
addresses Issue #608. Previously,
predict_tilereturned pixel coordinates even if the input was a georeferenced raster. This PR adds an optionalproject=Falseargument to allow users to request map coordinates directly.predict_tileinsrc/deepforest/main.pyto acceptproject(bool).project=True, the results are converted to a GeoDataFrame usingutilities.image_to_geo_coordinates.test_predict_tile_projectedtotests/test_main.pyto verify that settingproject=Truereturns a GeoDataFrame with valid CRS and map coordinates (UTM).Closes #608
AI-Assisted Development
I utilized AI for sanity checking code logic and conducting an assisted review to identify potential missing resets and schema constraints.