Hi,
 I have several errors in my codes when handling with the spatial data. I
did not find some example data to show this and attachment wasnot allowed
here, so i hope that some suggested correction or ideas could be given.
Sorry for this.
 The following are the codes.
######## CODES1 ##########
library(maptools); library(aspace)

poly<-readShapePoly("a.shp")
num<-c(0,1)

#hope to get poly_0 and poly_1
for(i in num) {
 poly_num<-poly[poly$LABEL_FLAG==num,]
 writeSpatialShape(poly_num,fn="c:/poly_num")
}

Warning messages:
1: In poly$LABEL_FLAG == num :
  longer object length is not a multiple of shorter object length
2: In poly$LABEL_FLAG == num :
  longer object length is not a multiple of shorter object length

Question1: If i didnot use the "for loops", it runs without error. What is
the problem here?
Question2: I noticed that write.polylistShape() is different from
writeSpatialShape(). The former needs a polylist object according to the
help. How can i convert the shapepolygon poly_num to the polylist object?

######## CODES2 ##########
point0<-readShapePoints("po2")
num<-c(2,4)

# hope to get r_sdd_2 and r_sdd_4
for(i in num) {
 point_i<-point0[point0$new==i,]
 r_sdd_i<-calc_sdd(id = 1, filename =
"c:/SDD_Output.txt",destmat=coordinates(point_i))
}

Warning messages:
1: In destmat[, 1] * weights :
  longer object length is not a multiple of shorter object length
2: In destmat[, 2] * weights :
  longer object length is not a multiple of shorter object length
> r_sdd_2
Error: object 'r_sdd_2' not found
> r_sdd_4
Error: object 'r_sdd_4' not found

Question3:  Here it will run correctly if i donot use the "for loops". What
is the problem?

 Thanks a lot. Actually, there maybe better methods to do the above task.

	[[alternative HTML version deleted]]

