25

Is it valid to have a properties element with a featureCollection-element as parent?

This is, according to geojson.org valid:

{ "type": "FeatureCollection",
  "features": [
              { "type": "Feature",
                "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
                "properties": {"prop0": "value0"}
              }
              ]
}

But I can't find is it is valid nor if it is in-valid to have this:

{ "type": "FeatureCollection",
  "properties" : { "description" : "This is the geometry for..." }
  "features": [
              { "type": "Feature",
                "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
                "properties": {"prop0": "value0"}
              }
              ]
}

According to the answer underneath it is not in-valid to put it there, but programs/scripts won't know its there.

So, let me rephrase the question: (Where) Is it possible to put some descriptive information about the property as a total??

5 Answers 5

20

The short answer is no - it is not valid to have a properties element on a FeatureCollection object:

https://www.rfc-editor.org/rfc/rfc7946#section-7.1

The GeoJSON "geometry" and "properties" members define a Feature object. FeatureCollection and Geometry objects, respectively, MUST NOT contain a "geometry" or "properties" member.

2
  • 5
    From my reading, the wording on this mandates that you cannot name a member of a FeatureCollection "properties" like the OP does, but it does not preclude you from calling it something else like "metadata" or "description". I have used several top level members in web maps that rely on geojson. Good update, @Niel.
    – nronnei
    Jan 17, 2017 at 15:54
  • 2
    @nronnei Yes, and this is explicitly allowed in section 6.1 of RFC7946 which says "Members not described in this specification ('foreign members') MAY be used in a GeoJSON document." and after a bit of hemming and hawing gives an example approving the addition of an arbitrary user-defined .title field to a feature.
    – natevw
    Feb 14, 2021 at 1:36
13

2.3. Feature Collection Objects

A GeoJSON object with the type "FeatureCollection" is a feature collection object.

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 think this clearly implies that if the object has additional members that doesn't make it invalid.

Ecmascript objects are very open.

So yes, you can have a properties element at the top level of a feature collection, but don't expect any tools to know its there, or to copy it, ...

7
  • 1
    O.K. Fair enough :) But what is the place to store information about the collection itself instead of the feature?
    – stUrb
    May 12, 2012 at 8:24
  • There isn't one in the spec.
    – Calvin
    May 17, 2013 at 10:09
  • Because FeatureCollection is a first class object any properties will be about the collection, not any feature. Either add as many as you like, or add a "metadata" property whose value is a map.
    – Julian
    May 19, 2014 at 15:39
  • Another way of thinking about it is that you need to sub-class FeatureCollection for your needs. That's really a metaphor rather than a programming construct here though because ECMAscript doesn't think of objects quite that way.
    – Julian
    May 20, 2014 at 8:30
  • 1
    The spec does allow Foreign Members in section 6.1. tools.ietf.org/html/draft-ietf-geojson-03#section-6. So it is legal, but the behaviour will be application dependent.
    – intotecho
    May 16, 2016 at 6:33
2

I too think that a top level 'properties' would be useful, one at the feature collection level.

But the work around that I did was to make an additional feature for the feature collection, populate the properties as desired, and just set the geometry object to NULL. From my reading of the spec, this seems allowed and stays within the standard.

1

I don't have enough reputation yet to comment, so I will post in the form of an answer in support of https://gis.stackexchange.com/a/25309/217561

There are at least three sections of the spec that are relevant. As https://gis.stackexchange.com/users/7207/julian points out, the description of FeatureCollection doesn't mention "properties".

I think https://gis.stackexchange.com/a/209263/217561 is overlooking "respectively" in the spec which to me indicates that a FeatureCollection cannot have a "geometry" and a Geometry cannot have a "properties".

Further as https://gis.stackexchange.com/users/9181/natevw's comment indicates the spec states that other members not defined in the spec are valid but may not be interpreted by clients and could reduce interoperability.

To me this all adds up to the conclusion that adding a "properties" member to a FeatureCollection is a valid way to add collection level information and is aligned with the conventions of geojson.

1
  • can you cite any examples where this has been done in practice?
    – prusswan
    Feb 3, 2023 at 9:13
0

You can insert a Polygon feature without any coordinates and set your properties as you like:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [          
        ]
      },
      "properties": {
        "description": "This is the geometry for..."
      }
    },
    {
      // Other features
    }
  ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.