Interface GeoProjection

A Geographic Projection to transform spherical polygonal geometry to planar polygonal geometry. D3 provides implementations of several classes of standard projections:

  • Azimuthal
  • Composite
  • Conic
  • Cylindrical

For many more projections, see d3-geo-projection. You can implement custom projections using d3.geoProjection or d3.geoProjectionMutator.

interface GeoProjection {
    angle(): number;
    angle(angle): GeoProjection;
    center(): [number, number];
    center(point): GeoProjection;
    clipAngle(): number;
    clipAngle(angle): GeoProjection;
    clipExtent(): [[number, number], [number, number]];
    clipExtent(extent): GeoProjection;
    fitExtent(extent, object): GeoProjection;
    fitHeight(height, object): GeoProjection;
    fitSize(size, object): GeoProjection;
    fitWidth(width, object): GeoProjection;
    invert?(point): [number, number];
    postclip(): ((stream) => GeoStream);
    postclip(postclip): GeoProjection;
    precision(): number;
    precision(precision): GeoProjection;
    preclip(): ((stream) => GeoStream);
    preclip(preclip): GeoProjection;
    reflectX(): boolean;
    reflectX(reflect): GeoProjection;
    reflectY(): boolean;
    reflectY(reflect): GeoProjection;
    rotate(): [number, number, number];
    rotate(angles): GeoProjection;
    scale(): number;
    scale(scale): GeoProjection;
    stream(stream): GeoStream;
    translate(): [number, number];
    translate(point): GeoProjection;
    (point): [number, number];
}

Hierarchy

  • Returns a new array [x, y] (typically in pixels) representing the projected point of the given point. The point must be specified as a two-element array [longitude, latitude] in degrees. May return null if the specified point has no defined projected position, such as when the point is outside the clipping bounds of the projection.

    Parameters

    • point: [number, number]

      A point specified as a two-dimensional array [longitude, latitude] in degrees.

    Returns [number, number]

