【问题标题】:Converting .csv (.geo column in sf package) to shapefile in r将 .csv(sf 包中的 .geo 列)转换为 r 中的 shapefile
【发布时间】:2020-08-25 17:32:23
【问题描述】:

我已从栅格图层中提取值,现在想将其转换为 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)。

【问题讨论】:

  • 我不明白你为什么不用sf::st_read(file.csv, crs = 4326) 而不是read.csv。能否详细介绍一下?
  • 谢谢。我从 GEE 中的栅格中提取值并将其作为 csv 文件导出到 Google Drive。
  • 它是否可以使用 sf::st_read 工作,因为它看起来更像 (geo)JSON 文件而不是 csv 文件? sf::st_read 适用于 JSON 文件
  • 是的。谢谢你。我解决了
  • 酷!我把这个作为答案,你介意接受吗? (如果需要,请参阅guidelines

标签: r geospatial shapefile sf


【解决方案1】:

看起来该文件是JSONgeoJSON 文件。可以直接使用sf::st_read

sf::st_read("https://raw.githubusercontent.com/tuyenhavan/Rice-Paper/master/LS_2013.csv", crs = 4326)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-27
    • 2020-11-14
    • 2011-08-13
    • 2018-11-22
    • 2018-12-21
    • 2018-08-23
    • 1970-01-01
    • 2016-04-22
    相关资源
    最近更新 更多