Skip to main content
se añadieron 4688 caracteres en el cuerpo
Origen Enlace
{
  "type": "FeatureCollection",
  "totalFeatures": 1515,
  "features": [
    {
      "type": "Feature",
      "id": "fd597jf1799.1",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.27163887,
                33.24041367
              ],
              [
                -7.27286911,
                33.24623871
              ],
              [
                -7.26732922,
                33.25904083
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 1,
        "name_4": "Ahlaf",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.27286911,
          33.22112656,
          -6.93353081,
          33.38970184
        ],
        "swing_count": 1,
        "polling_station_count": 15,
        "turnout": 0.4780299144225693,
        "results": {
          "PI": 187,
          "PJD": 88,
          "PAM": 59,
          "USFP": 1530,
          "APFGD": 2,
          "PPS": 15,
          "RNI": 708,
          "MP": 56,
          "UC": 3,
          "FFD": 0,
          "MDS": 0,
          "AAR": 0,
          "P Neo-Democrates": 8,
          "PEDD": 0,
          "PRD": 2,
          "PRV": 0,
          "PDI": 0,
          "PGVM": 0,
          "PALAMAL": 0,
          "PCS": 0,
          "PUD": 0,
          "PDN": 1,
          "PLJS": 0,
          "PSD": 0,
          "P Annahda": 0,
          "PA": 0,
          "UMD": 0,
          "USAPMD": 10
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 5953,
          "nbre_votants": 2997,
          "nbre_nuls": 328,
          "nbre_exprimees": 2669
        },
        "swing_ratio": 0.06666666666666667
      }
    },
    {
      "type": "Feature",
      "id": "fd597jf1799.2",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.00001287,
                33.63414383
              ],
              [
                -7.00081205,
                33.6269989
              ],
              [
                -6.99825382,
                33.60465622
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 2,
        "name_4": "Ain Tizgha",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.12737417,
          33.57954407,
          -6.99144888,
          33.78071213
        ],
        "swing_count": 11,
        "polling_station_count": 23,
        "turnout": 0.3912592182242994,
        "results": {
          "PI": 1837,
          "PJD": 366,
          "PAM": 143,
          "USFP": 22,
          "APFGD": 44,
          "PPS": 773,
          "RNI": 109,
          "MP": 111,
          "UC": 9,
          "FFD": 0,
          "MDS": 0,
          "AAR": 0,
          "P Neo-Democrates": 76,
          "PEDD": 27,
          "PRD": 2,
          "PRV": 0,
          "PDI": 0,
          "PGVM": 0,
          "PALAMAL": 0,
          "PCS": 0,
          "PUD": 0,
          "PDN": 1,
          "PLJS": 0,
          "PSD": 0,
          "P Annahda": 0,
          "PA": 0,
          "UMD": 2,
          "USAPMD": 514
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 8262,
          "nbre_votants": 4479,
          "nbre_nuls": 443,
          "nbre_exprimees": 4036
        },
        "swing_ratio": 0.4782608695652174
      }
    }
  ],
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4326"
    }
  },
  "bbox": [
    -13.2287693,
    27.62881088,
    -0.93655348,
    35.96390533
  ]
}

Por ejemplo, digamos que en Ahlaf winning_party = PAM. ¿Cómo me deshago del diccionario results y puestar winner:PAM en lugar? Aqui esta el resultado esperado:

