[R-sig-Geo] numeric fields imported as factors by readOGR()

Roger Bivand Roger.Bivand at nhh.no
Fri Dec 5 18:36:14 CET 2008


On Fri, 5 Dec 2008, James Nylen wrote:

> This happens to me as well.  I just create a new column in the shapefile
> object's data, like:
>
> shp$AreaNum = as.numeric(as.vector(shp$AREA))
>
> If all you want to know is "why is it coded this way" then I have no idea,
> sorry.

You could look at ogrInfo() for the same dsn= and layer= before you 
import. In principle, if the driver reports "Integer", "Real", or 
"String", this should be respected, so I'd be interested in seeing a case.

Roger

>
> -James
>
> On Fri, Dec 5, 2008 at 10:29 AM, Agustin Lobo <aloboaleu at gmail.com> wrote:
>
>> I often get some numeric fields (i.e, AREA in this case) imported
>> as factors by readOGR() from shp files. WHy could it be?
>> I've reviewed the field in the dbf file and do not
>> see any non-numeric value.
>>
>> Thanks
>> Agus
>> --
>> Dr. Agustin Lobo
>> Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
>> LLuis Sole Sabaris s/n
>> 08028 Barcelona
>> Spain
>> Tel. 34 934095410
>> Fax. 34 934110012
>> email: Agustin.Lobo at ija.csic.es
>> http://www.ija.csic.es/gt/obster
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list