[R-sig-Geo] rgdal - read geoJSON with readOGR

Emmanuel Blondel emmanuel.blondel1 at gmail.com
Wed May 11 09:27:26 CEST 2011


Dear all,

I tried to use the readOGR from package rgdal to read a geoJSON file 
from a Geoserver WFS.
I can get a SpatialPointDataFrame with this code:

url<-"http://localhost:8080/geoserver/wfs?service=WFS&version=1.0.0&request=GetFeature&outputFormat=json&typeName=mylayer"
ogrInfo(dsn=url,layer = 'OGRGeoJSON')
layer<-readOGR(dsn=url,layer = 'OGRGeoJSON')

but my problem is regarding the attributes. I have a numeric (real) 
field that is converted to integer. To see why readOGR had this 
behaviour, I downloaded my geoJSON file to explore the data: It appears 
that the first value for this attribute is 1, so the field is converted 
in integer with readOGR, and all values between 0 and 1 are set to 0.

Is there any way to force numeric attributes to real type?

I thank you in advance,

Cheers,
Emmanuel



More information about the R-sig-Geo mailing list