The geoAzimuthalEqualArea() function in d3.js is used to draw the Lambert azimuthal equal-area projection from the given geojson data. It is a projection that tries to maintain land features to their correct relative sizes while also maintaining the correct sense of direction from the center. The world here is projected onto a flat surface from any point on the globe.
Syntax:
d3.geoAzimuthalEqualArea()
Parameters: This method does not accept any parameters.
Return Value: This method returns the azimuthal equal-area projection.
Example 1: The following example draws the Lambert azimuthal equal-area projection of North and South America.
HTML
<!DOCTYPE html> <html>   <head>     </script>     <script src=     </script> </head>   <body>     <div style="width:300px;               height:700px;">         <center>             <h4 style="color:green">                 AzimuthalEqualArea Projection                 of America             </h4>         </center>         <svg width="400" height="300">         </svg>     </div>     <script>         var svg = d3.select("svg"),             width = +svg.attr("width"),             height = +svg.attr("height");           // AzimuthalEqualArea projection         var gfg = d3.geoAzimuthalEqualArea()             .scale(width / 1.5 / Math.PI)             .translate([width / 2, height / 2]);           // Loading the json data         d3.json("https://raw.githubusercontent.com/" +             "janasayantan/datageojson/master/" +             "america.json",             function (data) {                   // Draw the map                 svg.append("g")                     .selectAll("path")                     .data(data.features)                     .enter().append("path")                     .attr("fill", "green")                     .attr("d", d3.geoPath()                         .projection(gfg)                     )                     .style("stroke", "#ffff")             });     </script> </body>   </html> |
Output:
Example 2: The following example draws the Lambert azimuthal equal-area projection of Africa.
HTML
<!DOCTYPE html> <html>   <head>     </script>     <script src=     </script> </head>   <body>     <div style="width:600px;               height:300px;">         <center>             <h4 style="color:green">                 AzimuthalEqualArea Projection                 of Africa             </h4>         </center>         <svg width="600" height="300">         </svg>     </div>     <script>         var svg = d3.select("svg"),             width = +svg.attr("width"),             height = +svg.attr("height");           // AzimuthalEqualArea         var gfg = d3.geoAzimuthalEqualArea()             .scale(width / 1.5 / Math.PI)             .translate([width / 2, height / 2]);           // Loading the json data         d3.json("https://raw.githubusercontent.com/" +             "janasayantan/datageojson/master/" +             "geoAfrica.json",             function (data) {                   // Draw the map                 svg.append("g")                     .selectAll("path")                     .data(data.features)                     .enter().append("path")                     .attr("fill", "olive")                     .attr("d", d3.geoPath()                         .projection(gfg)                     )                     .style("stroke", "#ffff")             });     </script> </body>   </html> |
Output:

