The trees are currently misaligned, which you can verify by adding:
svg.selectAll("circle")
.data(trees)
.join("circle")
.attr("cx", d => d.x)
.attr("cy", d => d.y)
.attr("r", d => 4)
.attr("fill", "red");
To fix this, add:
.attr("text-anchor", "middle")