将 .csv(sf 包中的 .geo 列)转换为 r 中的 shapefile
Converting .csv (.geo column in sf package) to shapefile in r
我已经从栅格图层中提取了值,现在想将其转换为 shapefile。 csv 文件包含不同波段的值和 sf 包中的一列 .geo 。将 csv 文件转换为 R 中的 shapefile 的任何想法。
library(sf)
# Read data file
LS2013<-read.csv("https://raw.githubusercontent.com/tuyenhavan/Rice-Paper/master/LS_2013.csv",header = T)
head(LS2013)
.geo
1 {"type":"Point","coordinates":[106.0283799940066,21.191342664375124]}
2 {"type":"Point","coordinates":[106.02664540369682,21.19108403651402]}
3 {"type":"Point","coordinates":[106.02693524526529,21.191084036514017]}
4 {"type":"Point","coordinates":[106.02722508683375,21.19107957741297]}
5 {"type":"Point","coordinates":[106.02751492840221,21.19107957741297]}
6 {"type":"Point","coordinates":[106.02780031086967,21.19107511831191]}
shapefile 可以在地理坐标系 (4326) 中。
看起来文件是 JSON
或 geoJSON
文件。可以直接使用sf::st_read
:
sf::st_read("https://raw.githubusercontent.com/tuyenhavan/Rice-Paper/master/LS_2013.csv", crs = 4326)
我已经从栅格图层中提取了值,现在想将其转换为 shapefile。 csv 文件包含不同波段的值和 sf 包中的一列 .geo 。将 csv 文件转换为 R 中的 shapefile 的任何想法。
library(sf)
# Read data file
LS2013<-read.csv("https://raw.githubusercontent.com/tuyenhavan/Rice-Paper/master/LS_2013.csv",header = T)
head(LS2013)
.geo
1 {"type":"Point","coordinates":[106.0283799940066,21.191342664375124]}
2 {"type":"Point","coordinates":[106.02664540369682,21.19108403651402]}
3 {"type":"Point","coordinates":[106.02693524526529,21.191084036514017]}
4 {"type":"Point","coordinates":[106.02722508683375,21.19107957741297]}
5 {"type":"Point","coordinates":[106.02751492840221,21.19107957741297]}
6 {"type":"Point","coordinates":[106.02780031086967,21.19107511831191]}
shapefile 可以在地理坐标系 (4326) 中。
看起来文件是 JSON
或 geoJSON
文件。可以直接使用sf::st_read
:
sf::st_read("https://raw.githubusercontent.com/tuyenhavan/Rice-Paper/master/LS_2013.csv", crs = 4326)