我是R的新手。我正在尝试将X,Y转换为Long,将R转换为R.
我有一段代码可以将X,Y转换为Long,Lat。如何将其应用于数据框并创建两个新列(Long,Lat)?
data = read.csv('./parking_regulation.csv')
library(proj4)
proj4string <- "+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs"
# Source data
xy <- data.frame(x=data['x'], y=data['y'])
xy # But this only convert one row
# Transformed data
pj <- project(xy, proj4string, inverse=TRUE)
latlon <- data.frame(lat=pj$y, lon=pj$x)
# I want to create two new columns from this result lat,long
CSV列
x y
1005740.867110 243957.356623