Shift and rotate a geometry object. To help translate plot layout information into spatial coordinates.
transform_geometry.RdShift and rotate a geometry object. To help translate plot layout information into spatial coordinates.
Examples
# coordinates derived from plot metadata and an origin on the bottom-left of the map.
cornerpoints <- rbind(c(0,0),
c(0,10),
c(10,10),
c(10,0),
c(0,0))
mygeom <- sf::st_sfc(sf::st_polygon(list(cornerpoints)))
# points used to estimate rotation:
# Eyeballed from Googled maps imagery.
topleft <- c("lon" = -80.410466 , "lat" = 43.641394)
bottomleft <- c("lon"= -80.411367,"lat" = 43.640741)
myorigin <- sf::st_coordinates(
sf::st_transform(
sf::st_sfc(sf::st_point(c(bottomleft['lon'], bottomleft['lat'])), crs = 4326),
"ESRI:102008"))
## calculate bearing (degrees clockwise from true north)
mybearing <- bearing(lon1 = bottomleft['lon'],
lat1 = bottomleft['lat'],
lon2 = topleft['lon'],
lat2 = topleft['lat'])
newpolygon <- transform_geometry(mygeom, -mybearing,myorigin)