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:
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 =
</ 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
+ "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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...