Creating your own Spatial Objects

GPSVisualizer allows creation of text files with coordinates for any polygon (or line etc). Then use R's read.delim to create dataframes. Assume two dataframes are named poly1, poly2, poly3.

Convert a single set of coordinates into a polygon. Note the area is already calculated!

OnePoly=Polygon(poly1)
TwoPoly=Polygon(poly2)
ThreePoly=Polygon(poly3)
OnePoly@area
OnePoly@bbox

Groups of polygons can be combined into Polygons, and subsequently into SpatialPolygons. This matches the structure of Spatial Classes: groups of polygons. This can now be plotted etc. There is also a way to add your down data slot, ie a dataframe with information about each of the Polygons. You need to create a dataframe with one row per group of polygons. Assume below it is named YOURDATA.

Polys12=Polygons(list(OnePoly,TwoPoly))
Polys3=Polygons(list(ThreePoly))
SPoly=SpatialPolygon(list(Polys12,Polys3))
sp::plot(Spoly)    ## map omitted
slotNames(Spoly)
# SPolyData=SpatialPolygonsDataFrame(SPoly,<i>YOURDATA</i>)