[R-sig-Geo] trouble readOGR

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Mar 12 19:38:10 CET 2012


On Mon, Mar 12, 2012 at 5:34 PM, Thomas Hoffmann <tomte.tumetot at gmx.ch> wrote:
> Dear all,
>
> I try to import an Mapinfo file to R and get following error message:
>
>> tmp = readOGR(fi.tab[k],layer=fi[k])
> OGR data source with driver: MapInfo File
> Source: "25545700.TAB", layer: "25545700"
> with 40401 features and 3 fields
> Fehler in make.names(fldnms, unique = TRUE) :
>  ungültige multibyte Zeichenkette 3
>
> however ogrInfo obtains:
>
>> ogrInfo(fi.tab[k], layer=fi[k])
> Source: "25545700.TAB", layer: "25545700"
> Driver: MapInfo File number of rows 40401
> Feature type: wkbPoint with 2 dimensions
> +proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +towgs84=582,105,414,1.04,0.35,-3.08,8.3 +units=m +no_defs
> Number of fields: 3
>     name type length typeName
> 1  Rechts    2      0     Real
> 2    Hoch    2      0     Real
> 3 H\xf6he    2      0     Real

 Have you tried:

 readOGR(fi.tab[k],layer=fi[k],input_field_name_encoding="latin1")

It's that pesky \xf6 in there. R doesn't know what encoding it is:

> readOGR(".","e")
OGR data source with driver: ESRI Shapefile
Source: ".", layer: "e"
with 10 features and 1 fields
Error in make.names(fldnms, unique = TRUE) : invalid multibyte string 1
> readOGR(".","e",input_field_name_encoding="latin1")
OGR data source with driver: ESRI Shapefile
Source: ".", layer: "e"
with 10 features and 1 fields
Feature type: wkbPoint with 2 dimensions
   coordinates       Höhe
1       (1, 1) 0.50774675
[etc]

Barry



More information about the R-sig-Geo mailing list