Open
Description
Reading in data is often the hardest thing for users, we want to help them as much as possible at this step.
>>> ground_truth = read_file("/Users/benweinstein/Downloads/data/individual_align.shp")
m = main.deepforest()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/benweinstein/Documents/DeepForest/src/deepforest/utilities.py", line 331, in read_file
df = shapefile_to_annotations(input, root_dir=root_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/benweinstein/Documents/DeepForest/src/deepforest/utilities.py", line 184, in shapefile_to_annotations
raise ValueError(
ValueError: No image_path column found in shapefile, please specify rgb path
- We should allow users to pass an image_path to read_file. We currently have a root_dir argument, but no image_path argument.
- This assumes that all annotations in the file relate to the image_path, add a warning to make it clear.
- The same is true for the label column, should be an argument to read_file.
- Write tests for shapefiles, this is the common place we see this.
- Add an example to docs getting started for reading the file.
Current workaround
raster_path = "/Users/benweinstein/Downloads/data/SPA25_nogcp_crossrotate_aligned.tif"
gdf = gpd.read_file("/Users/benweinstein/Downloads/data/individual_align.shp")
gdf["image_path"] = os.path.basename(raster_path)
gdf["label"] = "Tree"
ground_truth = read_file(gdf, root_dir = os.path.dirname(raster_path))
This requires two unneeded library imports (os and geopandas) and supplies the root dir. The full versus relative path is an ongoing debate in DeepForest API and should not addressed here.