1

I have an array of objects with the following structure:

 population = 
     [{county: "Alachua", population: 269956}
     {county: "Baker", population: 28355}
     {county: "Bay", population: 185287}
     {county: "Bradford", population: 27732}
     {county: "Brevard", population: 596849}]

In my GeoJSON file, in the properties array, there is a key value pair called County_1 that matches the name of the county in my populations array.

    {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": []
},
"properties": {
"OBJECTID_12_13": 1,
"OBJECTID": 1,
"DEPCODE": 21,
"COUNTY": "041",
"COUNTYNAME": "GILCHRIST",
"DATESTAMP": "2000-05-16T00:00:00.000Z",
"ShapeSTAre": 9908353355.45099,
"ShapeSTLen": 487300.011359113,
"OBJECTID_1": 21,
"County_1": "Gilchrist",
"State": "FL",
"OBJECTID_12": "1",
"DEPCODE_1": 21,
"COUNTYN": "41",
"PUIsTotal": 177,
"Age_0_4": 4,
"Age_5_14": 2,
"Age_15_24": 20,
"Age_25_34": 27,
"Age_35_44": 30,
"Age_45_54": 26,
"Age_55_64": 30,
"Age_65_74": 21,
"Age_75_84": 14,
"Age_85plus": 3,
"Age_Unkn": 0,
"PUIAgeRange": "0 to 89",
"PUIAgeMedian": 46,
"PUIFemale": 108,
"PUIMale": 69,
"PUISexUnkn": 0,
"PUIFLRes": 177,
"PUINotFLRes": 0,
"PUIFLResOut": 0,
"PUIContNo": 3,
"PUIContUnkn": 172,
"PUIAgeAvrg": "2",
"PUITravelNo": 11,
"PUITravelYes": 1,
"TPositive": 4,
"TNegative": 172,
"TInconc": 0,
"TPending": 1,
"T_Total_Res": 176,
"T_LabDOH_Res": 0,
"T_LabDOH_NonRes": 0,
"T_LabPrivate_Res": 4,
"T_LabPrivate_NonRes": 0,
"C_Female": 2,
"C_Male": 2,
"C_SexUnkn": 0,
"C_AllResTypes": 4,
"C_Age_0_4": 0,
"C_Age_5_14": 0,
"C_Age_15_24": 0,
"C_Age_25_34": 0,
"C_Age_35_44": 1,
"C_Age_45_54": 2,
"C_Age_55_64": 1,
"C_Age_65_74": 0,
"C_Age_75_84": 0,
"C_Age_85plus": 0,
"C_Age_Unkn": 0,
"C_AgeRange": "38 to 56",
"C_AgeMedian": 50,
"C_RaceWhite": 4,
"C_RaceBlack": 0,
"C_RaceOther": 0,
"C_RaceUnknown": 0,
"C_HispanicYES": 0,
"C_HispanicNO": 4,
"C_HispanicUnk": 0,
"C_EDYes_Res": 0,
"C_EDYes_NonRes": 0,
"C_HospYes_Res": 0,
"C_HospYes_NonRes": 0,
"C_NonResDeaths": 0,
"C_FLResDeaths": 0,
"CasesAll": 4,
"C_Men": 2,
"C_Women": 2,
"C_FLRes": 4,
"C_NotFLRes": 0,
"C_FLResOut": 0,
"T_NegRes": 172,
"T_NegNotFLRes": 0,
"T_total": 177,
"T_negative": 172,
"T_positive": 4,
"Deaths": 0,
"EverMon": 11,
"MonNow": 8,
"Shape__Area": 920490830.042053,
"Shape__Length": 148547.348006441
}
},
.....

How can I add the population of each county (using the population array) to my GeoJSON file ?

Vince
  • 20,017
  • 15
  • 45
  • 64
Alonsoag
  • 11
  • 2
  • possible duplicated https://gis.stackexchange.com/questions/103782/how-can-i-dynamically-add-features-to-a-geojson-file – Fran Raga Apr 20 '20 at 18:31
  • @FranRaga not a duplicate, the other question is using python. I'm using Javascript – Alonsoag Apr 20 '20 at 18:35
  • Ooops!you're right , look at this https://stackoverflow.com/questions/18884840/adding-a-new-array-element-to-a-json-object for example, remember that GeoJson is a superset of json – Fran Raga Apr 21 '20 at 07:01

0 Answers0