Skip to main content
1 of 2
intotecho
  • 922
  • 2
  • 10
  • 24

How to include a GeoJSON FeatureCollection inside another FeatureCollection?

In the GeoJson spec

'An object of type "FeatureCollection" must have a member with the name "features". The value corresponding to "features" is an array. Each element in the array is a feature object as defined above.'

I wish to include a FeatureCollection inside another FeatureCollection.

Appending each feature of the child to the parent's features would mean they can no longer be identified - unless a new property is to each child features before appending.

Would it be legal GeoJSON to add it as a different member?

{ "type": "FeatureCollection",
"features": [ ],
"childfeaturecollection": { "type": "FeatureCollection",
             "features": [ ]
                  }
 }

This is legal JSON, and doesn't seem to break in a GeoJSON parser.

Based on the related question How widely supported are nested FeatureCollections in GeoJSON?, I assume that most systems would just ignore the childfeaturecollection member unless a special handler is implemented.

intotecho
  • 922
  • 2
  • 10
  • 24