0

I'm struggling to create an array of the values for D01. This is the first feature in my geojson variable:

county = [{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4269" } },

"features": [
{ "type": "Feature", "properties": { "NAMELSAD10": "St. Clair County", "D01": 5.650500, "D02": 0.504000, "D03": 0.495000, "D04": 48.100000, "D05": 0.199000, "D06": 0.965000, "D07": 0.038000, "D08": 0.031000, "D09": 0.211000 }, "geometry": { "type": "Polygon", "coordinates": [
//so many coordinate pairs
] } } ] ]

To clarify, I want [5.650500, ...]

From this post I used:

help = county.features.map(function(f){
    return f.properties.D01;
})

which gives the error: Cannot read property "map" of undefined.

Thinking some of my values might be null, I wrote this:

var help = new Array();
try{
    help = county.features.map(function(f){
        return f.properties.D01;
    })
}catch(e){}

console.log(help);

which results in [], the blank 'help' array being written.

It seems I'm not accessing what I want to here. Can someone please point me in the right direction?

Community
  • 1
  • 1
Syb Ille
  • 3
  • 2

1 Answers1

1

Your county seems an Array.

try this:

county[0].features.map(function(f){
    return f.properties.D01;
})
Alessandro Alessandra
  • 1,065
  • 12
  • 18