{
  "type": "FeatureCollection",
  "totalFeatures": 1515,
  "features": [
    {
      "type": "Feature",
      "id": "fd597jf1799.1",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.27163887,
                33.24041367
              ],
              [
                -7.27286911,
                33.24623871
              ],
              [
                -7.26732922,
                33.25904083
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 1,
        "name_4": "Ahlaf",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.27286911,
          33.22112656,
          -6.93353081,
          33.38970184
        ],
        "swing_count": 1,
        "polling_station_count": 15,
        "turnout": 0.4780299144225693,
        "winning_party": "PAM",
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 5953,
          "nbre_votants": 2997,
          "nbre_nuls": 328,
          "nbre_exprimees": 2669
        },
        "swing_ratio": 0.06666666666666667
      }
    },
    {
      "type": "Feature",
      "id": "fd597jf1799.2",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.00001287,
                33.63414383
              ],
              [
                -7.00081205,
                33.6269989
              ],
              [
                -6.99825382,
                33.60465622
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 2,
        "name_4": "Ain Tizgha",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.12737417,
          33.57954407,
          -6.99144888,
          33.78071213
        ],
        "swing_count": 11,
        "polling_station_count": 23,
        "turnout": 0.3912592182242994,
        "results": {
          "PI": 1837,
          "PJD": 366,
          "PAM": 143,
          "USFP": 22
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 8262,
          "nbre_votants": 4479,
          "nbre_nuls": 443,
          "nbre_exprimees": 4036
        },
        "swing_ratio": 0.4782608695652174
      }
    }
  ],
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4326"
    }
  },
  "bbox": [
    -13.2287693,
    27.62881088,
    -0.93655348,
    35.96390533
  ]
}
{
  "type": "FeatureCollection",
  "totalFeatures": 1515,
  "features": [
    {
      "type": "Feature",
      "id": "fd597jf1799.1",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.27163887,
                33.24041367
              ],
              [
                -7.27286911,
                33.24623871
              ],
              [
                -7.26732922,
                33.25904083
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 1,
        "name_4": "Ahlaf",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.27286911,
          33.22112656,
          -6.93353081,
          33.38970184
        ],
        "swing_count": 1,
        "polling_station_count": 15,
        "turnout": 0.4780299144225693,
        "results": {
          "PI": 187,
          "PJD": 88,
          "PAM": 59,
          "USFP": 1530,
          "APFGD": 2,
          "PPS": 15,
          "RNI": 708,
          "MP": 56,
          "UC": 3,
          "FFD": 0,
          "MDS": 0,
          "AAR": 0,
          "P Neo-Democrates": 8,
          "PEDD": 0,
          "PRD": 2,
          "PRV": 0,
          "PDI": 0,
          "PGVM": 0,
          "PALAMAL": 0,
          "PCS": 0,
          "PUD": 0,
          "PDN": 1,
          "PLJS": 0,
          "PSD": 0,
          "P Annahda": 0,
          "PA": 0,
          "UMD": 0,
          "USAPMD": 10
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 5953,
          "nbre_votants": 2997,
          "nbre_nuls": 328,
          "nbre_exprimees": 2669
        },
        "swing_ratio": 0.06666666666666667
      }
    },
    {
      "type": "Feature",
      "id": "fd597jf1799.2",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.00001287,
                33.63414383
              ],
              [
                -7.00081205,
                33.6269989
              ],
              [
                -6.99825382,
                33.60465622
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 2,
        "name_4": "Ain Tizgha",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.12737417,
          33.57954407,
          -6.99144888,
          33.78071213
        ],
        "swing_count": 11,
        "polling_station_count": 23,
        "turnout": 0.3912592182242994,
        "results": {
          "PI": 1837,
          "PJD": 366,
          "PAM": 143,
          "USFP": 22,
          "APFGD": 44,
          "PPS": 773,
          "RNI": 109,
          "MP": 111,
          "UC": 9,
          "FFD": 0,
          "MDS": 0,
          "AAR": 0,
          "P Neo-Democrates": 76,
          "PEDD": 27,
          "PRD": 2,
          "PRV": 0,
          "PDI": 0,
          "PGVM": 0,
          "PALAMAL": 0,
          "PCS": 0,
          "PUD": 0,
          "PDN": 1,
          "PLJS": 0,
          "PSD": 0,
          "P Annahda": 0,
          "PA": 0,
          "UMD": 2,
          "USAPMD": 514
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 8262,
          "nbre_votants": 4479,
          "nbre_nuls": 443,
          "nbre_exprimees": 4036
        },
        "swing_ratio": 0.4782608695652174
      }
    }
  ],
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4326"
    }
  },
  "bbox": [
    -13.2287693,
    27.62881088,
    -0.93655348,
    35.96390533
  ]
}

