mapme-initiative/mapme.biodiversity

write_portfolio_fails when an indicator has only NULL values

Closed this issue · 0 comments

Having an object with an indicator column with only NULL values like this:

Simple feature collection with 3 features and 3 fields
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: -80.10651 ymin: 19.66116 xmax: -80.10651 ymax: 19.66116
Geodetic CRS:  WGS 84
# A tibble: 3 × 4
  .mapmeid humanfootprint     key_biodiversity_areas                                                                                         geom
*    <int> <list>             <list>                                                                                                <POLYGON [°]>
1        1 <tibble [126 × 4]> <NULL>                 ((-80.10651 19.66116, -80.10651 19.66116, -80.10651 19.66116, -80.10651 19.66116, -80.106...
2        2 <tibble [126 × 4]> <NULL>                 ((-80.10651 19.66116, -80.10651 19.66116, -80.10651 19.66116, -80.10651 19.66116, -80.106...
3        3 <tibble [126 × 4]> <NULL>                 ((-80.10651 19.66116, -80.10651 19.66116, -80.10651 19.66116, -80.10651 19.66116, -80.106...

and trying to serialize it with write_portfolio() leads to the following error message:

Error in tmp[, c("assetid", "indicator", "datetime", "variable", "unit",  : 
  Can't subset columns that don't exist.Columns `datetime`, `variable`, `unit`, and `value` don't exist.