fix: pass simplify=FALSE to sf_geojson for geometry-only sf objects#214
Merged
Conversation
…alkerke#212) geojsonsf::sf_geojson() with simplify=TRUE (default) atomizes sf objects that have no non-geometry columns into a vector of individual geometry strings rather than a FeatureCollection. htmlwidgets cannot serialize a length-n json-class vector, causing a serialization error. Passing simplify=FALSE consistently returns a FeatureCollection regardless of whether the sf has property columns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
|
Thank you! This has been a long-needed fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This issue closes #212.
It adds
simplify = FALSEin everygeojsonsf::sf_geojson()call, to ensure that the geometry and properties are always serialized as a FeatureCollection, regardless of whether thesfhas property columns.Using the example that failed in #212: