Skip to content
Prev 16058 / 29559 Next

Changing coords in SpatialPolgyon

Thanks, Nick.

what works, and probably does what you want, is this:

slot(all_emerged_islands_at_this_height_break at polygons[[1]]@Polygons[[1]],
 "coords", check=FALSE) = slot(tmppoly_shrunken, "coords")

I replaced here

all_emerged_islands_at_this_height_break[j]

with

all_emerged_islands_at_this_height_break

selection-assignment replaces whole objects, not just its first element.
As you address @polygons[[1]] you do make sure the replacement concerns
the first element only.

Your (somewhat understandable) assumption was that SpatialPolygons
objects have a [<- method, but they don't (none of the Spatial* objects do).

The error message "object of type 'S4' is not subsettable" is not very
enlightening. I'll think of adding a [<- method that only gives an error
message that is more helpful.

Best regards,
--
Edzer
On 09/13/2012 02:13 AM, Nick Matzke wrote: