Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

D3.js geoBertin1953() Function

  • Last Updated : 23 Sep, 2020

The geoBertin1953() function in d3.js is used to draw the Jacques Bertin’s 1953 projection. It makes the Baker Bertin’s 1953 projection from given geo JSON data.

Syntax: 

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

d3.geoBertin1953()

Parameters: This method does not accept any parameters.

Return value: This method returns the Bertin1953 projection.



Example: The following example makes the Bertin’s 1953 projection of Africa.

HTML




<!DOCTYPE html> 
<html lang="en"
  
<head
    <meta charset="UTF-8" /> 
    <meta name="viewport"
        content="width=device-width, 
                initial-scale=1.0"/>
    <script src=
        "https://d3js.org/d3.v4.js">
    </script>
    <script src=
    </script>
</head>
  
<body
    <div style="width:400px; height:300px;"
        <svg width="600" height="300"
        </svg
    </div
      
    <script>
        var svg = d3.select("svg"),
            width = +svg.attr("width"),
            height = +svg.attr("height");
  
        // Bertin1953 projection
        var gfg = d3.geoBertin1953()
            .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", "black")
                    .attr("d", d3.geoPath()
                        .projection(gfg)
                    )
                    .style("stroke", "#ffff")
        })
    </script>
</body
  
</html>

Output:

Bertin 1953 Projection




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!