Find the coordinates (longitude and latitude) of the ground control points (GCPs) in a given image.

find_gcp_coords(gcp, sf_obj)

Arguments

gcp

A data frame containing the GCPs with columns id, x, y, longitude, and latitude.

sf_obj

the reference map, as an sf object (already cut to the extend and if needed projected)

Value

A data frame with the GCPs, including their image coordinates and corresponding geographic coordinates.

Examples

if (FALSE) { # rlang::is_installed("rnaturalearth") && rlang::is_interactive()
# load required packages
library(sf)
library(rnaturalearth)
# get the path to an example image included in the package and choose GCPs
img_path <- system.file("extdata/europe_map.jpeg",
package = "crstools")
# choose some points
gcp_europe <- choose_gcp(img_path)
# now get some more
gcp_europe <- choose_gcp(img_path, gcp = gcp_europe)
# create a map of europe to use to get the coordinates
world <- ne_countries(scale = "medium", returnclass = "sf")
# transform it to a suitable projection
world <- st_transform(world, crs = 4326)
# crop it to the extent of the image
europe <- st_crop(world, c(xmin = -25, ymin=25, xmax = 45, ymax = 70))
# get the coordinates for these points
new_gcp_europe <- find_gcp_coords(gcp_europe, sf_obj = europe)
# data frame with the GCPs
print(new_gcp_europe)
}