I am trying to create several maps and save as PNG files in a loop from 
a sppolygon  object. This object contains   464 records  and 108 
fields.  I  want to use column no. from 7 to 108 (see below) to create 
100 maps and want to save save as png  files. I tried following code but 
it  showed  error.  I used this code successfully for sppoint data 
frame. May be I am  missing something here.
Thanks
Zia

 >for (i in 1:ns){
+ png(filename = paste("sim",i,".png",sep=""), width=400, height=500, 
units="px",
+ pointsize=12, bg="transparent", res=NA)
+ print(spplot(sim[i], main = list(label=paste("Realization",i),cex=1.5),
+ par.settings=list(axis.line=list(col=NA)),at=at,
+ col.regions=rgb.palette (21),
+ colorkey=list(space="right",width=2,at=1:22,labels=list(cex=1.2,at=1:22,
+ labels=c("","< 
10","","","","40","","","","80","","","","120","","","","160","","", "> 
200", "")))
+ ))
+ dev.off()
+ }
Error in print(spplot(sim[i], main = list(label = paste("Realization",  :
   error in evaluating the argument 'x' in selecting a method for 
function 'print': Error in .local(obj, ...) :
   length of col.regions should match number of factor levels
 >

 > summary(sim)
Object of class SpatialPolygonsDataFrame
Coordinates:
         min       max
x 2542038.2 3016189.2
y  322929.6  985549.3
Is projected: TRUE
proj4string : [+init=epsg:3106]
Data attributes:


 > names(sim)
   [1] "ID"         "DIV_NAME"   "THANA_ID"   "x-cent"          "y-cent"
   [6] "DIST_NAME"  "THANA_NAME" "sim1"       "sim2"       "sim3"
  [11] "sim4"       "sim5"       "sim6"       "sim7"       "sim8"
  [16] "sim9"       "sim10"      "sim11"      "sim12"      "sim13"
  [21] "sim14"      "sim15"      "sim16"      "sim17"      "sim18"
  [26] "sim19"      "sim20"      "sim21"      "sim22"      "sim23"
  [31] "sim24"      "sim25"      "sim26"      "sim27"      "sim28"
  [36] "sim29"      "sim30"      "sim31"      "sim32"      "sim33"
  [41] "sim34"      "sim35"      "sim36"      "sim37"      "sim38"
  [46] "sim39"      "sim40"      "sim41"      "sim42"      "sim43"
  [51] "sim44"      "sim45"      "sim46"      "sim47"      "sim48"
  [56] "sim49"      "sim50"      "sim51"      "sim52"      "sim53"
  [61] "sim54"      "sim55"      "sim56"      "sim57"      "sim58"
  [66] "sim59"      "sim60"      "sim61"      "sim62"      "sim63"
  [71] "sim64"      "sim65"      "sim66"      "sim67"      "sim68"
  [76] "sim69"      "sim70"      "sim71"      "sim72"      "sim73"
  [81] "sim74"      "sim75"      "sim76"      "sim77"      "sim78"
  [86] "sim79"      "sim80"      "sim81"      "sim82"      "sim83"
  [91] "sim84"      "sim85"      "sim86"      "sim87"      "sim88"
  [96] "sim89"      "sim90"      "sim91"      "sim92"      "sim93"
[101] "sim94"      "sim95"      "sim96"      "sim97"      "sim98"
[106] "sim99"      "sim100"

-- 
---------------------
Zia Ahmed, PhD
Research Associate
Department of Crop and Soil Sciences
1002 Bradfield Hall, Cornell University
Ithaca, NY 14853-4203
t. 607.255.9387
f. 607.255.3207
email zua3@cornell.edu



	[[alternative HTML version deleted]]

