Skip to content

Geo Projections

zziuni edited this page Mar 22, 2013 · 78 revisions

WikiAPI ReferenceGeoGeo 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를 작성하기에 가장 적절하다. 하지만 개발자는 적절한 parallelsorigin을 결정해야만 한다.

# 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이다. 스케일은 투영된 지점들 사이거리에 선형으로 비례한다. 투영법 에 따라서 스케일 값은 일치하지 않을 수 도 있다. (예를 들어MercatorAlbers)

# 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.