[R-sig-Geo] Convert SpatialPointsDataFrame to SpatialPolygons or SpatialPolygonsDataFrame

Michael Sumner mdsumner at gmail.com
Mon Dec 26 07:24:22 CET 2016


It is but you will need at least a grouping ID for each polygon ring within
each object, and an order within each ring. Is ID_cell the object ID?

If there is only a single ring polygon within each object and the order is
native it's simplest, but the constructors require very particular
arrangements of your data, there is no abstractions for this. See
raster::spPolygons and spbabel::sp for alternative constructors, but other
wise see Polygon, Polygons, SpatialPolygons and SpatialPolygonsDataFrame in
sp.

There's not enough information in your post to be sure of what you have,
but I'm happy to help if you provide more detail about how your data is
organized. You could post sample data, or describe them in more detail. Do
you have actual  polygons here or are you attempting to estimate them from
point data?

To add more alternatives the new sf package simplifies the constructors a
lot, for a new family of classes, but still you need to nest matrices of
coordinates manually to use them rather than specify their organization
abstractly.  I'm working on tools to do that, but there is only spbabel so
far (it's really just a two-level grouping of coordinates for spatial
objects and their parts, but various legacies make it ever more
complicated).

Cheers, Mike

On Sun, Dec 25, 2016, 02:28 Miluji Sb <milujisb at gmail.com> wrote:

I have a SpatialPointsDataFrame with the following attributes. Is it
possible to convert this to a SpatialPolygons or SpatialPolygonsDataFrame?
Thank you!

Sincerely,

Milu

class       : SpatialPointsDataFrame
features    : 21441
extent      : -179.5, 179.5, -89.5, 83.5  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +a=6367470 +b=6367470 +no_defs
variables   : 7
names       : ID_cell,    lon,   lat, Field4, Field5, Field6, Field7
min values  :    2304,    0.5,   0.5,     NA,     NA,     NA,     NA
max values  :   64800, -179.5, -89.5,     NA,     NA,     NA,     NA

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list