Skip to content
Prev 11664 / 29559 Next

rgdal - read geoJSON with readOGR

On Wed, May 11, 2011 at 8:27 AM, Emmanuel Blondel
<emmanuel.blondel1 at gmail.com> wrote:
Some experiments with the command-line ogrinfo tools seem to indicate
that the geoJSON driver in OGR has this behaviour. I can't see this
explicitly in the source code from a brief look, however.

 The JSON spec only has a single 'number' concept (no differentiating
between ints and reals) so I'd argue that the geoJSON driver should
read anything numeric in as 'real'. (RFC 4627).

 If I get five minutes today I'll create some test samples and submit
a bug report to the OGR guys.

 A massively kludgy workaround would be to use readOGR to get the
geometry, and "fromJSON" from the rjson package to get the attributes
(which would need massaging to get into a data frame) - this does
preserve the floating point nature of data even if the first point
doesn't have a decimal point in it! If the geometry is simple enough
(points?) you could do it all with fromJSON fairly easily.

 Final thought: Geoserver WFS should maybe generate geoJSON where real
values always have a decimal point in them (I'm not sure if Geoserver
is creating these from anothe data source or just passing through
already-created files..).

Barry