Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoReferenced ROIs from points shapefile #19

Open
HaleySchuhl opened this issue Sep 30, 2024 · 0 comments
Open

GeoReferenced ROIs from points shapefile #19

HaleySchuhl opened this issue Sep 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@HaleySchuhl
Copy link
Contributor

HaleySchuhl commented Sep 30, 2024

Used this code from Keely to make circular ROIs & will brainstorm how to best add this feature flexibly.

import geopandas as gpd

# Try to convert points file to shapefile with circles

gdf = gpd.read_file("./plant_positions.shp")

# Specify the desired diameter (in the same units as the CRS, e.g., meters)
radius = 0.4  # Half the diameter to use as buffer radius

# Generate a circle (buffer) around each point
gdf['geometry'] = gdf.geometry.buffer(radius)

# Save the resulting circles as a GeoJSON file
gdf.to_file('./output_circles.geojson', driver='GeoJSON')


geo_rois = geo.transform_polygons(img=spectral, geojson='./shpfiles/kura_center_circles.geojson')
# now take these contours and make them into a labeled mask? 
all_objs = Objects()
lbl_mask = np.zeros(np.shape(gray)).astype(np.int32)
i = 1
for roi in geo_rois:
    new = [np.array(roi, dtype=np.int32)]
    lbl_mask = cv2.drawContours(lbl_mask.astype(np.int32), new, -1, (i), -1)
    all_objs.append(contour=roi, h=[])
    i += 1

label_mask_where = np.where(plant_mask == 255, lbl_mask, 0)
@HaleySchuhl HaleySchuhl added the enhancement New feature or request label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant