setwd('E:/R_test/corrd/')
getwd()
library(readxl)
library(maptools)
library(rgdal)
library(rgeos)
library(sf)
library(sp)
library(ggplot2)
pointread=read_excel('E:/R_test/corrd/loglat.xlsx')
shaperead=st_read('E:/R_test/shape/firstmerge.shp')
shapegeo=st_geometry(shaperead) # 获取几何信息
shapecrs=st_as_text(shapegeo) #将几何信息写出到wkt文本格式
shapecrs=st_crs(shaperead) #获取shaperead空间参考
pointreadcrs=st_set_crs(pointread,'4326') #想设追加4326坐标系。
报错提示:
rror in UseMethod("st_crs<-") :
no applicable method for 'st_crs<-' applied to an object of class "character"
尝试方法:1.提取pointread经纬度两列数据单独转换从dataframe转换到character显示上述报错。
2.尝试查看help(st_set_crs)发现x变量能是numeric,character,sf,sfc。
疑惑:这该怎么解决。pointread内容有三列,是自己随便写了几个国内城市的名称以及经纬度。