[R-sig-Geo] Possible rgdal enhancement request related to null attributes

Alex M tech_dev at wildintellect.com
Fri Jul 7 20:17:51 CEST 2017


Roger et al,

I couldn't find a ticket system for rgdal so this seemed the best place
to post.

We just hit a bug (in QGIS [1]) of sorts due to a change in behavior in
GDAL from 2.1.x to 2.2.x in the way null fields are handled. [2]

Short story if you have a column of null values and you save a geojson
those fields are not saved. So the next time you open up the file, you
have less columns than before. It's great for minifying geojson but
terrible for many other use cases.

I'm not 100% sure this will show up in rgdal (2.2 hasn't been pushed to
my Ubuntu yet so I haven't tested), but there's a good chance it will
depending on how R deals with unset vs null. If someone would like to
test, you can get a sample file from [3], readOGR and then writeOGR (to
geojson) and see if the null columns vanish.

The enhancement requested to deal with this, is to provide the user an
option that allows them to decide when a field is unset vs null. Or
maybe just a clarification on how R represents that data and how a user
could set a field as null instead of unset and vice versa.

Even R. pointed out that this can be controlled with the
OGR_F_IsFieldNull() part of the ogr api.

[1] https://issues.qgis.org/issues/16812
[2] https://trac.osgeo.org/gdal/wiki/rfc67_nullfieldvalues
[3] https://github.com/UCDavisLibrary/ava/issues/270

Thanks,
Alex



More information about the R-sig-Geo mailing list