Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upgeojson_sf with NA numeric values changes to character #79
Comments
|
Thanks. This is odd given the underlying res <- jsonify::from_json( gj )
str( res$features$properties )
# 'data.frame': 2 obs. of 1 variable:
# $ a: num 1 NAThere must be a mis-match between my implementations (I wrote |
|
On branch library(sf)
#> Linking to GEOS 3.8.1, GDAL 2.4.4, PROJ 7.0.0
# remotes::install_github("SymbolixAU/geojsonsf", ref = "issue79")
library(geojsonsf)
gj <- '{"type":"FeatureCollection","features":[
{"type":"Feature","properties":{"a":1.0,"b":true,"c":"hello"},"geometry":{"type":"Point","coordinates":[0.0,0.0]}},
{"type":"Feature","properties":{"a":null,"b":null,"c":null},"geometry":{"type":"Point","coordinates":[1.0,1.0]}}
]}'
sf <- geojson_sf(gj)
str( sf )
# Classes ‘sf’ and 'data.frame': 2 obs. of 4 variables:
# $ a : num 1 NA
# $ c : chr "hello" NA
# $ b : logi TRUE NA
# $ geometry:sfc_POINT of length 2; first list element: 'XY' num 0 0
# - attr(*, "sf_column")= chr "geometry" |
|
Brilliant! All tests pass in rmapshaper now (at least locally) with that fix (nb. I did have to install dev |
|
yeah I just saw that too, so have updated the sfheaders requirement in the DESCRIPTION. |
It seems that when a numeric field in a geojson contains
nullvalues,geojson_sfconverts that field tocharacter:Created on 2020-04-08 by the reprex package (v0.3.0)