1

Can a Geojson MultiGeometry contain a Multipoint array of points, or is it necessary to convert them into individual Points before adding to the geometry collection?

This related question suggests it is allowed. Can a GeoJSON GeometryCollection contain another Collection?

intotecho
  • 902
  • 1
  • 9
  • 22

2 Answers2

3

A GeometryCollection that contains only an array of points is less optimal than a MultiPoint. See https://datatracker.ietf.org/doc/html/draft-ietf-geojson-03#section-3.1.8.

To maximize interoperability implementations SHOULD avoid nested geometry collections. Furthermore, geometry collections composed of a single part or a number of parts of a single type SHOULD be avoided when that single part or a single object of multi-part type (MultiPoint, MultiLineString, or MultiPolygon) could be used instead.

I've also given an updated answer to the other question you've linked.

sgillies
  • 9,056
  • 1
  • 33
  • 41
  • Thanks for the reference. I think the cleanest approach would be a JSON array of GeoJson FeatureCollections, with each FeatureCollection containing two features. A Multipoint geometry Feature and a Feature with it's associated boundary properties in a Polygon geometry. – intotecho May 16 '16 at 06:44
  • @intotecho I don't think that's the best solution since you end up duplicating the feature properties, increasing the feature count and you loose the association between the geometries. That's why a GeometryCollection exists. – AndrewHarvey Dec 21 '19 at 09:29
2

1) a MultiPoint GeoJSON (list of coordinates)

{'type': 'MultiPoint', 'coordinates': ((197434.0074146679, 90234.91638080444), (198639.4631111624, 89807.44982176385), (197758.8819995387, 88943.96737250185), (198374.4338445572, 88473.7541575572), (197895.6712984317, 88020.63960497417), (196921.0475438192, 88345.51418984502), (196536.3276406827, 89294.48995091513), (197434.0074146679, 90234.91638080444))}

2) a GeometryCollection (list of points)

{'type': 'GeometryCollection', 'geometries': [{'type': 'Point', 'coordinates': (197434.0074146679, 90234.91638080444)}, {'type': 'Point', 'coordinates': (198639.4631111624, 89807.44982176385)}, {'type': 'Point', 'coordinates': (197758.8819995387, 88943.96737250185)}, {'type': 'Point', 'coordinates': (198374.4338445572, 88473.7541575572)}, {'type': 'Point', 'coordinates': (197895.6712984317, 88020.63960497417)}, {'type': 'Point', 'coordinates': (196921.0475438192, 88345.51418984502)}, {'type': 'Point', 'coordinates': (196536.3276406827, 89294.48995091513)}, {'type': 'Point', 'coordinates': (197434.0074146679, 90234.91638080444)}]} 

3) as a GeometryCollection is a simple collection of geometries

{'type': 'GeometryCollection', 'geometries':{'type': 'MultiPoint', 'coordinates': ((197434.0074146679, 90234.91638080444), (198639.4631111624, 89807.44982176385), (197758.8819995387, 88943.96737250185), (198374.4338445572, 88473.7541575572), (197895.6712984317, 88020.63960497417), (196921.0475438192, 88345.51418984502), (196536.3276406827, 89294.48995091513), (197434.0074146679, 90234.91638080444))}}

But look at the answer of Sean Gillies

gene
  • 54,868
  • 3
  • 110
  • 187