diff --git a/docs/points_to_geojson.md b/docs/points_to_geojson.md index de2554a..57b5b39 100644 --- a/docs/points_to_geojson.md +++ b/docs/points_to_geojson.md @@ -7,7 +7,7 @@ Using a Napari or PlantCV-annotate viewer object with clicked points, output a s - **Parameters:** - img - Spectral image object, likely read in with [`geo.read_geotif`](read_geotif.md) - viewer - Napari viewer class object or plantcv-annotate Points class object. - - out_path - Path to save the geojson shapefile. + - out_path - Path to save the geojson shapefile. Must be ".geojson" file type. - **Context:** - Saved points can be used downstream for generating circular ROIs or circles for use with rasterstats. diff --git a/plantcv/geospatial/points_to_geojson.py b/plantcv/geospatial/points_to_geojson.py index 0571502..f64eb86 100644 --- a/plantcv/geospatial/points_to_geojson.py +++ b/plantcv/geospatial/points_to_geojson.py @@ -15,7 +15,7 @@ def points_to_geojson(img, viewer, out_path): viewer: Napari viewer class object or plantcv-annotate Points class object. The viewer used to make the clicks. out_path : str - Path to save to shapefile. + Path to save to shapefile. Must have "geojson" file extension """ # Napari output, points must be reversed if hasattr(viewer, 'layers'): diff --git a/tests/test_geospatial_points_to_geojson.py b/tests/test_geospatial_points_to_geojson.py index 9042971..d06d1fe 100644 --- a/tests/test_geospatial_points_to_geojson.py +++ b/tests/test_geospatial_points_to_geojson.py @@ -42,3 +42,13 @@ def test_geospatial_points_to_geojson_badviewer(test_data, tmpdir): filename = os.path.join(cache_dir, 'test_out.geojson') with pytest.raises(RuntimeError): points_to_geojson(img, viewer, out_path=filename) + +def test_geospatial_points_to_geojson_badfilename(test_data, tmpdir): + """Test for plantcv-geospatial.""" + cache_dir = tmpdir.mkdir("cache") + img = read_geotif(filename=test_data.rgb_tif, bands="R,G,B") + viewer = FakePoints() + viewer.coords["default"] = [] + filename = os.path.join(cache_dir, 'test_out.txt') + with pytest.raises(RuntimeError): + points_to_geojson(img, viewer, out_path=filename)