create_Polys {CCAMLRGIS}R Documentation

Create Polygons

Description

Create Polygons such as proposed Research Blocks or Marine Protected Areas.

Usage

create_Polys(
  Input,
  OutputFormat = "ROBJECT",
  OutputName = NULL,
  Buffer = 0,
  Densify = TRUE,
  Clip = FALSE,
  SeparateBuf = TRUE,
  NamesIn = NULL
)

Arguments

Input

the name of the Input data as a .csv file or an R dataframe. If a .csv file is used as input, this file must be in your working directory and its name given in quotes e.g. "DataFile.csv".

If NamesIn is not provided, the columns in the Input must be in the following order:

Polygon name, Latitude, Longitude.

Latitudes and Longitudes must be given clockwise.

OutputFormat

can be an R object or an ESRI Shapefile. if OutputFormat is specified as "ROBJECT" (the default), a SpatialPolygonDataFrame is created in your R environment. if OutputFormat is specified as "SHAPEFILE", an ESRI Shapefile is exported in your working directory.

OutputName

if OutputFormat is specified as "SHAPEFILE", the name of the output shapefile in quotes (e.g. "MyPolygons") must be provided.

Buffer

Distance in nautical miles by which to expand the polygons. Can be specified for each polygon (as a numeric vector).

Densify

If set to TRUE, additional points between points of equal latitude are added prior to projection (see examples).

Clip

if set to TRUE, polygon parts that fall on land are removed (see Clip2Coast).

SeparateBuf

If set to FALSE when adding a Buffer, all spatial objects are merged, resulting in a single spatial object.

NamesIn

character vector of length 3 specifying the column names of polygon identifier, Latitude and Longitude fields in the Input.

Names must be given in that order, e.g.:

NamesIn=c('Polygon ID','Poly Latitudes','Poly Longitudes').

Value

Spatial object in your environment or ESRI shapefile in your working directory. Data within the resulting spatial object contains the data provided in the Input plus an additional "AreaKm2" column which corresponds to the areas, in square kilometers, of your polygons. Also, columns "Labx" and "Laby" which may be used to add labels to polygons.

To see the data contained in your spatial object, type: View(MyPolygons@data).

See Also

create_Points, create_Lines, create_PolyGrids, create_Stations, add_RefGrid.

Examples




#Example 1: Simple and non-densified polygons

MyPolys=create_Polys(Input=PolyData,Densify=FALSE)
plot(MyPolys,col='blue')
text(MyPolys$Labx,MyPolys$Laby,MyPolys$ID,col='white')

#Example 2: Simple and densified polygons (note the curvature of iso-latitude lines)

MyPolys=create_Polys(Input=PolyData)
plot(MyPolys,col='red')
text(MyPolys$Labx,MyPolys$Laby,MyPolys$ID,col='white')

#Example 3: Buffered and clipped polygons

MyPolysBefore=create_Polys(Input=PolyData,Buffer=c(10,-15,120))
MyPolysAfter=create_Polys(Input=PolyData,Buffer=c(10,-15,120),Clip=TRUE)
plot(MyPolysBefore,col='green')
plot(Coast[Coast$ID=='All',],add=TRUE)
plot(MyPolysAfter,col='red',add=TRUE)
text(MyPolysAfter$Labx,MyPolysAfter$Laby,MyPolysAfter$ID,col='white')

#Example 4: Buffered and grouped polygons
MyPolys=create_Polys(Input=PolyData,Buffer=80,SeparateBuf=FALSE)
plot(MyPolys,border='blue',lwd=3)





[Package CCAMLRGIS version 3.0.7 Index]