[R-sig-Geo] Possible rgdal enhancement request related to null attributes
Roger Bivand
Roger.Bivand at nhh.no
Mon Jul 10 18:04:30 CEST 2017
Hi Alex,
GDAL 2.2 is supported in rgdal and in sf - has been for some time. If GDAL
>= 2.2:
https://r-forge.r-project.org/scm/viewvc.php/pkg/src/OGR_write.cpp?root=rgdal&r1=650&r2=660
and
https://r-forge.r-project.org/scm/viewvc.php/pkg/src/ogrsource.cpp?root=rgdal&r1=650&r2=660
This is general, not just GeoJSON, see
https://trac.osgeo.org/gdal/wiki/rfc67_nullfieldvalues
I don't see a good reason for making the user have to choose - could you
suggest one with a use case reprex?
See also the sf code, which is relevant here.
Roger
On Fri, 7 Jul 2017, Alex M wrote:
> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no
Editor-in-Chief of The R Journal, https://journal.r-project.org/index.html
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
More information about the R-sig-Geo
mailing list