Por ejemplo, digamos que en Ahlaf winning_party = PAM. ¿Cómo me deshago del diccionario results y puestar winner:PAM?

{
  "type": "FeatureCollection",
  "totalFeatures": 1515,
  "features": [
    {
      "type": "Feature",
      "id": "fd597jf1799.1",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.27163887,
                33.24041367
              ],
              [
                -7.27286911,
                33.24623871
              ],
              [
                -7.26732922,
                33.25904083
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 1,
        "name_4": "Ahlaf",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.27286911,
          33.22112656,
          -6.93353081,
          33.38970184
        ],
        "swing_count": 1,
        "polling_station_count": 15,
        "turnout": 0.4780299144225693,
        "results": {
          "PI": 187,
          "PJD": 88,
          "PAM": 59,
          "USFP": 1530,
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 5953,
          "nbre_votants": 2997,
          "nbre_nuls": 328,
          "nbre_exprimees": 2669
        },
        "swing_ratio": 0.06666666666666667
      }
    },
    {
      "type": "Feature",
      "id": "fd597jf1799.2",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.00001287,
                33.63414383
              ],
              [
                -7.00081205,
                33.6269989
              ],
              [
                -6.99825382,
                33.60465622
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 2,
        "name_4": "Ain Tizgha",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.12737417,
          33.57954407,
          -6.99144888,
          33.78071213
        ],
        "swing_count": 11,
        "polling_station_count": 23,
        "turnout": 0.3912592182242994,
        "results": {
          "PI": 1837,
          "PJD": 366,
          "PAM": 143,
          "USFP": 22,
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 8262,
          "nbre_votants": 4479,
          "nbre_nuls": 443,
          "nbre_exprimees": 4036
        },
        "swing_ratio": 0.4782608695652174
      }
    }
  ],
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4326"
    }
  },
  "bbox": [
    -13.2287693,
    27.62881088,
    -0.93655348,
    35.96390533
  ]
}

Por ejemplo, digamos que en Ahlaf winning_party = PAM. ¿Cómo me deshago del diccionario results y puestar winner:PAM en lugar? Aqui esta el resultado esperado:

{
  "type": "FeatureCollection",
  "totalFeatures": 1515,
  "features": [
    {
      "type": "Feature",
      "id": "fd597jf1799.1",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.27163887,
                33.24041367
              ],
              [
                -7.27286911,
                33.24623871
              ],
              [
                -7.26732922,
                33.25904083
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 1,
        "name_4": "Ahlaf",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.27286911,
          33.22112656,
          -6.93353081,
          33.38970184
        ],
        "swing_count": 1,
        "polling_station_count": 15,
        "turnout": 0.4780299144225693,
        "winning_party": "PAM",
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 5953,
          "nbre_votants": 2997,
          "nbre_nuls": 328,
          "nbre_exprimees": 2669
        },
        "swing_ratio": 0.06666666666666667
      }
    },
    {
      "type": "Feature",
      "id": "fd597jf1799.2",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.00001287,
                33.63414383
              ],
              [
                -7.00081205,
                33.6269989
              ],
              [
                -6.99825382,
                33.60465622
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 2,
        "name_4": "Ain Tizgha",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.12737417,
          33.57954407,
          -6.99144888,
          33.78071213
        ],
        "swing_count": 11,
        "polling_station_count": 23,
        "turnout": 0.3912592182242994,
        "results": {
          "PI": 1837,
          "PJD": 366,
          "PAM": 143,
          "USFP": 22
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 8262,
          "nbre_votants": 4479,
          "nbre_nuls": 443,
          "nbre_exprimees": 4036
        },
        "swing_ratio": 0.4782608695652174
      }
    }
  ],
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4326"
    }
  },
  "bbox": [
    -13.2287693,
    27.62881088,
    -0.93655348,
    35.96390533
  ]
}
Origen Enlace

¿Cómo reemplazar un diccionario en un archivo JSON?

