Kann mir bitte jemand helfen, herauszufinden, wie Sie Standorte, die in lat/long (Dezimal Grad) zu UTM NAD83 Zone 13 mit Programm R konvertieren?Lat/Long zu UTM
Ich habe dies bisher geschrieben:
install.packages("sp")
install.packages("rgdal")
library(sp)
library(rgdal)
setwd("I:/R/latlong_utm/")
locs=read.table("Location_Database.txt", head=TRUE)
locs=subset(locs, select=c(number, LongWGS84, LatWGS84))
head(locs)
LongLatToUTM <- function(x, y, ID, zone){
xy <- data.frame(ID=ID, X=x, Y=y)
coordinates(xy) <- c("X", "Y")
proj4string(xy) <- CRS("+ proj=longlat + datum=WGS84")
res <- spTransform(xy, CRS(paste("+ proj=utm + zone=", zone, " ellps=WGS84",
sep='')))
return(as.data.frame(res))
}
x=LongLatToUTM(locs$LongWGS84, locs$LatWGS84, ID=locs$number, 13)
x$number = x$ID
locs=merge(locs, x, by="number")
head(locs)
plot(locs$X, locs$Y)
Ich habe auch versucht, einen anderen Code:
require("PBSmapping") || install.packages("PBSmapping", dependencies=TRUE)
&& require("PBSmapping")
setwd("I:/R/latlong_utm/")
locs <- read.csv("Location_Database.csv", head=TRUE)
Location_Database.csv <- commandArgs(TRUE)[1]
coord <- read.csv("Location_Database.csv", head=TRUE)
attr(coord, "projection") <- "LL"
attr(coord, "zone") <- 13
coord.utm <- convUL(coord)
output <- sub(pattern = "Location_Database.csv", replacement = ".utm.csv",
x = "Location_Database.csv")
write.csv(coord.utm, file =
"C:/Users/utmoutput.csv",
row.names = FALSE)
tail(meter.data)
)
von Weder diese Arbeit. Denken Sie daran, dies wäre für Stapelpositionen (z. B. 75k + Standorte). Jede Hilfe wird sehr geschätzt!
Bitte geben Sie einige Beispieldaten für ein reproduzierbares Beispiel. Einige Informationen darüber, wie jedes dieser Codebeispiele fehlschlägt, wären hilfreich (Fehlermeldung, unerwünschte Ausgabe usw.). –