I'm classifying vegetation in eCognition. From ArcMap I already have a shapefile with training polygons that I would like to use for this but so far I was only able to insert this as a thematic layer and use for the segmentation process. Also, is eCognition able to handle the attribute table information where the classes for the polygons are stored or will I have to split the shapefile with all the information into individual shapefiles?
If you want to use training polygons as samples in eCognition you need to add them as a TTA mask (Training and Test Area), also this can be used in Accuracy Assessment process.
A TTA mask is a raster layer with training classes as integers. You also need to create a .csv file with Class name, ID, Red, Green and Blue (0-255 value for coloring each training class).
I've been using an R code for this purpose, it could help you:
require(rgdal) require(raster) # Load training shapefile shp <- readOGR(dsn="/path/to/folder", layer = "layer_name") r <- setValues(raster("/path/to/sample/layer/used/in/eCognition"), values = NA) Class_Names <- unique(shp@data$Class_name_field) id <- as.numeric(unique(shp@data$Integer_ID_field)) Red <- round(sample(0:255,length(Class_Names),replace = T)) Green <- round(sample(0:255,length(Class_Names),replace = T)) Blue <- round(sample(0:255,length(Class_Names),replace = T)) TTAconversor <- data.frame(id,Red,Green,Blue,Class_Names) write.table(TTAconversor,file = "/path/to/TTAMask.csv",quote = F,row.names=F,sep = ";") # sep = ',' if this csv doesn't work TTAr <- rasterize(shp,r,field=as.numeric(shp@data$Integer_ID_field),background=255) writeRaster(TTAr,filename ="/path/to/TTAmask",format = "GTiff", overwrite= T, datatype="INT1U") #same name than .csv file
Finally, add TTA mask by selecting Classification / Samples / Load TTA Mask and a dialog box will appear asking if you want to use this mask as training samples.