Tengo una circunscripción y un resultado. Me gustaría añadir este resultado a un geojson en la línea donde la clave es el circunscripción .

Por ejemplo, con circunscripcion.geojson:

{
  "type": "FeatureCollection",
  "totalFeatures": 1515,
  "features": [
    {
      "type": "Feature",
      "id": "fd597jf1799.1",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.27163887,
                33.24041367
              ],
              [
                -7.27286911,
                33.24623871
              ],
              [
                -7.26732922,
                33.25904083
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 1,
        "name_4": "Ahlaf",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.27286911,
          33.22112656,
          -6.93353081,
          33.38970184
        ],
        "swing_count": 1,
        "polling_station_count": 15,
        "turnout": 0.4780299144225693,
        "results": {
          "PI": 187,
          "PJD": 88,
          "PAM": 59,
          "USFP": 1530,
          "APFGD": 2,
          "PPS": 15,
          "RNI": 708,
          "MP": 56,
          "UC": 3,
          "FFD": 0,
          "MDS": 0,
          "AAR": 0,
          "P Neo-Democrates": 8,
          "PEDD": 0,
          "PRD": 2,
          "PRV": 0,
          "PDI": 0,
          "PGVM": 0,
          "PALAMAL": 0,
          "PCS": 0,
          "PUD": 0,
          "PDN": 1,
          "PLJS": 0,
          "PSD": 0,
          "P Annahda": 0,
          "PA": 0,
          "UMD": 0,
          "USAPMD": 10
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 5953,
          "nbre_votants": 2997,
          "nbre_nuls": 328,
          "nbre_exprimees": 2669
        },
        "swing_ratio": 0.06666666666666667
      }
    },
    {
      "type": "Feature",
      "id": "fd597jf1799.2",
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [
                -7.00001287,
                33.63414383
              ],
              [
                -7.00081205,
                33.6269989
              ],
              [
                -6.99825382,
                33.60465622
              ]
            ]
          ]
        ]
      },
      "geometry_name": "geom",
      "properties": {
        "id_0": 152,
        "iso": "MAR",
        "name_0": "Morocco",
        "id_1": 1,
        "name_1": "Chaouia - Ouardigha",
        "id_2": 1,
        "name_2": "Ben Slimane",
        "id_3": 1,
        "name_3": "Ben Slimane",
        "id_4": 2,
        "name_4": "Ain Tizgha",
        "varname_4": null,
        "ccn_4": 0,
        "cca_4": null,
        "type_4": "Commune Rural",
        "engtype_4": "Rural Commune",
        "bbox": [
          -7.12737417,
          33.57954407,
          -6.99144888,
          33.78071213
        ],
        "swing_count": 11,
        "polling_station_count": 23,
        "turnout": 0.3912592182242994,
        "results": {
          "PI": 1837,
          "PJD": 366,
          "PAM": 143,
          "USFP": 22,
          "APFGD": 44,
          "PPS": 773,
          "RNI": 109,
          "MP": 111,
          "UC": 9,
          "FFD": 0,
          "MDS": 0,
          "AAR": 0,
          "P Neo-Democrates": 76,
          "PEDD": 27,
          "PRD": 2,
          "PRV": 0,
          "PDI": 0,
          "PGVM": 0,
          "PALAMAL": 0,
          "PCS": 0,
          "PUD": 0,
          "PDN": 1,
          "PLJS": 0,
          "PSD": 0,
          "P Annahda": 0,
          "PA": 0,
          "UMD": 2,
          "USAPMD": 514
        },
        "voter_file": {
          "nbre_sieges": 3,
          "nbre_inscrits": 8262,
          "nbre_votants": 4479,
          "nbre_nuls": 443,
          "nbre_exprimees": 4036
        },
        "swing_ratio": 0.4782608695652174
      }
    }
  ],
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4326"
    }
  },
  "bbox": [
    -13.2287693,
    27.62881088,
    -0.93655348,
    35.96390533
  ]
}

Por ejemplo, digamos que en Ahlaf winning_party = PAM. ¿Cómo me deshago del diccionario results y puestar winner:PAM?