| Title: | Local Point-Count Processing for Coral Photoquadrats |
|---|---|
| Description: | Imports Coral Point Count with Excel extensions (CPCe) point-count annotations and related exported tables, standardizes labels with a user-supplied crosswalk, creates ecological cover summaries, writes quality-control overlays, and exports machine-learning-ready point labels, image patches, sparse masks, and train/validation/test splits. The package is fully local and does not depend on third-party web platforms, user accounts, or other closed services. CPCe methods are described by Kohler and Gill (2006) "Coral Point Count with Excel extensions (CPCe): A Visual Basic program for the determination of coral and substrate coverage using random point count methodology" <doi:10.1016/j.cageo.2005.11.009>. |
| Authors: | Elvin Cordero [aut, cre] |
| Maintainer: | Elvin Cordero <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-06-20 09:12:19 UTC |
| Source: | https://github.com/el-cordero/pointcoral |
Reports labels in CPCe data missing from the crosswalk, crosswalk labels not present in current data, duplicate mappings, missing class IDs, and excluded classes.
check_crosswalk(points, crosswalk, by = NULL)check_crosswalk(points, crosswalk, by = NULL)
points |
A tidy point table. |
crosswalk |
A crosswalk data frame. |
by |
Optional join columns. See |
A tibble report.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") xwalk <- system.file( "extdata", "pointcoral_example_crosswalk.csv", package = "pointcoral" ) pts <- read_cpce_file(cpc) check_crosswalk(pts, read_label_crosswalk(xwalk))cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") xwalk <- system.file( "extdata", "pointcoral_example_crosswalk.csv", package = "pointcoral" ) pts <- read_cpce_file(cpc) check_crosswalk(pts, read_label_crosswalk(xwalk))
Converts point coordinates from the CPCe coordinate space to actual image pixels by proportional scaling. Original CPCe coordinates are preserved.
convert_cpce_coords( points, cpce_width = NULL, cpce_height = NULL, image_width = NULL, image_height = NULL )convert_cpce_coords( points, cpce_width = NULL, cpce_height = NULL, image_width = NULL, image_height = NULL )
points |
A data frame with |
cpce_width, cpce_height
|
CPCe coordinate-space width and height. If
|
image_width, image_height
|
Image width and height in pixels. If |
A tibble with updated x_px and y_px columns.
pts <- tibble::tibble(cpce_x = c(0, 50, 100), cpce_y = c(0, 25, 50)) convert_cpce_coords(pts, 100, 50, 1000, 500)pts <- tibble::tibble(cpce_x = c(0, 50, 100), cpce_y = c(0, 25, 50)) convert_cpce_coords(pts, 100, 50, 1000, 500)
This helper writes local point labels only. It does not connect to CoralNet.
export_coralnet_points(points, out_dir)export_coralnet_points(points, out_dir)
points |
A tidy point table. |
out_dir |
Output directory. |
Path to the written CSV.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") export_coralnet_points( read_cpce_file(cpc), file.path(tempdir(), "pointcoral-coralnet-example") )cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") export_coralnet_points( read_cpce_file(cpc), file.path(tempdir(), "pointcoral-coralnet-example") )
Writes sparse weak-label masks and a manifest. These are not dense segmentation annotations.
export_segformer_sparse(points, image_root, out_dir, radius = 3)export_segformer_sparse(points, image_root, out_dir, radius = 3)
points |
A tidy point table. |
image_root |
Image root. |
out_dir |
Output directory. |
radius |
Point disk radius. |
A mask manifest tibble.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) export_segformer_sparse( pts[1:3, ], image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-segformer-example"), radius = 2 )example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) export_segformer_sparse( pts[1:3, ], image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-segformer-example"), radius = 2 )
Extracts point-centered patches into split/class folders and writes a patch manifest.
export_yolo_classification(points, image_root, out_dir, patch_size = 224)export_yolo_classification(points, image_root, out_dir, patch_size = 224)
points |
A tidy point table. |
image_root |
Image root. |
out_dir |
Output directory. |
patch_size |
Patch size in pixels. |
A patch manifest tibble.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) export_yolo_classification( pts[20:25, ], image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-yolo-example"), patch_size = 64 )example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) export_yolo_classification( pts[20:25, ], image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-yolo-example"), patch_size = 64 )
Extracts square image patches centered on CPCe points and writes a manifest.
extract_point_patches( points, image_root, out_dir, patch_size = 224, class_col = "ml_class", edge = c("skip", "pad") )extract_point_patches( points, image_root, out_dir, patch_size = 224, class_col = "ml_class", edge = c("skip", "pad") )
points |
A tidy point table. |
image_root |
Image root used to match images when |
out_dir |
Output patch directory. |
patch_size |
Patch width/height in pixels. |
class_col |
Class column used for folder names and labels. |
edge |
|
A patch manifest tibble.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) out_dir <- file.path(tempdir(), "pointcoral-patches-example") extract_point_patches( pts[1:3, ], image_root = example_dir, out_dir = out_dir, patch_size = 64, class_col = "raw_label", edge = "pad" )example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) out_dir <- file.path(tempdir(), "pointcoral-patches-example") extract_point_patches( pts[1:3, ], image_root = example_dir, out_dir = out_dir, patch_size = 64, class_col = "raw_label", edge = "pad" )
Produces a distinct class lookup table from point data. If no usable class ID column exists, IDs are assigned in sorted class order starting at 0.
make_class_lookup(points, class_col = "ml_class", id_col = "class_id")make_class_lookup(points, class_col = "ml_class", id_col = "class_id")
points |
A tidy point table. |
class_col |
Column containing class labels. |
id_col |
Column containing integer class IDs. |
A tibble with class labels and IDs.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") xwalk <- system.file( "extdata", "pointcoral_example_crosswalk.csv", package = "pointcoral" ) pts <- standardize_labels(read_cpce_file(cpc), read_label_crosswalk(xwalk)) make_class_lookup(pts, class_col = "ml_class")cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") xwalk <- system.file( "extdata", "pointcoral_example_crosswalk.csv", package = "pointcoral" ) pts <- standardize_labels(read_cpce_file(cpc), read_label_crosswalk(xwalk)) make_class_lookup(pts, class_col = "ml_class")
Creates a compact table suitable for patch classification or weakly supervised segmentation workflows.
make_ml_points(points, image_root = NULL, class_col = "ml_class")make_ml_points(points, image_root = NULL, class_col = "ml_class")
points |
A tidy point table. |
image_root |
Optional image root used to match image paths. |
class_col |
Label column to use as the ML label. |
A tibble with image_path, image_id, x_px, y_px, label,
class_id, split, and available metadata.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") make_ml_points(read_cpce_file(cpc), class_col = "raw_label")cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") make_ml_points(read_cpce_file(cpc), class_col = "raw_label")
Writes sparse masks where point neighborhoods contain class_id values and
all unlabeled pixels are ignore_index. These are weak labels, not dense
human-annotated segmentation masks.
make_sparse_masks( points, image_root, out_dir, radius = 3, ignore_index = 255, background_index = 0, class_col = "ml_class" )make_sparse_masks( points, image_root, out_dir, radius = 3, ignore_index = 255, background_index = 0, class_col = "ml_class" )
points |
A tidy point table. |
image_root |
Image root used to match images when needed. |
out_dir |
Output directory. |
radius |
Disk radius in pixels around each point. |
ignore_index |
Pixel value for unlabeled pixels. |
background_index |
Reserved background value. Included for downstream
schemas; unlabeled pixels still default to |
class_col |
Label column used to assign |
A mask manifest tibble.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) out_dir <- file.path(tempdir(), "pointcoral-masks-example") make_sparse_masks( pts[1:3, ], image_root = example_dir, out_dir = out_dir, radius = 2, class_col = "raw_label" )example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) out_dir <- file.path(tempdir(), "pointcoral-masks-example") make_sparse_masks( pts[1:3, ], image_root = example_dir, out_dir = out_dir, radius = 2, class_col = "raw_label" )
Matches image_file values in a point table to files under image_root.
Image dimensions are filled in, and pixel coordinates are calculated when
CPCe and image dimensions are available.
match_images(points, image_root, image_col = "image_file")match_images(points, image_root, image_col = "image_file")
points |
A pointcoral point table. |
image_root |
Root folder containing images. |
image_col |
Column in |
A point table with image_path, image_width, and image_height.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) pts$image_path <- NA_character_ match_images(pts, image_root = example_dir)example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) pts$image_path <- NA_character_ match_images(pts, image_root = example_dir)
Draws point halos and labels on an image and returns a magick-image object.
plot_points_on_image( image_path, points, label_col = "ml_class", point_size = 8 )plot_points_on_image( image_path, points, label_col = "ml_class", point_size = 8 )
image_path |
Path to an image. |
points |
Point rows for that image. |
label_col |
Column to use for text labels. |
point_size |
Point radius in pixels. |
A magick-image overlay.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) plot_points_on_image(pts$image_path[1], pts[1:5, ], label_col = "raw_label")example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) plot_points_on_image(pts$image_path[1], pts[1:5, ], label_col = "raw_label")
Reports unmapped labels, rare labels, duplicate points, and class balance in a compact tibble.
qc_label_summary(points, label_col = "ml_class", rare_threshold = 1L)qc_label_summary(points, label_col = "ml_class", rare_threshold = 1L)
points |
A tidy point table. |
label_col |
Label column to summarize. |
rare_threshold |
Count at or below which labels are flagged as rare. |
A QC summary tibble.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") qc_label_summary(read_cpce_file(cpc), label_col = "raw_label")cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") qc_label_summary(read_cpce_file(cpc), label_col = "raw_label")
Reads generic CPCe-like point exports from CSV, TSV, XLS, or XLSX files, cleans column names, and maps common coordinate/label columns to the pointcoral tidy point schema. Project-specific ecological "Data Summary" workbooks are not fully translated yet because representative workbook fixtures are not bundled with the package.
read_cpce_export(path)read_cpce_export(path)
path |
Path to a CSV, TSV, XLS, or XLSX export. |
A tidy point table when point-like columns are present.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") pts <- read_cpce_file(cpc) tmp <- tempfile(fileext = ".csv") readr::write_csv(pts[, c("image_file", "point_id", "x_px", "y_px", "raw_label")], tmp) read_cpce_export(tmp)cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") pts <- read_cpce_file(cpc) tmp <- tempfile(fileext = ".csv") readr::write_csv(pts[, c("image_file", "point_id", "x_px", "y_px", "raw_label")], tmp) read_cpce_export(tmp)
.cpc fileReads the tested text .cpc format used by the bundled examples: header row,
four ROI vertices, point count, point coordinate rows, and point label rows.
If an image with the same basename is present next to the .cpc file, image
dimensions are read and x_px/y_px are calculated.
read_cpce_file(path)read_cpce_file(path)
path |
Path to a |
A tidy point table.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") pts <- read_cpce_file(cpc) dplyr::glimpse(pts)cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") pts <- read_cpce_file(cpc) dplyr::glimpse(pts)
Recursively reads supported CPCe-related files from a folder. .cpc files
are parsed with read_cpce_file(). CSV/TSV/XLS/XLSX files are attempted with
read_cpce_export().
read_cpce_folder(path, image_root = NULL, recursive = TRUE)read_cpce_folder(path, image_root = NULL, recursive = TRUE)
path |
Folder containing CPCe files/exports. |
image_root |
Optional image root used to match image paths after import. |
recursive |
Whether to search recursively. |
A combined tidy point table.
example_dir <- system.file("extdata", package = "pointcoral") read_cpce_folder(example_dir, image_root = example_dir, recursive = FALSE)example_dir <- system.file("extdata", package = "pointcoral") read_cpce_folder(example_dir, image_root = example_dir, recursive = FALSE)
_raw sheets from a CPCe output workbookCPCe output workbooks often contain one worksheet per image, with raw point
annotation worksheets named like image_name_raw. This function reads only
those raw worksheets, skips deep_cres_..._raw worksheets by default, keeps
the raw worksheet columns, adds image_name and point_index as the first
columns, and adds a full major_category column using a label crosswalk.
point_index is a 1-based row index within each raw worksheet, matching the
CPCe point order.
read_cpce_output_raw_tabs( path, crosswalk = NULL, skip_deep_cres = TRUE, sheet_pattern = "_raw$" )read_cpce_output_raw_tabs( path, crosswalk = NULL, skip_deep_cres = TRUE, sheet_pattern = "_raw$" )
path |
Path to a CPCe output |
crosswalk |
Optional label crosswalk data frame or path. When |
skip_deep_cres |
Whether to skip worksheets whose names start with
|
sheet_pattern |
Regular expression used to identify raw worksheets.
Defaults to sheets ending in |
A tibble combining all selected raw worksheets. The first columns are
image_name and point_index. The original CPCe raw major/group column is
preserved as cpce_major_category when present.
xlsx <- system.file( "extdata", "pointcoral_example_cpce_output_raw_tabs.xlsx", package = "pointcoral" ) read_cpce_output_raw_tabs(xlsx)xlsx <- system.file( "extdata", "pointcoral_example_cpce_output_raw_tabs.xlsx", package = "pointcoral" ) read_cpce_output_raw_tabs(xlsx)
Reads a CSV, TSV, XLS, or XLSX crosswalk table, cleans column names, recognizes common synonyms, and validates that the table contains at least one raw label/code key and at least one output class field.
read_label_crosswalk(path)read_label_crosswalk(path)
path |
Path to a crosswalk file. |
A tidy crosswalk tibble.
xwalk <- system.file( "extdata", "pointcoral_example_crosswalk.csv", package = "pointcoral" ) read_label_crosswalk(xwalk)xwalk <- system.file( "extdata", "pointcoral_example_crosswalk.csv", package = "pointcoral" ) read_label_crosswalk(xwalk)
Reads CPCe files/exports from a folder, matches images, validates points, and
writes analysis/ML-ready outputs. A crosswalk is optional. Without one,
pointcoral uses the raw labels already stored in the CPCe files. With one,
it standardizes those raw labels to full labels, ecological classes, and
custom ML classes.
run_pointcoral( cpce_dir, image_root, out_dir, crosswalk_path = NULL, recursive = TRUE, class_col = "ml_class", patch_size = 224, make_patches = TRUE, make_masks = FALSE, make_qc = TRUE )run_pointcoral( cpce_dir, image_root, out_dir, crosswalk_path = NULL, recursive = TRUE, class_col = "ml_class", patch_size = 224, make_patches = TRUE, make_masks = FALSE, make_qc = TRUE )
cpce_dir |
Folder containing CPCe files or exports. |
image_root |
Folder containing source images. |
out_dir |
Output directory. |
crosswalk_path |
Optional path to a user-supplied label crosswalk. |
recursive |
Whether to search |
class_col |
Class column to use for ML labels. |
patch_size |
Patch size for point-centered patches. |
make_patches, make_masks, make_qc
|
Whether to write optional outputs. |
A list from write_pointcoral_dataset().
example_dir <- system.file("extdata", package = "pointcoral") run_pointcoral( cpce_dir = example_dir, image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-run-example"), recursive = FALSE, make_patches = FALSE, make_masks = FALSE, make_qc = FALSE, class_col = "raw_label" )example_dir <- system.file("extdata", package = "pointcoral") run_pointcoral( cpce_dir = example_dir, image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-run-example"), recursive = FALSE, make_patches = FALSE, make_masks = FALSE, make_qc = FALSE, class_col = "raw_label" )
Assigns split labels by image, transect, or site to avoid leakage. Splits are
reproducible with seed.
split_ml_points( points, split_by = c("image", "transect", "site"), train = 0.7, val = 0.15, test = 0.15, seed = 1 )split_ml_points( points, split_by = c("image", "transect", "site"), train = 0.7, val = 0.15, test = 0.15, seed = 1 )
points |
A tidy point table. |
split_by |
One of |
train, val, test
|
Split proportions. |
seed |
Random seed. |
The input table with split and split_unit columns.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_folder(example_dir, image_root = example_dir, recursive = FALSE) split_ml_points(pts, split_by = "image", train = 0.5, val = 0, test = 0.5)example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_folder(example_dir, image_root = example_dir, recursive = FALSE) split_ml_points(pts, split_by = "image", train = 0.5, val = 0, test = 0.5)
Joins raw CPCe labels/codes to user-defined clean labels, ecological categories, ML classes, and class IDs. Raw labels and raw codes are always preserved.
standardize_labels( points, crosswalk, by = NULL, unknown_action = c("warn", "keep", "drop", "error") )standardize_labels( points, crosswalk, by = NULL, unknown_action = c("warn", "keep", "drop", "error") )
points |
A tidy point table. |
crosswalk |
A crosswalk data frame, usually from |
by |
Optional join columns. Use a character vector for same-name joins or a named vector where names are point-table columns and values are crosswalk columns. |
unknown_action |
How to handle labels not found in the crosswalk:
|
A tidy point table with standardized label columns.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") xwalk <- system.file( "extdata", "pointcoral_example_crosswalk.csv", package = "pointcoral" ) pts <- read_cpce_file(cpc) standardize_labels(pts, read_label_crosswalk(xwalk))cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") xwalk <- system.file( "extdata", "pointcoral_example_crosswalk.csv", package = "pointcoral" ) pts <- read_cpce_file(cpc) standardize_labels(pts, read_label_crosswalk(xwalk))
Summarize points at image level
summarize_images(points, class_col = "major_category")summarize_images(points, class_col = "major_category")
points |
A tidy point table. |
class_col |
Class/label column to summarize. |
An image-level summary tibble.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") summarize_images(read_cpce_file(cpc), class_col = "raw_label")cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") summarize_images(read_cpce_file(cpc), class_col = "raw_label")
Counts point labels by grouping variables and returns percent cover within each group.
summarize_points( points, by = c("site", "transect", "image_id"), class_col = "major_category" )summarize_points( points, by = c("site", "transect", "image_id"), class_col = "major_category" )
points |
A tidy point table. |
by |
Grouping columns. |
class_col |
Class/label column to summarize. |
A summary tibble with n, n_points, and percent.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") pts <- read_cpce_file(cpc) summarize_points(pts, by = "image_id", class_col = "raw_label")cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") pts <- read_cpce_file(cpc) summarize_points(pts, by = "image_id", class_col = "raw_label")
Summarize points at site level
summarize_sites(points, class_col = "major_category")summarize_sites(points, class_col = "major_category")
points |
A tidy point table. |
class_col |
Class/label column to summarize. |
A site-level summary tibble.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") summarize_sites(read_cpce_file(cpc), class_col = "raw_label")cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") summarize_sites(read_cpce_file(cpc), class_col = "raw_label")
Summarize points at transect level
summarize_transects(points, class_col = "major_category")summarize_transects(points, class_col = "major_category")
points |
A tidy point table. |
class_col |
Class/label column to summarize. |
A transect-level summary tibble.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") summarize_transects(read_cpce_file(cpc), class_col = "raw_label")cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") summarize_transects(read_cpce_file(cpc), class_col = "raw_label")
Checks required fields, missing coordinates, duplicated point IDs within images, coordinates outside image bounds, missing image files, and missing image dimensions.
validate_points(points)validate_points(points)
points |
A tidy point table. |
A validation report tibble.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") validate_points(read_cpce_file(cpc))cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") validate_points(read_cpce_file(cpc))
Writes labels.csv, class_lookup.csv, and split-specific label CSVs when a
split column is present.
write_ml_points_csv(points, out_dir)write_ml_points_csv(points, out_dir)
points |
An ML-ready point table or tidy point table. |
out_dir |
Output directory. |
A named list of written file paths.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") ml <- make_ml_points(read_cpce_file(cpc), class_col = "raw_label") write_ml_points_csv(ml, file.path(tempdir(), "pointcoral-ml-csv-example"))cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") ml <- make_ml_points(read_cpce_file(cpc), class_col = "raw_label") write_ml_points_csv(ml, file.path(tempdir(), "pointcoral-ml-csv-example"))
Runs the common local workflow: validation, ecological summaries,
train/validation/test splits, ML label CSVs, optional point patches, optional
sparse masks, and optional QC overlays. If crosswalk is NULL, the
workflow uses the raw CPCe labels already stored in the point table. A
crosswalk is an optional standardization layer for full labels, ecological
major classes, and custom ML classes.
write_pointcoral_dataset( points, image_root, out_dir, crosswalk = NULL, patch_size = 224, make_patches = TRUE, make_masks = FALSE, make_qc = TRUE, class_col = "ml_class" )write_pointcoral_dataset( points, image_root, out_dir, crosswalk = NULL, patch_size = 224, make_patches = TRUE, make_masks = FALSE, make_qc = TRUE, class_col = "ml_class" )
points |
Imported point data. |
image_root |
Image root for matching images. |
out_dir |
Output directory. |
crosswalk |
Optional crosswalk data frame or path. |
patch_size |
Patch size for point-centered patches. |
make_patches, make_masks, make_qc
|
Whether to write optional outputs. |
class_col |
Class column to use for ML labels. |
A list containing paths, tibbles, and manifests.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_folder(example_dir, image_root = example_dir, recursive = FALSE) write_pointcoral_dataset( points = pts, image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-dataset-example"), make_patches = FALSE, make_masks = FALSE, make_qc = FALSE, class_col = "raw_label" )example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_folder(example_dir, image_root = example_dir, recursive = FALSE) write_pointcoral_dataset( points = pts, image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-dataset-example"), make_patches = FALSE, make_masks = FALSE, make_qc = FALSE, class_col = "raw_label" )
Writes one overlay image per source image.
write_qc_overlays(points, image_root, out_dir, label_col = "ml_class")write_qc_overlays(points, image_root, out_dir, label_col = "ml_class")
points |
A tidy point table. |
image_root |
Image root used to match images when needed. |
out_dir |
Output directory. |
label_col |
Label column to draw. |
A manifest tibble of written overlays.
example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) write_qc_overlays( pts[1:5, ], image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-qc-example"), label_col = "raw_label" )example_dir <- system.file("extdata", package = "pointcoral") pts <- read_cpce_file(file.path(example_dir, "HIW_158_W_U-1.cpc")) write_qc_overlays( pts[1:5, ], image_root = example_dir, out_dir = file.path(tempdir(), "pointcoral-qc-example"), label_col = "raw_label" )
Writes image-, transect-, and site-level summaries for one or more class columns, plus a class lookup table when possible.
write_summary_tables( points, out_dir, class_cols = c("major_category", "clean_label", "ml_class") )write_summary_tables( points, out_dir, class_cols = c("major_category", "clean_label", "ml_class") )
points |
A tidy point table. |
out_dir |
Output directory for summary CSV files. |
class_cols |
Class columns to summarize. |
A named list of written file paths.
cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") pts <- read_cpce_file(cpc) out_dir <- file.path(tempdir(), "pointcoral-summary-example") write_summary_tables(pts, out_dir, class_cols = "raw_label")cpc <- system.file("extdata", "HIW_158_W_U-1.cpc", package = "pointcoral") pts <- read_cpce_file(cpc) out_dir <- file.path(tempdir(), "pointcoral-summary-example") write_summary_tables(pts, out_dir, class_cols = "raw_label")