I feel a bit lazy asking for help, as I know I can do this -- but since I don't work with spatial polygons frequently, I find assembling objects consisting of nested polygons to be a bit challenging.

I have a Spatial Polygons Data Frame object named "s2poly" (read in from a polygons shapefile). The first portion of the output from str(s2poly) is shown here:

Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
  ..@ data       :'data.frame': 1173 obs. of  11 variables:
  .. ..$ OBJECTID  : num [1:1173] 3 12 13 77 78 79 80 81 82 83 ...
  .. ..$ ENTITY    : Factor w/ 0 levels: NA NA NA NA NA NA NA NA NA NA ...
.. ..$ HANDLE : Factor w/ 1173 levels "10002","10008",..: 348 349 350 351 352 353 354 355 356 357 ... .. ..$ LAYER : Factor w/ 15 levels "ADMIN_MAP","B-BLDG-LINE",..: 14 8 8 8 8 11 11 11 11 9 ...
  .. ..$ COLOR     : num [1:1173] 252 4 4 4 4 200 200 200 200 7 ...
.. ..$ LINETYPE : Factor w/ 3 levels "Continuous","DASHED",..: 1 1 1 1 1 1 1 1 1 1 ...
  .. ..$ ELEVATION : num [1:1173] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ THICKNESS : num [1:1173] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ TEXT      : Factor w/ 0 levels: NA NA NA NA NA NA NA NA NA NA ...
  .. ..$ SHAPE_AREA: num [1:1173] 10.8 32549.7 16571.2 37.7 59.2 ...
  .. ..$ SHAPE_LEN : num [1:1173] 19 932.6 608 77.4 120.3 ...
  .. ..- attr(*, "data_types")= chr [1:11] "N" "C" "C" "C" ...
  ..@ polygons   :List of 1173
  .. ..$ :Formal class 'Polygons' [package "sp"] with 5 slots
  .. .. .. ..@ Polygons :List of 1
  .. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots
  .. .. .. .. .. .. ..@ labpt  : num [1:2] 1653186 431813
  .. .. .. .. .. .. ..@ area   : num 10.8
  .. .. .. .. .. .. ..@ hole   : logi FALSE
  .. .. .. .. .. .. ..@ ringDir: int 1
.. .. .. .. .. .. ..@ coords : num [1:8, 1:2] 1653190 1653190 1653187 1653188 1653183 ...
  .. .. .. ..@ plotOrder: int 1
  .. .. .. ..@ labpt    : num [1:2] 1653186 431813
  .. .. .. ..@ ID       : chr "0"
  .. .. .. ..@ area     : num 10.8


I suspect, but have not confirmed, that some of the instances of Polygons objects have length > 1.

I have also created a simple polygon named "s2bound" that surrounds all of the polygons in s2poly.

I need a single object that I can give to spsample() in which all of the polygons in s2poly are holes within s2bound. I don't need to keep any of the attributed data in @data, so I believe I can simplify to a SpatialPolygons object.

My basic request for assistance is this:

- can it be done with a modest number of high levels functions? (and if so, I think I need to be shown how)

- or will I need to write nested loops of @Polygons within @polygons to change @hole to TRUE in every polygon, in order construct my final polygon?

Thanks
-Don
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to