Geo Projections - zziuni/d3 GitHub Wiki
Wiki โธ API Reference โธ Geo โธ Geo Projections
The spherical Mercator projection is commonly used by tiled mapping libraries (such as OpenLayers and Leaflet). It is conformal; however, it introduces severe area distortion at world scale and thus is not recommended for choropleths.
# d3.geo.mercator()
Construct a new spherical Mercator projection with the default scale (500) and translate ([480, 250]). The default Mercator projection is appropriate for displaying the entire world in a 960ร500 area.
# mercator(location)
The forward projection: returns a two-element array [x, y] given the input [longitude, latitude].
# mercator.invert(point)
The inverse projection: returns a two-element array [longitude, latitude] given the input [x, y].
# mercator.scale([scale])
Get or set the projectionโs scale factor. If scale is specified, sets the projectionโs scale factor to the specified value and returns the projection. If scale is not specified, returns the current scale factor which defaults to 500. The scale factor corresponds linearly to the distance between projected points. Note that scale factors may not be consistent across projection types (e.g., Mercator and Albers).
# mercator.translate([offset])
Get or set the projection's translation offset. If offset is specified, sets the projectionโs translation offset to the specified two-element array [x, y] and returns the projection. If offset is not specified, returns the current translation offset which defaults to [480, 250]. The translation offset determines the pixel coordinates of the origin ([0, 0] in longitude and latitude). The default value is designed to place null island at the center of a 960ร500 area.
Albers ๋ฑ์ ํฌ์๋ฒ์ ์งํ๋ฉด์ ์๋์ ํฌ๊ธฐ๋ฅผ ์ ์งํ๋ฏ๋ก choropleth map๋ฅผ ์์ฑํ๊ธฐ์ ๊ฐ์ฅ ์ ์ ํ๋ค. ํ์ง๋ง ๊ฐ๋ฐ์๋ ์ ์ ํ parallels
์ origin
์ ๊ฒฐ์ ํด์ผ๋ง ํ๋ค.
# d3.geo.albers()
Albers ๋ฑ์ ์์ถ ํฌ์(Albers equal-area conic projection)์ ์๋ก ์์ฑํ๋ค. ๊ธฐ๋ณธ๊ฐ์ scale(1000), translate([480,250]), origin([-98,38]), parallels([29.5,45.4])์ด๋ค. ๊ธฐ๋ณธ ๋ฑ์ ํฌ์์ 960x500 ํฌ๊ธฐ์ ๋ฏธ๊ตญ์ ์ถ๋ ฅํ๊ธฐ์ ์ ๋น๋นํ ํฌ๊ธฐ๋ค. parallels ๊ฐ 29.5ยบ์ 45.4ยบ์ 1970๋ National Atlas์์ USGS๊ฐ ์ ํํ๋ค.
# albers(location)
The forward projection: returns a two-element array [x, y] given the input [longitude, latitude].
# albers.invert(point)
The inverse projection: returns a two-element array [longitude, latitude] given the input [x, y].
# albers.origin([origin])
origin ์ธ์๋ฅผ ์ง์ ํ๋ฉด [longitude(๊ฒฝ๋), latitude(์๋)]์ ์์๊ฐ ๋๊ฐ์ธ ๋ฐฐ์ด๋ก ํฌ์๋ฒ์ origin์ ์ง์ ํ๋ค. ๊ทธ๋ฆฌ๊ณ ํฌ์(projection)์ ๋ฐํํ๋ค. origin์ ์ง์ ํ์ง ์์ผ๋ฉด ํ์ฌ origin์ ๋ฐํํ๋ค. ๊ธฐ๋ณธ๊ฐ์ -98, 38์ด๋ค(Hutchinson, Kansas). parallel ๋ผ์ธ์ ์ธ๊ณก์ ์ต์ํ ํ๊ธฐ ์ํด์๋ origin์ด ๊ด์ฌ ์ง์ญ์ ์ค์ฌ์์ ๊ฐ๊น์ด ๊ณณ์ ์ง์ ํด์ผ๋ง ํ๋ค.
# albers.parallels([parallels])
parallels์ธ์๋ฅผ ์ง์ ํ๋ฉด ์๋(latitude) ์์๊ฐ ๋๊ฐ์ธ ๋ฐฐ์ด๋ก ํฌ์๋ฒ์ parallels๋ฅผ ์ง์ ํ๋ค. ๊ทธ๋ฆฌ๊ณ ํฌ์(projection)์ ๋ฐํํ๋ค. paralles ์ธ์๋ฅผ ์ง์ ํ์ง ์์ผ๋ฉด ํ์ฌ paralles๋ฅผ ๋ฐํํ๋ค. ๊ธฐ๋ณธ๊ฐ์ [29.5, 45.5]์ด๋ค. parallals ๋ผ์ธ์ ์ธ๊ณก์ ์ต์ํ ํ๊ธฐ ์ํด์๋ origin์ ์์์ธ๊ณ ๊ด์ฌ ์ง์ญ์ parallals๊ฐ ๋ฅ์ด์ผ ํ๋ค.
# albers.scale([scale])
ํฌ์๋์ ์ค์ผ์ผ ๊ฐ์ get, set ํ๋ค. scale ์ธ์๋ฅผ ์ง์ ํ๋ฉด ์ด ๊ฐ์ผ๋ก ํฌ์๋์ ์ค์ผ์ผ ๊ฐ์ ์ง์ ํ๊ณ ํฌ์๋๋ฅผ ๋ฐํํ๋ค. ์ง์ ํ์ง ์์ผ๋ฉด ํ์ฌ ์ค์ผ์ผ์ ๋ฐํํ๋ค. ๊ธฐ๋ณธ๊ฐ์ 1000์ด๋ค. ์ค์ผ์ผ์ ํฌ์๋ ์ง์ ๋ค ์ฌ์ด๊ฑฐ๋ฆฌ์ ์ ํ์ผ๋ก ๋น๋กํ๋ค. ํฌ์๋ฒ ์ ๋ฐ๋ผ์ ์ค์ผ์ผ ๊ฐ์ ์ผ์นํ์ง ์์ ์ ๋ ์๋ค. (์๋ฅผ ๋ค์ดMercator
์ Albers
)
# albers.translate([offset])
Get or set the projection's translation offset. If offset is specified, sets the projectionโs translation offset to the specified two-element array [x, y] and returns the projection. If offset is not specified, returns the current translation offset which defaults to [480, 250]. The translation offset determines the pixel coordinates of the origin. The default value is designed to place Hutchinson, Kansas at the center of a 960ร500 area.
Albers USA ํฌ์๋ฒ์ ๋ค ๊ฐ์ Albers ํฌ์๋ฒ์ ํจ์ฑ ํฌ์๋ฒ์ด๋ค. ์๋ ์ค์นด, ํ์์ด, ํธ์๋ฅดํ ๋ฆฌ์ฝ๋ฅผ ์๋์ชฝ์ ๋ถ์ธ ๋ฏธ๊ตญ 48๊ฐ์ฃผ๋ฅผ ์ถ๋ ฅํ๋๋ก ๋์์ธ๋์๋ค. choropleths map์ ์ํด์ ๋์๋์์ง๋ง ํธ์๋ฅดํ ๋ฆฌ์ฝ(1.5x), ์๋ ์ค์นด(0.6x) ํฌ๊ธฐ๋ ์ธ๊ณก์ด ์๋ค. ํ์์ด๋ 48๊ฐ์ฃผ์ ๊ฐ์ด ๋์ผ ์ค์ผ์ผ์ด๋ค.
์ด ํฉ์ฑ ํฌ์๋ฒ์ ๋ค์์ฒ๋ผ ๊ตฌํ๋์๋ค.
function albersUsa(coordinates) {
var lon = coordinates[0],
lat = coordinates[1];
return (lat > 50 ? alaska
: lon < -140 ? hawaii
: lat < 21 ? puertoRico
: lower48)(coordinates);
}
Albers USA ํฌ์๋ฒ์ ๋ฐ์ ํฌ์์ ์์ง ์ง์ํ์ง ์๋๋ค.
# d3.geo.albersUsa()
Construct a new composite Albers projection for the United States.
# albersUsa(location)
The forward projection: returns a two-element array [x, y] given the input [longitude, latitude].
# albersUsa.scale([scale])
Get or set the projectionโs scale factor. If scale is specified, sets the projectionโs scale factor to the specified value and returns the projection. If scale is not specified, returns the current scale factor which defaults to 1000. The scale factor corresponds linearly to the distance between projected points. Note that scale factors may not be consistent across projection types (e.g., Mercator and Albers).
(As noted above, a scale factor of 1000 corresponds to a scale of 1500 for Puerto Rico and 600 for Alaska.)
# albersUsa.translate([offset])
Get or set the projection's translation offset. If offset is specified, sets the projectionโs translation offset to the specified two-element array [x, y] and returns the projection. If offset is not specified, returns the current translation offset which defaults to [480, 250]. The translation offset determines the pixel coordinates of the origin. The default value is designed to place Hutchinson, Kansas at the center of a 960ร500 area.
D3โs azimuthal projection implementation encompasses [orthographic](http://en.wikipedia.org/wiki/Orthographic_projection_(cartography\)), stereographic, gnomonic, equidistant and equal-area projections.
# d3.geo.azimuthal()
Construct a new Azimuthal projection with the default mode (orthographic), origin (โจ0, 0โฉ), scale (200) and translate ([480, 250]). The default projection shows the hemisphere centered around null island in a 960ร500 area. Azimuthal projections should typically be used in conjunction with d3.geo.circleโs clip method to avoid showing the back-facing hemisphere.
# azimuthal(location)
The forward projection: returns a two-element array [x, y] given the input [longitude, latitude].
# azimuthal.mode([mode])
Get or set the projectionโs mode. If mode is specified, sets the projection mode to the specified string and returns the projection. If mode is not specified, returns the current mode which defaults to orthographic. The allowed modes are:
- orthographic
- stereographic
- gnomonic
- equidistant
- equalarea
See this interactive example for a demonstration of the different projection modes.
# azimuthal.origin([origin])
Get or set the projectionโs origin. If origin is specified, sets the projectionโs origin to the specified two-element array [longitude, latitude] and returns the projection. If origin is not specified, returns the current origin, which defaults to [0, 0] (null island). To minimize distortion, the origin should be chosen to be near the center of the region of interest.
# azimuthal.scale([scale])
Get or set the projectionโs scale factor. If scale is specified, sets the projectionโs scale factor to the specified value and returns the projection. If scale is not specified, returns the current scale factor which defaults to 200. The scale factor corresponds linearly to the distance between projected points. Note that scale factors may not be consistent across projection types (e.g., Mercator and Albers).
# azimuthal.translate([offset])
Get or set the projection's translation offset. If offset is specified, sets the projectionโs translation offset to the specified two-element array [x, y] and returns the projection. If offset is not specified, returns the current translation offset which defaults to [480, 250]. The translation offset determines the pixel coordinates of the origin. The default value is designed to place Null Island at the center of a 960ร500 area.