mBox: Return a spatial polygon from a point

Description Usage Arguments Details Examples

Description

Returns an object of type SpatialPolygons with a single feature.

Usage

1
2
3
mBox(x, y, wktstring, size = 500, square = T, long.ratio = 1.618034,
  landscape = T, proj.srid = "+init=epsg:3857",
  gcs.srid = "+init=epsg:4326")

Arguments

x

Real value corresponding to longitude of a point (expected as WGS84 or epsg:4326)

y

Real value corresponding to latitude of a point (expected as WGS84 or epsg:4326)

wktstring

a WKT formatted point required if x, y not given

size

radial size of box given in units for the given projection (see Details)

square

should a square box (of area 2*size^2) be returned; if F then a rectangle whose long side is a multiple of size configured by...

long.ratio

The factor for stretching the box along its long axis, configured by....

landscape

whether to make the long dimension the horizontal (x) (default) or vertical

proj.srid

a proj4string for a planar projected coordinate system. Default epsg:3857 or "Web Mercator"

Details

Default behavior is a square polygon based on radial distance (specified by size) in the unit of the projection spatial reference system. Default linear measure is in meters. Because it is defined radially a square buffer will have sides equal to 2x the size argument.

If square = F the size argument will be scaled as a multiple of long.ratio. If landscape = T (default) is chosen, then the X-axis (horizontal) side will be longer. Note that square = F implies a 1:1 correspondence between size and the shortest side of the rectangle. In other words, if the size argument is unchanged, the short side of a box from square = F will be one half the length of the side of a box where square = T. I could fix that pretty easily. But this works fine for me...

The function will return a polygon in the same coordinate system as the point given as input (specified as gcs.srid). It makes no attempt to transform the spatial reference system of the input point. As of now, it's only been tested with points in WGS84 (epsg:4326) lat/long (x = long, y = lat).

Note: The default (flawed) "Web Mercator" (EPSG:3857) was chosen as the planar spatial reference system so as not to bias in favor of any world region. Since it is used here for area calculations and given the Mercator's well-known exaggeration of areas as latitudes get larger, an equal-area projection is recomended (e.g. in the U.S., the US National Atlas "+init=epsg:2163").

Examples

1
2
3
box_1k = mBox(wktstring = "POINT(90 30)", size = 500)
box_1k = mBox(-90, 30, size = 500)
rectangle_1k = mBox(-90, 30, size = 1e3, square = F, long.ratio = 16/9)

townleym/mSpatial documentation built on May 31, 2019, 6:46 p.m.