Learn R Programming

CCAMLRGIS (version 3.0.7)

create_Points: Create Points

Description

Create Points to display point locations. Buffering points may be used to produce bubble charts.

Usage

create_Points(
  Input,
  OutputFormat = "ROBJECT",
  OutputName = NULL,
  Buffer = 0,
  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:

Latitude, Longitude, Variable 1, Variable 2, ... Variable x

OutputFormat

can be an R object or an ESRI Shapefile. if OutputFormat is specified as "ROBJECT" (the default), a spatial object 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. "MyPoints") must be provided.

Buffer

Radius in nautical miles by which to expand the points. Can be specified for each point (as a numeric vector).

Clip

if set to TRUE, polygon parts (from buffered points) 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 2 specifying the column names of Latitude and Longitude fields in the Input. Latitudes name must be given first, e.g.:

NamesIn=c('MyLatitudes','MyLongitudes').

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 additional "x" and "y" columns which corresponds to the projected points locations and may be used to label points (see examples).

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

See Also

create_Lines, create_Polys, create_PolyGrids, create_Stations, add_RefGrid.

Examples

Run this code
# NOT RUN {

#Example 1: Simple points with labels

MyPoints=create_Points(Input=PointData)
plot(MyPoints)
text(MyPoints$x,MyPoints$y,MyPoints$name,adj=c(0.5,-0.5),xpd=TRUE)

#Example 2: Simple points with labels, highlighting one group of points with the same name

MyPoints=create_Points(Input=PointData)
plot(MyPoints)
text(MyPoints$x,MyPoints$y,MyPoints$name,adj=c(0.5,-0.5),xpd=TRUE)
plot(MyPoints[MyPoints$name=='four',],bg='red',pch=21,cex=1.5,add=TRUE)

#Example 3: Buffered points with radius proportional to catch

MyPoints=create_Points(Input=PointData,Buffer=0.5*PointData$Catch)
plot(MyPoints,col='green')
text(MyPoints$x,MyPoints$y,MyPoints$name,adj=c(0.5,0.5),xpd=TRUE)

#Example 4: Buffered points with radius proportional to catch and clipped to the Coast

MyPoints=create_Points(Input=PointData,Buffer=2*PointData$Catch,Clip=TRUE)
plot(MyPoints,col='cyan')
plot(Coast[Coast$ID=='All',],add=TRUE,col='grey')


# }
# NOT RUN {
# }

Run the code above in your browser using DataLab