如何转换 utm32 中的经度/纬度坐标以使用 ggplot2 绘图?
How to convert Longitude / Latitude coordinate in utm32 for plotting with ggplot2?
我用 utm32-shapefile 制作了等值线图,现在,我想用来自另一个数据框的数据添加第二层。第二个数据框只有 Lon/Lat-information。
我想将 Lon/Lat 转换为 utm32 坐标,因此我可以将它们与 ggplot2 一起用作另一个收敛层。
数据框如下所示:
GPS_Lat GPS_Lon Index
51,133 14,683 12.75
首先,我使用 gsub
将“,”重新编码为“.”。然后我将变量转换为数字。
#Then I tried to define the variables as Lon/Lat-Coordinates
cord.dec<-SpatialPointsDataFrame(cbind(plot.eeg$GPS_Lon,plot.eeg$GPS_Lat),data=plot.eeg,proj4string=CRS("+proj=longlat"))
#Then i tried to convert them to utm32
cord.UTM<-spTransform(cord.dec,CRS("+init=epsg:4326"))
没用。我刚拿到一份 Lat/Lon-variables.
我没有找到有关如何执行此操作的良好文档。也许其他人可以帮助我?
您的 CRS 字符串不正确:EPSG:4326 是 WGS84 longlat(参见 here);请尝试 EPSG:32632。
我用 utm32-shapefile 制作了等值线图,现在,我想用来自另一个数据框的数据添加第二层。第二个数据框只有 Lon/Lat-information。 我想将 Lon/Lat 转换为 utm32 坐标,因此我可以将它们与 ggplot2 一起用作另一个收敛层。
数据框如下所示:
GPS_Lat GPS_Lon Index
51,133 14,683 12.75
首先,我使用 gsub
将“,”重新编码为“.”。然后我将变量转换为数字。
#Then I tried to define the variables as Lon/Lat-Coordinates
cord.dec<-SpatialPointsDataFrame(cbind(plot.eeg$GPS_Lon,plot.eeg$GPS_Lat),data=plot.eeg,proj4string=CRS("+proj=longlat"))
#Then i tried to convert them to utm32
cord.UTM<-spTransform(cord.dec,CRS("+init=epsg:4326"))
没用。我刚拿到一份 Lat/Lon-variables.
我没有找到有关如何执行此操作的良好文档。也许其他人可以帮助我?
您的 CRS 字符串不正确:EPSG:4326 是 WGS84 longlat(参见 here);请尝试 EPSG:32632。