Methods

  • Returns the projection’s current angle, which defaults to 0°.

    Returns number

  • Sets the projection’s post-projection planar rotation angle to the specified angle in degrees and returns the projection.

    Parameters

    • angle: number

      The new rotation angle of the projection.

    Returns GeoProjection

  • Returns the current center of the projection, which defaults to ⟨0°,0°⟩.

    Returns [number, number]

  • Sets the projection’s center to the specified center, a two-element array of longitude and latitude in degrees and returns the projection. The default is ⟨0°,0°⟩.

    Parameters

    • point: [number, number]

      A point specified as a two-dimensional array [longitude, latitude] in degrees.

    Returns GeoProjection

  • Returns the current clip angle which defaults to null.

    null switches to antimeridian cutting rather than small-circle clipping.

    Returns number

  • Sets the projection’s clipping circle radius to the specified angle in degrees and returns the projection. If angle is null, switches to antimeridian cutting rather than small-circle clipping.

    Parameters

    • angle: number

    Returns GeoProjection

  • Returns the current viewport clip extent which defaults to null.

    Returns [[number, number], [number, number]]

  • Sets the projection’s viewport clip extent to the specified bounds in pixels and returns the projection. The extent bounds are specified as an array [[x₀, y₀], [x₁, y₁]], where x₀ is the left-side of the viewport, y₀ is the top, x₁ is the right and y₁ is the bottom. If extent is null, no viewport clipping is performed.

    Parameters

    • extent: [[number, number], [number, number]]

    Returns GeoProjection

  • Returns a new array [longitude, latitude] in degrees representing the unprojected point of the given projected point. May return null if the specified point has no defined projected position, such as when the point is outside the clipping bounds of the projection.

    Parameters

    • point: [number, number]

      The projected point, specified as a two-element array [x, y] (typically in pixels).

    Returns [number, number]

  • Returns the current cartesian clipping function. Post-clipping occurs on the plane, when a projection is bounded to a certain extent such as a rectangle.

    Returns ((stream) => GeoStream)

      • (stream): GeoStream
      • Returns the current cartesian clipping function. Post-clipping occurs on the plane, when a projection is bounded to a certain extent such as a rectangle.

        Parameters

        Returns GeoStream

  • Sets the projection’s cartesian clipping to the specified function and returns the projection.

    Parameters

    • postclip: ((stream) => GeoStream)

      A cartesian clipping function. Clipping functions are implemented as transformations of a projection stream. Post-clipping operates on planar coordinates, in pixels.

    Returns GeoProjection

  • Returns the projection’s current resampling precision which defaults to square root of 0.5. This value corresponds to the Douglas–Peucker distance.

    Returns number

  • Sets the threshold for the projection’s adaptive resampling to the specified value in pixels and returns the projection. This value corresponds to the Douglas–Peucker distance.

    Parameters

    • precision: number

      A numeric value in pixels to use as the threshold for the projection’s adaptive resampling.

    Returns GeoProjection

  • Returns the current spherical clipping function. Pre-clipping occurs in geographic coordinates. Cutting along the antimeridian line, or clipping along a small circle are the most common strategies.

    Returns ((stream) => GeoStream)

      • (stream): GeoStream
      • Returns the current spherical clipping function. Pre-clipping occurs in geographic coordinates. Cutting along the antimeridian line, or clipping along a small circle are the most common strategies.

        Parameters

        Returns GeoStream

  • Sets the projection’s spherical clipping to the specified function and returns the projection. Pre-clipping occurs in geographic coordinates. Cutting along the antimeridian line, or clipping along a small circle are the most common strategies.

    Parameters

    • preclip: ((stream) => GeoStream)

      A spherical clipping function. Clipping functions are implemented as transformations of a projection stream. Pre-clipping operates on spherical coordinates, in radians.

    Returns GeoProjection

  • Returns true if x-reflection is enabled, which defaults to false.

    Returns boolean

  • Sets whether or not the x-dimension is reflected (negated) in the output.

    Parameters

    • reflect: boolean

      Whether or not the x-dimension is reflected (negated) in the output.

    Returns GeoProjection

  • Returns true if y-reflection is enabled, which defaults to false.

    Returns boolean

  • Sets whether or not the y-dimension is reflected (negated) in the output.

    Parameters

    • reflect: boolean

      Whether or not the y-dimension is reflected (negated) in the output.

    Returns GeoProjection

  • Returns the current rotation [lambda, phi, gamma] specifying the rotation angles in degrees about each spherical axis. (These correspond to yaw, pitch and roll.) which defaults [0, 0, 0].

    Returns [number, number, number]

  • Sets the projection’s three-axis rotation to the specified angles, which must be a two- or three-element array of numbers.

    Parameters

    • angles: [number, number] | [number, number, number]

      A two- or three-element array of numbers [lambda, phi, gamma] specifying the rotation angles in degrees about each spherical axis. (These correspond to yaw, pitch and roll.) If the rotation angle gamma is omitted, it defaults to 0.

    Returns GeoProjection

  • Returns the current scale factor; the default scale is projection-specific.

    The scale factor corresponds linearly to the distance between projected points; however, absolute scale factors are not equivalent across projections.

    Returns number

  • Sets the projection’s scale factor to the specified value and returns the projection. The scale factor corresponds linearly to the distance between projected points; however, absolute scale factors are not equivalent across projections.

    Parameters

    • scale: number

      Scale factor to be used for the projection; the default scale is projection-specific.

    Returns GeoProjection

  • Returns a projection stream for the specified output stream. Any input geometry is projected before being streamed to the output stream. A typical projection involves several geometry transformations: the input geometry is first converted to radians, rotated on three axes, clipped to the small circle or cut along the antimeridian, and lastly projected to the plane with adaptive resampling, scale and translation.

    Parameters

    Returns GeoStream

  • Returns the current translation offset which defaults to [480, 250] and places ⟨0°,0°⟩ at the center of a 960×500 area. The translation offset determines the pixel coordinates of the projection’s center.

    Returns [number, number]

  • Sets the projection’s translation offset to the specified two-element array [tx, ty] and returns the projection. The translation offset determines the pixel coordinates of the projection’s center. The default translation offset places ⟨0°,0°⟩ at the center of a 960×500 area.

    Parameters

    • point: [number, number]

      A two-element array [tx, ty] specifying the translation offset. The default translation offset of defaults to [480, 250] places ⟨0°,0°⟩ at the center of a 960×500 area.

    Returns GeoProjection