Converting area of a polygon from steradians to square kilometers using D3.js?

المشرف العام

Administrator
طاقم الإدارة
How can I find the area of a polygon in square km using D3.js? I'm not even really sure whether to use d3.geo.path.area or d3.geo.area.

Here is my code (JSFiddle):

var d = { "type":"Feature", "id":"7525", "properties":{"name":"Paris, 11e arrondissement","id":"117525"}, "geometry": { "type":"Polygon", "coordinates":[[[2.377,48.8719],[2.3991,48.8481],[2.369,48.8532], [2.3684,48.8557],[2.3639,48.8674],[2.377,48.8719]]] } }; var w=720, h=640; var projection = d3.geo.orthographic().scale(3660).rotate([-3,-46.35]) .clipExtent([[0,0], [w,h]]).translate([w/2,h/2]); var path = d3.geo.path().projection(projection); console.log('path area', path.area(d)); console.log('geo area', d3.geo.area(d)); For path area I get 1.0841410092907608 and for geo area I get 8.101249039703731e-8.

The docs suggest that the first is the result in pixels, and the second is the result in steradians. Is it possible to convert steradians to square km?



أكثر...
 
أعلى