You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry if this doesnt fit here, I guess its more a question than an issue.
I would like to read a STAC ItemCollection(a GeoJSON FeatureCollection that is augmented with foreign members) and save individual features to disk as seperate geojson.
What would be an appropriate way to save the files without the square brackets? Do I somehow need do convert the features to sf first and then use write_geojson_file()?
The text was updated successfully, but these errors were encountered:
While I still didnt found a nice solution the following at least does what it should
# Read the JSON file as a text stringjson_content<- readLines(here::here(paste0(feature$id, ".json"), warn=FALSE)
# Collapse the lines into a single stringjson_string<- paste(json_content, collapse="\n")
# Remove the outer square brackets and any leading/trailing whitespace or newlinesjson_string<- sub("^\\s*\\[\\s*", "", json_string)
json_string<- sub("\\s*\\]\\s*$", "", json_string)
# Write the modified JSON string to a new file
writeLines(json_string, here::here(paste0(feature$id, ".json"))
Sorry if this doesnt fit here, I guess its more a question than an issue.
I would like to read a STAC ItemCollection(a GeoJSON FeatureCollection that is augmented with foreign members) and save individual features to disk as seperate geojson.
The output is as expected, except that it is wrapped as array in
[ ]
. I guess this is due to the json spec.as is:
as expected:
What would be an appropriate way to save the files without the square brackets? Do I somehow need do convert the features to sf first and then use
write_geojson_file()
?The text was updated successfully, but these errors were encountered: