法国国家研究所(Insee)以MapInfo格式提供地理数据( .mid和.mif两个文件和一个dbf文件)。我怎么读R里的那些文件?
这里有一个示例。
发布于 2013-11-20 18:54:47
MapInfo文件有一个OGR驱动程序(包rgdal):
R> library("rgdal")
R> ogrDrivers()[28, ]
name write
28 MapInfo File TRUE但是您的文件/几何图形有问题,readOGR给出了错误消息:
R> ogrListLayers("R02_rfl09_UTM20N1000.mid")
[1] "R02_rfl09_UTM20N1000"
R> readOGR("R02_rfl09_UTM20N1000.mid", layer="R02_rfl09_UTM20N1000")
OGR data source with driver: MapInfo File
Source: "R02_rfl09_UTM20N1000.mid", layer: "R02_rfl09_UTM20N1000"
with 967 features and 4 fields
Feature type: wkbPolygon with 2 dimensions
Error in stopifnot(is.list(srl)) : ring not closed但是,我能够用GRASS GIS读取文件,这些文件可以从R (package spgrass6)中编写脚本:
v.in.ogr dsn=R02_rfl09_UTM20N1000.mid output=R02_rfl09_UTM20N1000 snap=1e-08

发布于 2013-11-20 17:22:10
这有点难说,因为您的pdf只定义了.mid结构。
这取决于您想要对日期做什么,但是查看它,.mid文件有每个区域的SW坐标,并且检查.mif文件,每个区域是1000m2,所以您可以只计算这些区域(对于这个数据样本),而不是加载它们。
因此,这里有一种加载它的方法,但是它将取决于您想要对数据做什么
首先将.csv文件复制到您的工作目录中,然后
coords<-read.csv(file="R02_rfl09_UTM20N1000.mid", header=FALSE)
colnames(coords)<-c("SW.E","SW.N","ind","indXYNE1")
# add the co-ords for the area
coords$SE.N=coords$SW.N
coords$SE.E=coords$SW.E+1000
coords$NW.N=coords$SW.N+1000
coords$NW.E=coords$SW.E
coords$NE.N=coords$SW.N+1000
coords$NE.E=coords$SW.E+1000
head(coords)这将给你:
SW.E SW.N ind indXYNE1 SE.N SE.E NW.N NW.E NE.N NE.E
1 690000 1636000 241 6 1636000 691000 1637000 690000 1637000 691000
2 690000 1637000 414 3 1637000 691000 1638000 690000 1638000 691000
3 690000 1638000 240 6 1638000 691000 1639000 690000 1639000 691000
4 690000 1640000 8 0 1640000 691000 1641000 690000 1641000 691000
5 691000 1634000 142 0 1634000 692000 1635000 691000 1635000 692000
6 691000 1635000 216 5 1635000 692000 1636000 691000 1636000 692000
....哪个是每个区域的四个边界点,再加上ind和indXYNE1,我猜这就是你想要的?然后,您可以使用SW点(或新派生键)作为每个区域的引用来转换数据。
希望这能帮上忙!这在一定程度上取决于您想对数据做什么。
https://stackoverflow.com/questions/20101083
复制相似问题