rotatePolys: Rotate Polygons and Events

Description Usage Arguments Details Value Note Author(s) References See Also

View source: R/extraFuns.r

Description

Rotate a PolySet (or an EventData set) clockwise by a specified angle around a fixed point.

Usage

1
2
3
4
5
6
rotatePolys(polys, angle=40, centroid=c(500,5700),
   proj.out, zone, xlim=c(-135,-121.5), ylim=c(47,56),
   plot=FALSE, keep.extra=FALSE, ...)

rotateEvents(data, angle=40, centroid=c(500,5700),
   proj.out, zone, plot=FALSE, keep.extra=FALSE, ...)

Arguments

polys

PolySet – data frame with fields 'PID', 'SID', 'POS', 'X', 'Y', and attribute 'projection' set to either "LL" or "UTM".

data

EventData – data frame with fields 'EID', 'POS', 'X', 'Y', and attribute 'projection' set to either "LL" or "UTM".

angle

numeric – angle between 0 and 360 degrees for map rotation in a clockwise direction.

centroid

numeric – fixed UTM point, specified in km, around which the map will be rotated. Rotation is performed in UTM space regardless of the input and output projections. If user specifies 'NULL' or 'NA', the centroid of the map will be used.

proj.out

character – desired output projection, where choices are 'LL' or 'UTM'. If 'proj.out' is not specified, the output projection will be the same as the projection of the input object.

zone

numeric – UTM zone used for rotation; if not supplied, the zone is set to 9.

xlim

numeric – two-element vector specifying the limits of X using units (degrees or km) that match the input projection.

ylim

numeric – two-element vector specifying the limits of Y using units (degrees or km) that match the input projection.

plot

logical – if TRUE, plot the results of the rotation.

keep.extra

logical – if TRUE, keep the coordinates of initial and intermediate steps in the rotation process in addition to the final rotated coordinates of the desired projection.

...

dots – additional arguments for 'plotMap' (in 'rotatePolys') or 'plotPoints' (in 'rotateEvents').

Details

Map rotation returns coordinates that are no longer meaningful with respect to the original coordinate system. When displaying rotated maps, the user might wish to turn off axis labels using xaxt="n" and yaxt="n".

Value

Rotated PolySet or EventData set where 'X' and 'Y' are the rotated coordinates in the projection specified by 'proj.out'. The returned object has an attribute list object named 'rotation' that contains:

When keep.extra=TRUE, the returned object will contain additional fields calculated by the rotational algorithm:

Note:
If proj.out="UTM", the coordinates c(rX, rY) are used as the final rotated coordinates. If proj.out="LL", the coordinates c(rX, rY) are transformed back into projection 'LL' as the final rotated coordinates.

Additionally, 'xylim' in the 'rotation' list attribute contains intermediary bounding box objects. For instance, if the input PolySet | EventData object has projection 'LL', the 'xylim' object contains:

Note

The map rotation algorithm is not heavily tested at this time. Report any issues to the package maintainer.

Author(s)

Rowan Haigh, Program Head – Offshore Rockfish
Pacific Biological Station (PBS), Fisheries & Oceans Canada (DFO), Nanaimo BC
locus opus: Institute of Ocean Sciences (IOS), Sidney BC
Last modified Rd: 2019-03-14

References

Academo – 2D Rotation about a point

Wikipedia – Rotation matrix

See Also

In package PBSmapping:
as.PolySet in PolySet, clipPolys, nepacLL, plotMap, plotPoints, refocusWorld, surveyData


PBSmapping documentation built on Jan. 15, 2021, 3:41 p.m.