crop | R Documentation |
Select and cut a polygon shaped area of interest from a satin object.
crop(X, polygon = NULL, return.poly = FALSE)
X |
a satin object as returned by |
polygon |
a polygon defining the area of interest (aoi) to be cutted. |
return.poly |
if TRUE, |
If provided, the polygon defining the aoi must have two columns with x and y coordinates. The function verifies that the last point is exactly the same as the first one. When not specified, the user can draw a polygon by clicking on a previously displayed image. Note that for drawing the polygon in this manner, the plot of the satin object has to be created using colbar = FALSE
. The result is a satin object where the pixels outside the aoi are set to NA. In order to cut Copernicus data returned from read.cmems
, the appropriate indexing should be previously done.
A cutted satin object.
When return.poly = TRUE
, a list with two components:
aoi |
cutted satin object. |
polygon |
polygon coordinates defining the aoi. |
Héctor Villalobos
getpoly
# load and display sample data data(dsst) plot(dsst) # define polygon, cut the image and display the aoi polyg <- data.frame(x = c(-110, -105, -113, -116, -110), y = c(23, 23, 32, 32, 23)) dsst.clip <- crop(dsst, polygon = polyg) plot(dsst.clip) if(interactive()){ # the same, but polygon is defined by clicking on the image plot(dsst, colbar = FALSE) dsst.clip2 <- crop(dsst, return.poly = TRUE) # *** draw the aoi polygon *** dsst.clip2$polygon # show polygon coordinates plot(dsst.clip2$aoi) # plot the selected aoi }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.