Dear All



I am using the following command to add column to shape file

> v@data$class3 <- 1:nrow(v@data)  ##where v is the object of polygon shape
file

                                                          ##class3 is the
column to be added



Now, I want to add column in loop as

> v@data$classi <- 1:nrow(v@data) ## i = 1,2,3,4,….. Supplied by loop



 i.e, I want to add column class1, class2, class3….. so on using loop.



My next problem is to extract the name of shape file from selected path.

> shapePath <- choose.files(caption = "Select grid file", filters =
Filters[c("All"),])

 > shapePath

[1] "H:\\file\\gridfile.shp"



I want to extract ‘gridfile’ string (without .shp) so that it could directly
supplied in place of layerFileName in the command written below

> v <- readOGR(shapePath, layer = “layerFileName”)



Please help to resolve these two issues



With regards

Rahul Raj

Indian Institute of Remote Sensing, India

	[[alternative HTML version deleted]]

