如何在循环中加载多个点的多个点文件并将其转换为CSV文件?
我想阅读并将多个Shapefile转换为CSV。该链接包含Shapefile的样本。以下是我正在尝试的代码。
library(raster)
setwd("D:/share_1/PAPER_regimes/22_06_22/hp/firepoint_12_veg")
all.files <- list.files(pattern="\\.shp$")
out.files <- gsub("\\.shp$", ".csv")
crs <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
for(i in 1:length(all.files)) {
d <- readOGR(all.files[i], stringsAsFactors = FALSE)
sp <- SpatialPointsDataFrame(coords = d[c("Longitude", "Latitude")], d, proj4string = crs)
utm <- spTransform(sp, CRS("+proj=utm +zone=16 +datum=WGS84"))
shapefile(utm, out.files[i])
}
I want to read and convert multiple shapefile into csv. The link contain sample of shapefile. Following is the code I was trying.
library(raster)
setwd("D:/share_1/PAPER_regimes/22_06_22/hp/firepoint_12_veg")
all.files <- list.files(pattern="\\.shpquot;)
out.files <- gsub("\\.shpquot;, ".csv")
crs <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
for(i in 1:length(all.files)) {
d <- readOGR(all.files[i], stringsAsFactors = FALSE)
sp <- SpatialPointsDataFrame(coords = d[c("Longitude", "Latitude")], d, proj4string = crs)
utm <- spTransform(sp, CRS("+proj=utm +zone=16 +datum=WGS84"))
shapefile(utm, out.files[i])
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以这样做,
我不知道为什么您去了属性中的LON/LAT,但是如果您需要的话,您可以做:
You can do that like this
I do not know why you went to the lon/lat in the attributes, but if that is what you need you can do: