如何读取R中的Mapinfo文件

PAC*_*PAC 6 r mapinfo

法国国家研究所(Insee)以MapInfo格式提供地理数据(两个文件.mid和.mif以及一个dbf文件).如何在R中读取这些文件?

这是一个例子.

rcs*_*rcs 8

MapInfo文件(包rgdal)有一个OGR驱动程序:

R> library("rgdal")
R> ogrDrivers()[28, ]
           name write
28 MapInfo File  TRUE
Run Code Online (Sandbox Code Playgroud)

但是你的文件/几何有问题,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
Run Code Online (Sandbox Code Playgroud)

但是,我能够使用GRASS GIS读取文件,可以从R(包spgrass6)编写脚本:

v.in.ogr dsn=R02_rfl09_UTM20N1000.mid output=R02_rfl09_UTM20N1000 snap=1e-08
Run Code Online (Sandbox Code Playgroud)

GRASS截图


Tro*_*roy 5

这有点难以说,因为你的pdf只定义了.mid结构.

这取决于你想对日期做什么,但看看它,.mid文件有每个区域的SW合作,并检查.mif文件,每个区域是1000平方米,所以你可以只计算面积(这个数据样本)而不是加载它们.

所以这是加载它的一种方法,但它取决于你想要对数据做什么

首先将.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)
Run Code Online (Sandbox Code Playgroud)

这会给你:

    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
....
Run Code Online (Sandbox Code Playgroud)

这是每个区域的四个边界点,加上ind和indXYNE1,我想你正在寻找什么?然后,您可以使用SW点(或新的派生键)转换数据作为每个区域的参考.

希望有所帮助!取决于您想要对数据做什么.