Turf: Loosing properties when using explode

Created on 2 Feb 2017  路  2Comments  路  Source: Turfjs/turf

Hi,

I have a Feature with a Geometry of type MultiPoint. I was surprise to see that the properties has not been transfer over the newly created (exploded) FeatureCollections features. Is this an issue or the intended behavior?

Thanks!

Input

{
   "type":"Feature",
   "properties":{
      "title":"Notable Avalanches",
      "id":"notable-avalanches-2017-02-01"
   },
   "geometry":{
      "type":"MultiPoint",
      "coordinates":[
         [
            -119.19410705566405,
            52.24798298528184
         ],
         [
            -119.09832000732423,
            52.579688026538726
         ],
         [
            -120.19523620605467,
            53.30708287744626
         ],
         [
            -121.47994995117188,
            53.986780183052055
         ],
         [
            -122.67814636230469,
            55.48741337428432
         ],
         [
            -127.16812133789062,
            54.7943516039205
         ],
         [
            -126.85775756835938,
            54.41573362292812
         ]
      ]
   }
}

Output

{
   "type":"FeatureCollection",
   "features":[
      {
         "type":"Feature",
         "properties":{

         },
         "geometry":{
            "type":"Point",
            "coordinates":[
               -119.19410705566405,
               52.24798298528184
            ]
         }
      },
      {
         "type":"Feature",
         "properties":{

         },
         "geometry":{
            "type":"Point",
            "coordinates":[
               -119.09832000732423,
               52.579688026538726
            ]
         }
      },
      {
         "type":"Feature",
         "properties":{

         },
         "geometry":{
            "type":"Point",
            "coordinates":[
               -120.19523620605467,
               53.30708287744626
            ]
         }
      },
      {
         "type":"Feature",
         "properties":{

         },
         "geometry":{
            "type":"Point",
            "coordinates":[
               -121.47994995117188,
               53.986780183052055
            ]
         }
      },
      {
         "type":"Feature",
         "properties":{

         },
         "geometry":{
            "type":"Point",
            "coordinates":[
               -122.67814636230469,
               55.48741337428432
            ]
         }
      },
      {
         "type":"Feature",
         "properties":{

         },
         "geometry":{
            "type":"Point",
            "coordinates":[
               -127.16812133789062,
               54.7943516039205
            ]
         }
      },
      {
         "type":"Feature",
         "properties":{

         },
         "geometry":{
            "type":"Point",
            "coordinates":[
               -126.85775756835938,
               54.41573362292812
            ]
         }
      }
   ]
}
bug

All 2 comments

@karlguillotte Thanks for reporting this, I do not believe this was intentional (more of a minor bug). There is no reason why properties of the parent GeoJSON should not be transferred down.

This doesn't sound like a hard issue to fix.

@karlguillotte Should have a fix for this now, at the moment it's on a separate branch explode-preserve-properties until it gets reviewed & merged.

Test input

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "foo": "bar"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -88.24218749999999,
              37.996162679728116
            ],
            [
              -88.24218749999999,
              53.330872983017066
            ],
            [
              -64.3359375,
              53.330872983017066
            ],
            [
              -64.3359375,
              37.996162679728116
            ],
            [
              -88.24218749999999,
              37.996162679728116
            ]
          ]
        ]
      }
    }
  ]
}

Output

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "foo": "bar"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -88.24218749999999,
          37.996162679728116
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "foo": "bar"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -88.24218749999999,
          53.330872983017066
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "foo": "bar"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -64.3359375,
          53.330872983017066
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "foo": "bar"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -64.3359375,
          37.996162679728116
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "foo": "bar"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -88.24218749999999,
          37.996162679728116
        ]
      }
    }
  ]
}

CC: @tmcw

Was this page helpful?
0 / 5 - 0 ratings