Skip to content

Commit

Permalink
Try checking file type to fix external file deepsource issue
Browse files Browse the repository at this point in the history
  • Loading branch information
k034b363 committed Oct 11, 2024
1 parent 7ab2c4e commit 61e17bf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plantcv/geospatial/points_to_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import geojson
import rasterio
import os
from plantcv.plantcv import fatal_error


def points_to_geojson(img, viewer, out_path="./points.geojson"):
def points_to_geojson(img, viewer, out_path):
"""Use clicks from a Napari or plantcv-annotate viewer to output a geojson shapefile.
Parameters
Expand Down Expand Up @@ -35,5 +34,8 @@ def points_to_geojson(img, viewer, out_path="./points.geojson"):
"name": rasterio.crs.CRS.to_string(img.metadata["crs"])
}
}
with open(out_path, 'w') as writefile:
geojson.dump(feature_collection, writefile)
if ".geojson" in out_path:
with open(out_path, 'w') as f:
geojson.dump(feature_collection, f)
else:
fatal_error("File type not supported.")

0 comments on commit 61e17bf

Please sign in to comment.