Geo Projections - zziuni/d3 GitHub Wiki

Wiki โ–ธ API Reference โ–ธ Geo โ–ธ Geo Projections

Mercator

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

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 (Composite)

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.

Azimuthal

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.

โš ๏ธ **GitHub.com Fallback** โš ๏ธ