Accepted answer

Filter your data retaining unique keys only by"#road").selectAll("option")
    .data(, function(d){return d.roadname;}).keys())
    .text(function(d){return d;})
    .attr("value",function(d){return d;});

score:3 is deprecated - the d3 devs now recommend simply using JavaScript's built-in (In fact the entire d3-collection module is now deprecated, with similar rationale for d3.set.)

Here's a concise and (I think) elegant way to do this in ES6, using, Set, and the spread operator ...:

let options = [ Set( => d.roadname))]; 
// optionally add .sort() to the end of that line to sort the unique values
// alphabetically rather than by insertion order'#road')
    .text(d => d)
    .attr('value', d => d);

Related Query

More Query from same tag