[gdal-dev] ogr geojson columns that start with null converted to string

Raluca nicolara at ethz.ch
Wed May 18 05:06:08 PDT 2016


Hi,

At the moment the geojson reader automatically converts an attribute where
the first feature is null to string. Is it possible to check values also
from the next features and based on that to set the type of the column?

For example for the following geojson the type of int_prop2 and dbl_prop1
will be string:

{
    "features": [
        {
            "geometry": {
                "coordinates": [ 1.0, 0.0 ],
                "type": "Point"
            },
            "properties": {
                "name": "point2",
                "int_prop1": 2,
                "int_prop2": null,
                "dbl_prop1": 2.1,
                "dbl_prop2": null
            },
            "type": "Feature"
        },
        {
            "geometry": {
                "coordinates": [ 0.0, 0.0 ],
                "type": "Point"
            },
            "properties": {
                "name": "point1",
                "int_prop1": 1,
                "int_prop2": 1,
                "dbl_prop1": 1.1,
                "dbl_prop2": 1.1
            },
            "type": "Feature"
        }
    ],
    "type": "FeatureCollection"
}

Result in the console when using ogrinfo with gdal version 2.1.0, released
2016/04/25: 

name: String (0.0)
int_prop1: Integer (0.0)
int_prop2: String (0.0)
dbl_prop1: Real (0.0)
dbl_prop2: String (0.0)
OGRFeature(OGRGeoJSON):0
  name (String) = point2
  int_prop1 (Integer) = 2
  int_prop2 (String) = (null)
  dbl_prop1 (Real) = 2.1
  dbl_prop2 (String) = (null)
  POINT (1 0)

OGRFeature(OGRGeoJSON):1
  name (String) = point1
  int_prop1 (Integer) = 1
  int_prop2 (String) = 1
  dbl_prop1 (Real) = 1.1
  dbl_prop2 (String) = 1.1000
  POINT (0 0)



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/ogr-geojson-columns-that-start-with-null-converted-to-string-tp5266960.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list