rust_d3_geo icon indicating copy to clipboard operation
rust_d3_geo copied to clipboard

Accessing properties of Geometry objects when using AlbersUsa projector

Open jtsiros opened this issue 2 years ago • 0 comments

I'm looking at the Globe Albersusa example and noticed that the properties of Geometry object is not available after feature_from_name returns. I need to access these properties to assign/map the FIPS county ID to each SVG subcomponent so I can map specific data to each county.

Here's the equivalent code in JS does this automatically without having to do any manual mapping:

ex:

     // Draw county boundaries and fill accordingly
      svg.selectAll("path")
        .data(feature(usCounties, usCounties.objects.counties).features)
        .enter().append("path")
        .attr("d", path)
        .attr("fill", d => {
          const countyData = countyToData[d.id];
          console.log(d, countyData);
          if (countyData) {
            return d3.color(colorScale(countyData.rise));
          }
          return "darkgrey";
        })
        .attr("stroke", "#ffffff") // color of the border
        .attr("stroke-width", "1.0"); // thickness of the border;

How can i do something similar with d3_geo?

jtsiros avatar Sep 02 '23 23:09 jtsiros