8000 Improve deepforest.utilities.read_file for reading a .shp that doesn't have a image_path column · Issue #997 · weecology/DeepForest · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Improve deepforest.utilities.read_file for reading a .shp that doesn't have a image_path column #997
Open
@bw4sz

Description

@bw4sz

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
  1. We should allow users to pass an image_path to read_file. We currently have a root_dir argument, but no image_path argument.
  2. This assumes that all annotations in the file relate to the image_path, add a warning to make it clear.
  3. The same is true for the label column, should be an argument to read_file.
  4. Write tests for shapefiles, this is the common place we see this.
  5. 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0