[GRASS-user] Loading JSON data in GRASS

Moritz Lennert mlennert at club.worldonline.be
Wed Oct 22 05:15:51 PDT 2014


On 21/10/14 04:38, Arighna wrote:
> Hi Vaclav,
>
> I have loaded the point in GRASS. But the attributes are not loaded
> successfully. I am posting one sample data. Could you please help me
> finding what is wrong with the data. Or maybe I am going wrong with the
> loading process.

This sample data is not enough. According to the ogr GeoJSON format 
manual [1], "according to the GeoJSON Specification, only the Feature 
object must have a member with name properties. Each and every member of 
properties is translated to OGR object of type of OGRField and added to 
corresponding OGRFeature object."

In other words: attributes have to be members of the member properties 
of the Feature object.

I can get a bit further in importing your attributes by using the 
following at the beginning

{"type": "Feature",
"geometry":
{

     "type": "Point",

     "coordinates": [50.922759,-90.089954]
},

                 "properties":

                 {

                                 "air_temp":{"unit":"F","value":32.0},

[then the rest is identical to JSON code].

However, this imports the attributes as such (example is air_temp):

{ "unit": "F", "value": 32.0 }

If I change the JSON to

                 "properties":

                 {

                                 "air_temp":32.0,

etc

I get the expected attribute values, i.e. air_temp is 32.0 which is 
recognized as double precision in the attribute table.

To check quickly how ogr parses the attributes, you can check on the 
command line with

ogrinfo point.json OGRGeoJSON

Moritz

[1] http://www.gdal.org/drv_geojson.html


More information about the grass-user mailing list