5

I'm working with GeoJSON Multipoints and wondering if there's any way of encoding properties for each point in the array? I realise this is a vague question but I'm looking for suggestions as to how I might achieve this or if there's a standard I'm unaware of.

AN EXAMPLE

In the example below I would be looking for a way for point1_property to represent a value for the first point in the MultiPoint array and point2_property to represent a value for the second point.

{  
    "type":"FeatureCollection",
    "features":[
        {
            "type":"Feature",
            "geometry":
                {
                    "type": "MultiPoint",
                    "coordinates": [ 
                        [100.0, 0.0], [101.0, 1.0] 
                    ]
                },
                "properties":{  
                "point1_property":"value1",
                "point2_property":"value2"
            }
        }
    ]
}
  • You must explode multipoint geometry into elementary geometries and attach attributes from the right columns to those. Is there a fixed number of members (points) in your MultiPoints or can it vary? – user30184 Mar 13 '16 at 16:30
  • No the number of points can vary wildly. Could you give an example of what this might look like. I'm currently in the process of writing a serializer. Thanks! – sammy88888888 Mar 13 '16 at 16:58
  • You could convert your data into PostGIS, use ST_DumpPoints postgis.net/docs/ST_DumpPoints.html and continue from that somehow. Alternative route could be to use SpatiaLite and ElementaryGeometries gaia-gis.it/gaia-sins/spatialite-sql-latest.html. However, I believe you would like to do it with a script or a program but I can't show any examples about that. For my mind the main problem is in the data. It should not contain MultiPoints if each point has its own attributes but data should consist of many simple points instead. – user30184 Mar 13 '16 at 17:49
7

In GeoJSON, features and feature collections have properties, Geometries don't.

Points in a Multipoint geometry all inherit the same properties of their container feature.

The standard way to express this in GeoJson would be a Feature Collection containing a collection of features, each feature contains a point geometry and arbitrary properties.

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

This might not be convenient or efficient in your case. There is no standard way to do this in GeoJson. Your proposed array of properties not invalid but application dependent. user30184 is correct

"the main problem is in the data. It should not contain MultiPoints if each point has its own attributes"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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