View source: R/georeference_img.R
| georeference_img | R Documentation |
This function warps a given image using a set of Ground Control Points (GCPs)
to create a georeferenced version of the image. The function uses GDAL tools
to first translate the image into a georeferenced TIFF format and then
applies a warp operation to reproject the image into a spatial reference
system (EPSG:4326). The warped image is saved as a new file with the suffix
_warp.tif.
georeference_img(image_obj, gcp, output_path = NULL)
image_obj |
A character string specifying the file path to the input image (JPEG format). The function reads this image and applies the GCPs for georeferencing. |
gcp |
A data frame containing the Ground Control Points (GCPs). This dataframe can be produced with the draw_gcp_points function. This data frame should have the following columns:
|
output_path |
A character string representing the file path to the input
image. ( |
A character string representing the path to the newly created warped
TIFF image file (_warp.tif). This file contains the georeferenced image.
# get the path to an example image included in the package
img_path <- system.file("extdata/europe_map.jpeg", package = "crstools")
# load a set of GCPs (or we could create them using the choose_gcp()
# and find_gcp() functions)
gcp_df <- readRDS(system.file(
"extdata/europe_gcp_georef.RDS",
package = "crstools"
))
#' # Assuming you have a set of GCPs in gcp_df and an image file "image.jpg"
warped_img <- georeference_img(
image_obj = img_path, gcp = gcp_df,
output_path = tempfile(
patter = "georef_img_",
tmpdir = tempdir(),
fileext = ".tif"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.