Before this please refer to the post "Export list of Feature datasets and classes from a geodatabase to CSV"
Here you will observe that each line has 2 characters. One is " " and second one is "\". We need to bring this file into this format: Geodatabase Name, Feature Dataset Name, Feature Class Name.
To process an above mentioned text file, this R code has been prepared in R Studio.
# read input file
input_file <- "I:/GDBs/GDB2csv.txt"
file_con <- file(input_file, "r")
input_data <- readLines(file_con)
close(file_con)
# read each line and reformat
output_data <- NULL
for (eachLine in 1:length(input_data)) {
out_str1 <- unlist(strsplit(input_data[eachLine], "\\\\"))
if (length(out_str1) == 3) {
out_str2 <- unlist(strsplit(out_str1[3], ".gdb "))
output_tmp <- data.frame(Geodatabase_name = out_str2[1],
Feature_dataset_name = " ",
Feature_Class_name = out_str2[2],
stringsAsFactors = FALSE)
} else if (length(out_str1 == 4)) {
out_str2 <- unlist(strsplit(out_str1[4], " "))
output_tmp <- data.frame(Geodatabase_name = out_str1[3],
Feature_dataset_name = out_str2[1],
Feature_Class_name = out_str2[2],
stringsAsFactors = FALSE)
} else {
message("check input!")
}
# update output
output_data <- rbind(output_data, output_tmp)
}
# write output
write.table(output_data, file = "I:/GDBs/GDB2csv_Output.txt", sep = ",",
quote = FALSE, row.names = FALSE)
The output text file is having 3 columns: Geodatabase Name, Feature Dataset Name, Feature Class Name.
The purpose of this exercise is to maintain the multiple geodatabases accessed by users from several locations without an ArcSDE server. It helps an user to determine which feature dataset or feature classes has been added to particular geodatabase from other users. The limitations of this program is that an user will not be able to check the last updated version of any feature classes. Infact, it won't be necessary because all the users from multiple location will going to access same geodatabase on a server.
No comments:
Post a Comment