Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read Mapinfo files in R

Tags:

r

mapinfo

The French national institute (Insee) provides geographical data in the MapInfo format (two files .mid and .mif and one dbf file). How can I read those files in R ?

Here is one example.

like image 310
PAC Avatar asked Nov 20 '13 16:11

PAC


1 Answers

There is an OGR-Driver for MapInfo files (package rgdal):

R> library("rgdal")
R> ogrDrivers()[28, ]
           name write
28 MapInfo File  TRUE

But there is a problem with your files/geometry, readOGR gives the error message:

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

However, I was able to read the files with GRASS GIS, which can be scripted from R (package spgrass6):

v.in.ogr dsn=R02_rfl09_UTM20N1000.mid output=R02_rfl09_UTM20N1000 snap=1e-08

GRASS screenshot

like image 109
rcs Avatar answered Oct 30 '22 15:10

rcs