write.table在ArcGIS中对csv文件进行加扰

时间:2014-02-17 10:17:19

标签: r csv arcgis write.table

我已将此question发布到GIS论坛,但我在这里问,因为这个硬币有两面 - 我相信ArcGIS人会告诉我问R人 - 所以我在这里问R人。我试图从R脚本生成的输出文件中引入并创建一个shape文件。所以,我使用:

编写我的csv文件
write.table(PointData, paste(RootOutputFileName,"SSF_MvtMetrics_",Date,".csv", sep = ""), row.names = F, sep = ",")

PointData只是一个数据框。

   structure(list(ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("3311_1", 
"3313_1", "3313_2", "3344_1", "3344_2", "3344_3", "3348_1", "3349_1", 
"3350_1", "3352_1", "3352_2", "3352_3", "3353_1", "3353_2", "3353_3", 
"3355_1", "3355_2", "3602_1", "7615_1", "7616_1", "7616_2", "7617_1", 
"7617_2", "7617_3", "7618_1", "7618_2", "7618_3", "7619_1", "7619_2"
), class = "factor"), Date_Time = structure(c(1286529600, 1286529600, 
1286529600, 1286529600, 1286529600, 1286529600), class = c("POSIXct", 
"POSIXt"), tzone = "GMT"), moose = structure(c(7L, 7L, 7L, 7L, 
7L, 7L), .Label = c("F01001", "F070014a", "F07002", "F07005", 
"F07006", "F07010", "F07011", "F07020", "F07021", "F10004", "F10008", 
"F10009", "F98015", "M07012a", "M10011"), class = "factor"), 
    trial = c(1L, 1L, 1L, 1L, 1L, 1L), x = c(1476079, 1475943.59345214, 
    1476063.09369225, 1476103.7686023, 1476191.98817498, 1475969.09165391
    ), y = c(6620355, 6620153.61044344, 6620319.54350105, 6620364.30580689, 
    6620189.01655503, 6620438.97062545), label = structure(c(2L, 
    2L, 2L, 2L, 2L, 2L), .Label = c("after", "before", "dog", 
    "End before", "End Before", "end dog", "End dog", "no dog", 
    "resettles", "Start after", "start dog"), class = "factor"), 
    label.1 = structure(c(2L, 2L, 2L, 2L, 2L, 2L), .Label = c("after", 
    "before", "dog", "no dog", "resettles"), class = "factor"), 
    dog = structure(c(2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Ida", 
    "Ludde", "Tanja"), class = "factor"), Reproduction = structure(c(2L, 
    2L, 2L, 2L, 2L, 2L), .Label = c("Calf", "No Calf"), class = "factor"), 
    Position = c("End", "End", "End", "End", "End", "End"), EvalPt = c(1, 
    1, 1, 1, 1, 1), DistX = c(-13, -148.406547861864, -28.9063077468417, 
    11.7686022959398, 99.9881749765198, -122.908346089521), DistY = c(26, 
    -175.389556564022, -9.45649895283019, 35.3058068878195, -139.983444967128, 
    109.970625448519), Dist = c(29.0688837074973, 229.752040252094, 
    30.4138126514911, 37.2155881318568, 172.026160801199, 164.924225024706
    ), Heading = c(5.81953769817878, 3.8438495850988, 4.39621994880961, 
    0.321750554396642, 2.52134316760697, 5.44228863853642), TimeDif = c(0.166666666666667, 
    0.166666666666667, 0.166666666666667, 0.166666666666667, 
    0.166666666666667, 0.166666666666667), Velocity = c(174.413302244984, 
    1378.51224151257, 182.482875908947, 223.293528791141, 1032.15696480719, 
    989.545350148239), Angle = c(2.67794504458899, 0.702256931509007, 
    1.25462729521981, 3.46334320798643, 5.66293582119676, 2.30069598494663
    ), LocType = c("Obs", "rand", "rand", "rand", "rand", "rand"
    ), LocNum = c(1, 1, 1, 1, 1, 1), RandId = 0:5), .Names = c("ID", 
"Date_Time", "moose", "trial", "x", "y", "label", "label.1", 
"dog", "Reproduction", "Position", "EvalPt", "DistX", "DistY", 
"Dist", "Heading", "TimeDif", "Velocity", "Angle", "LocType", 
"LocNum", "RandId"), row.names = c("3", "2", "31", "4", "5", 
"6"), class = "data.frame")

当我将其带入ArcGIS并打开表格时,事情会被described in my other post打乱。

我假设write.table命令正在发生一些事情以及我如何设置sep = ","但我真的不知道。我以前从未遇到问题,只需使用write.csv。我不明白为什么/如何使用或不使用随后由ArcGIS读取的格式化代码来写入对象。

在R中,要生成此csv文件的数据 - 我已设置as.POSIXct(strptime(loc$Date_Time,"%Y-%m-%d %H:%M",tz="GMT"),tz="GMT")

我不知道从哪里获取moose.x或moose.y的值,或者ID_X或ID_Y,为什么它会更改date_time列中的时间或为什么x中的某些值列以数字形式出现,但其他列出现为0.

我没有试图过帖,并且如果我与另一个问题的链接形式不好而道歉 - 我只是不想重新输入所有内容,而是询问是否有人之前遇到过这个问题,如果有什么我可以添加到我的代码,以保持结构格式在R之外的其他程序中工作。

0 个答案:

没有答案