79230446

Date: 2024-11-27 13:22:47
Score: 0.5
Natty:
Report link

I got it resolved. Look up the property: zone_code in zone_to_division.

    for feature in topojson_data['features']:
        division_name = feature['properties'].get('division', 'Unknown')
        zone_code = next((k for k, v in zone_to_division.items() if v == division_name), None)
        
        if zone_code and zone_code in zone_colors:
            feature['properties']['color'] = zone_colors[zone_code]
            feature['properties']['data_count'] = division_crime_counts.get(division_name, 0)
        else:
            feature['properties']['color'] = [200, 200, 200]
            feature['properties']['data_count'] = 0

    geojson_layer = pdk.Layer(
        "GeoJsonLayer",
        topojson_data,
        opacity=0.6,
        stroked=True,
        filled=True,
        extruded=True,
        get_fill_color='properties.color',
        get_elevation='properties.crime_count * 100',
    ...

Here's my output

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Sree