[R-sig-Geo] Extracting regions with no neighbors from Map2poly object

Alexander.Herr at csiro.au Alexander.Herr at csiro.au
Wed Jun 29 02:16:25 CEST 2005


Thanks Roger,

#################### snip ##############################################
Please try debug(subset.polylist) and re-run to see where this is 
happening, most likely in:

    area <- sapply(res, function(x) attr(x, "area"))
    if (any(sapply(area, is.null))) 
        pO <- order(subset.default(attr(x, "plotOrder"), subset))
    else pO <- order(area, decreasing = TRUE)

It looks as though any(sapply(area, is.null)) is TRUE as well as the 
return value from attr(x, "plotOrder") is not a vector. This suggests that 
your "polylist" object is pretty old (?) and/or that the maptools package 
is not very fresh(?) - which version of maptools are you using, and when 
was the "polylist" object generated? What are the components of 
attributes(<"polylist">)? Is there an area attribute and/or a plotOrder 
attribute? 
######################## END #############################################


Yes the error occurs in the area statement:

debug: if (any(sapply(area, is.null))) pO <- order(subset.default(attr(x, 
    "plotOrder"), subset)) else pO <- order(area, decreasing = TRUE) Browse[1]> 
Error in order(na.last, decreasing, ...) : 
        argument 1 is not a vector


My maptools package is version 0.4-13. I am running R 2.1.0 under Mandrake 10.1 on a Pentium 4 and my polylist is from a week ago (ie create with this package).


Attributes of the polylist are:
List of 3
 $ region.id: chr [1:4638] "1" "2" "3" "4" ...
 $ class    : chr "polylist"
 $ maplim   :List of 2
  ..$ x: num [1:2] 113 153
  ..$ y: num [1:2] -30.00  -9.14


################## snip  ########################################
> 
> The shapefile I am using is messy and has multiple polygons in one
> region (ie islands off the coast assocaited with coastal polygons). Is 
> there a way of matching region.id in the Map2poly object with the 
> isolated/non-isolated polygons from the neigborlist so I can 
> delete/retain polygons?

PS. I don't understand. A shape can have multiple polygons, and in 
maptools, you can only subset shapes easily, removing one or more 
sub-polygons from a shape can be done, but you have to manipulate the 
object directly. This is one of the reasons why the sp package has been 
developed, and it is where development will continue.
#################### end ####################################

I try to be clearer. Basically, I want to label all polygons that have no neighbor and than delete them from the Map2poly object. Subset is one way of doing that, but it doesn't work for me using card. A work around could be to identify all region.id with no neighbors in the nb object and match these to the region.id in the Map2poly object. How to do this so I cannot figure out...

Thanks for any help
Herry

--------------------------------------------
Alexander Herr - Herry
Northern Futures
Davies Laboratory, CSIRO
PMB, Aitkenvale, QLD 4814
Phone (07) 4753 8510
Fax   (07) 4753 8650
Home: http://herry.ausbats.org.au
Webadmin ABS: http://ausbats.org.au
Sustainable Ecosystems: http://www.cse.csiro.au/
--------------------------------------------
 




More information about the R-sig-Geo mailing list