PatBall1 / detectree2

Python package for automatic tree crown delineation based on the Detectron2 implementation of Mask R-CNN
https://patball1.github.io/detectree2/
MIT License
158 stars 39 forks source link

outputs.stitch_crowns is registering the same CRS as being different #88

Open rjstack266 opened 1 year ago

rjstack266 commented 1 year ago

Hi there, am trying to stitch predictions together and am getting the following error:

ValueError: Cannot determine common CRS for concatenation inputs, got ['WGS 84 / UTM zone 30N', 'WGS 84 / UTM zone 30N']. Use to_crs() to transform geometries to the same CRS before merging.

I have attempted to force a different crs onto the predictions using a for_loop (shown below but error persists). The two "different" crs's shown are identical!

specify the input and output folders

input_folder = tiles_path + "predictions_geo/" output_folder = tiles_path + "predictions_geo_crs32630/"

specify the target CRS

target_crs = 'EPSG:32630'

loop through all files in the input folder

for filename in os.listdir(input_folder):

construct the full file path for the input and output files

input_filepath = os.path.join(input_folder, filename)
output_filepath = os.path.join(output_folder, filename)

# read the file using geopandas
gdf = gpd.read_file(input_filepath)

# apply the to_crs() function to the file
gdf_reprojected = gdf.to_crs(target_crs)

# write the reprojected file to the output folder
gdf_reprojected.to_file(output_filepath)
zeppehpt1 commented 1 year ago

Did you follow the "Generating landscape predictions" steps from the documentation?

rjstack266 commented 1 year ago

Not completely - the tutorial does not actually define the variable crowns that is referenced.

Tutorial says: project_to_geojson(data, tiles_path + "predictions_geo/", tiles_path + "predictions/") crowns = crowns[crowns.is_valid] crowns = clean_crowns(crowns, 0.6)

I am using

outputs.project_to_geojson(data, tiles_path + "predictions_geo/", tiles_path + "predictions/") crowns = outputs.stitch_crowns(tiles_path + "/predictions_geo/",1)

The predictions themselves are made just fine, I can take the crowns and drop them over an orthographic photo in QGIS. There is just massive overlap thanks to tiling.

PatBall1 commented 1 year ago

Hi @rjstack266 sorry you are having some issues. I am away in the field this week but I will have a look at correcting the bug or updating the tutorial as soon as I am back.

rjstack266 commented 1 year ago

Thank you very much sir, I'll look out for it.

On Sun, Feb 12, 2023, 9:05 AM James Ball @.***> wrote:

Hi @rjstack266 https://github.com/rjstack266 sorry you are having some issues. I am away in the field this week but I will have a look at correcting the bug or updating the tutorial as soon as I am back.

— Reply to this email directly, view it on GitHub https://github.com/PatBall1/detectree2/issues/88#issuecomment-1426980019, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4PUCMWYKIP5SXDOWRMUJL3WXCRTZANCNFSM6AAAAAAUXFC26A . You are receiving this because you were mentioned.Message ID: @.***>