Skip to content
Prev 6126 / 29559 Next

split SpatialPolygon after unionSpatialPolygons()

I think I got it working although without truly understand why some aspects
seems to be mandatory, such as assigning NA's into the SGDF to get labcon()
working.

  grelha<-readGDAL(paste("A:\\",i,sep=""))
  gr.topo <- slot(grelha, "grid")
#! GridTopology
  
  
  codcores <- SGDF2PCT(grelha)$idx                            #! Convert RGB
into a single code ID for each color
  codcores[codcores==1] <- NA                                 #! Assign NA's
for ID =1
  sgdf.gr<-SpatialGridDataFrame(gr.topo,data.frame(codcores)) #! Rebuild
SGDF with NA's
  #image(sgdf.gr)
  asc.gr = as.asc(as.matrix(sgdf.gr),xll = 0.5, yll = 0.5,)   #! Build
object "asc"
  grelhaID = labcon(asc.gr)                                   #! Split
culsters (regions) with same ID's
  class(grelhaID)                                             #! classe
"asc" 
  #image(grelhaID)
  grelhaID[is.na(grelhaID)] <- 0
  #win.graph()
  #image(grelhaID)
  pixID = asc2spixdf(grelhaID)                                #! Build
SpatialPixelDataFrame from asc object
  class(pixID)
  names(pixID) <- "ID"
  image(pixID)
  
____________
Paulo E. Cardoso
Message-ID: <!&!AAAAAAAAAAAYAAAAAAAAAK2N38q7o51Ejb8q0JfvLrBiggAAEAAAAHms5igSpCBAox6e8g/vKzgBAAAAAA==@netcabo.pt>
In-Reply-To: <alpine.LRH.2.00.0907151853520.31001@reclus.nhh.no>