Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reference all projections incl. d3-geo-projection and d3-geo-polygon #3665

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export default defineConfig({
{text: "Azimuthal projections", link: "/d3-geo/azimuthal"},
{text: "Conic projections", link: "/d3-geo/conic"},
{text: "Cylindrical projections", link: "/d3-geo/cylindrical"},
{text: "Extended projections", link: "/d3-geo/extended"},
]
},
{text: "Streams", link: "/d3-geo/stream"},
Expand Down
110 changes: 47 additions & 63 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,10 @@ Geographic projections, shapes and math.
* [*path*.area](./d3-geo/path.md#path_area) - compute the projected planar area of a given feature.
* [*path*.bounds](./d3-geo/path.md#path_bounds) - compute the projected planar bounding box of a given feature.
* [*path*.centroid](./d3-geo/path.md#path_centroid) - compute the projected planar centroid of a given feature.
* [*path*.digits](./d3-geo/path.md#path_digits) - set the output precision.
* [*path*.measure](./d3-geo/path.md#path_measure) - compute the projected planar length of a given feature.
* [*path*.projection](./d3-geo/path.md#path_projection) - set the geographic projection.
* [*path*.context](./d3-geo/path.md#path_context) - set the render context.
* [*path*.digits](./d3-geo/path.md#path_digits) - set the output precision.
* [*path*.pointRadius](./d3-geo/path.md#path_pointRadius) - set the radius to display point features.

### [Projections](./d3-geo/projection.md)
Expand All @@ -520,63 +520,56 @@ Geographic projections, shapes and math.
* [*projection*.fitSize](./d3-geo/projection.md#projection_fitSize) - set the scale and translate to fit a GeoJSON object.
* [*projection*.fitWidth](./d3-geo/projection.md#projection_fitWidth) - set the scale and translate to fit a GeoJSON object.
* [*projection*.fitHeight](./d3-geo/projection.md#projection_fitHeight) - set the scale and translate to fit a GeoJSON object.

#### [Raw projections](./d3-geo/projection.md#raw-projections)

* [*project*](./d3-geo/projection.md#_project) - project the specified point from the sphere to the plane.
* [*project*.invert](./d3-geo/projection.md#project_invert) - unproject the specified point from the plane to the sphere.
* [d3.geoProjection](./d3-geo/projection.md#geoProjection) - create a custom projection.
* [d3.geoProjectionMutator](./d3-geo/projection.md#geoProjectionMutator) - create a custom configurable projection.
* [d3.geoTransform](./d3-geo/projection.md#geoTransform) - define a custom geometry transform.
* [d3.geoIdentity](./d3-geo/projection.md#geoIdentity) - scale, translate or clip planar geometry.
* [d3.geoClipAntimeridian](./d3-geo/projection.md#geoClipAntimeridian) - cuts spherical geometries that cross the antimeridian.
* [d3.geoClipCircle](./d3-geo/projection.md#geoClipCircle) - clips spherical geometries to a small circle.
* [d3.geoClipRectangle](./d3-geo/projection.md#geoClipRectangle) - clips planar geometries to a rectangular viewport.

#### [Azimuthal projections](./d3-geo/projection/azimuthal.md)

* [d3.geoAzimuthalEqualArea](./d3-geo/azimuthal.md#geoAzimuthalEqualArea) - the azimuthal equal-area projection.
* [d3.geoAzimuthalEqualAreaRaw](./d3-geo/azimuthal.md#geoAzimuthalEqualAreaRaw) - the raw azimuthal equal-area projection.
* [d3.geoAzimuthalEquidistant](./d3-geo/azimuthal.md#geoAzimuthalEquidistant) - the azimuthal equidistant projection.
* [d3.geoAzimuthalEquidistantRaw](./d3-geo/azimuthal.md#geoAzimuthalEquidistantRaw) - the raw azimuthal equidistant projection.
* [d3.geoGnomonic](./d3-geo/azimuthal.md#geoGnomonic) - the gnomonic projection.
* [d3.geoGnomonicRaw](./d3-geo/azimuthal.md#geoGnomonicRaw) - the raw gnomonic projection.
* [d3.geoOrthographic](./d3-geo/azimuthal.md#geoOrthographic) - the azimuthal orthographic projection.
* [d3.geoOrthographicRaw](./d3-geo/azimuthal.md#geoOrthographicRaw) - the raw azimuthal orthographic projection.
* [d3.geoStereographic](./d3-geo/azimuthal.md#geoStereographic) - the azimuthal stereographic projection.
* [d3.geoStereographicRaw](./d3-geo/azimuthal.md#geoStereographicRaw) - the raw azimuthal stereographic projection.
* [d3.geoEqualEarth](./d3-geo/cylindrical.md#geoEqualEarth) - the Equal Earth projection.
* [d3.geoEqualEarthRaw](./d3-geo/cylindrical.md#geoEqualEarthRaw) - the raw Equal Earth projection.
* [d3.geoAlbersUsa](./d3-geo/conic.md#geoAlbersUsa) - a composite Albers projection for the United States.

#### [Conic projections](./d3-geo/projection/conic.md)

* [*conic*.parallels](./d3-geo/conic.md#conic_parallels) - set the two standard parallels.
* [d3.geoAlbers](./d3-geo/conic.md#geoAlbers) - the Albers equal-area conic projection.
* [d3.geoConicConformal](./d3-geo/conic.md#geoConicConformal) - the conic conformal projection.
* [d3.geoConicConformalRaw](./d3-geo/conic.md#geoConicConformalRaw) - the raw conic conformal projection.
* [d3.geoConicEqualArea](./d3-geo/conic.md#geoConicEqualArea) - the conic equal-area (Albers) projection.
* [d3.geoConicEqualAreaRaw](./d3-geo/conic.md#geoConicEqualAreaRaw) - the raw conic equal-area (Albers) projection.
* [d3.geoConicEquidistant](./d3-geo/conic.md#geoConicEquidistant) - the conic equidistant projection.
* [d3.geoConicEquidistantRaw](./d3-geo/conic.md#geoConicEquidistantRaw) - the raw conic equidistant projection.
* [d3.geoAlbers](./d3-geo/conic.md#geoAlbers) - the Albers equal-area conic projection.
* [d3.geoAlbersUsa](./d3-geo/conic.md#geoAlbersUsa) - a composite Albers projection for the United States.

#### [Cylindrical projections](./d3-geo/projection/cylindrical.md)

* [d3.geoEquirectangular](./d3-geo/cylindrical.md#geoEquirectangular) - the equirectangular (plate carreé) projection.
* [d3.geoEquirectangularRaw](./d3-geo/cylindrical.md#geoEquirectangularRaw) - the raw equirectangular (plate carreé) projection.
* [d3.geoMercator](./d3-geo/cylindrical.md#geoMercator) - the spherical Mercator projection.
* [d3.geoMercatorRaw](./d3-geo/cylindrical.md#geoMercatorRaw) - the raw Mercator projection.
* [d3.geoTransverseMercator](./d3-geo/cylindrical.md#geoTransverseMercator) - the transverse spherical Mercator projection.
* [d3.geoTransverseMercatorRaw](./d3-geo/cylindrical.md#geoTransverseMercatorRaw) - the raw transverse spherical Mercator projection.
* [d3.geoEqualEarth](./d3-geo/cylindrical.md#geoEqualEarth) - the Equal Earth projection.
* [d3.geoNaturalEarth1](./d3-geo/cylindrical.md#geoNaturalEarth1) - the Equal Earth projection, version 1.
* [d3.geoNaturalEarth1Raw](./d3-geo/cylindrical.md#geoNaturalEarth1Raw) - the raw Equal Earth projection, version 1

### [Raw projections](./d3-geo/projection.md#raw-projections)

* [*project*](./d3-geo/projection.md#_project) - project the specified point from the sphere to the plane.
* [*project*.invert](./d3-geo/projection.md#project_invert) - unproject the specified point from the plane to the sphere.
* [d3.geoProjection](./d3-geo/projection.md#geoProjection) - create a custom projection.
* [d3.geoProjectionMutator](./d3-geo/projection.md#geoProjectionMutator) - create a custom configurable projection.

### [Spherical math](./d3-geo/math.md)
### [Streams](./d3-geo/stream.md)

* [d3.geoArea](./d3-geo/math.md#geoArea) - compute the spherical area of a given feature.
* [d3.geoBounds](./d3-geo/math.md#geoBounds) - compute the latitude-longitude bounding box for a given feature.
* [d3.geoCentroid](./d3-geo/math.md#geoCentroid) - compute the spherical centroid of a given feature.
* [d3.geoDistance](./d3-geo/math.md#geoDistance) - compute the great-arc distance between two points.
* [d3.geoLength](./d3-geo/math.md#geoLength) - compute the length of a line string or the perimeter of a polygon.
* [d3.geoInterpolate](./d3-geo/math.md#geoInterpolate) - interpolate between two points along a great arc.
* [d3.geoContains](./d3-geo/math.md#geoContains) - test whether a point is inside a given feature.
* [d3.geoRotation](./d3-geo/math.md#geoRotation) - create a rotation function for the specified angles.
* [*rotation*](./d3-geo/math.md#_rotation) - rotate the given point around the sphere.
* [*rotation*.invert](./d3-geo/math.md#rotation_invert) - unrotate the given point around the sphere.
* [d3.geoStream](./d3-geo/stream.md#geoStream) - convert a GeoJSON object to a geometry stream.
* [*stream*.point](./d3-geo/stream.md#stream_point) - indicates a point with the specified coordinates.
* [*stream*.lineStart](./d3-geo/stream.md#stream_lineStart) - indicates the start of a line or ring.
* [*stream*.lineEnd](./d3-geo/stream.md#stream_lineEnd) - indicates the end of a line or ring.
* [*stream*.polygonStart](./d3-geo/stream.md#stream_polygonStart) - indicates the start of a polygon.
* [*stream*.polygonEnd](./d3-geo/stream.md#stream_polygonEnd) - indicates the end of a polygon.
* [*stream*.sphere](./d3-geo/stream.md#stream_sphere) - indicates the sphere.

### [Spherical shapes](./d3-geo/shape.md)

* [d3.geoCircle](./d3-geo/shape.md#geoCircle) - create a circle generator.
* [*circle*](./d3-geo/shape.md#_circle) - generate a piecewise circle as a Polygon.
* [*circle*.center](./d3-geo/shape.md#circle_center) - specify the circle center in latitude and longitude.
* [*circle*.radius](./d3-geo/shape.md#circle_radius) - specify the angular radius in degrees.
* [*circle*.precision](./d3-geo/shape.md#circle_precision) - specify the precision of the piecewise circle.
* [d3.geoGraticule](./d3-geo/shape.md#geoGraticule) - create a graticule generator.
* [*graticule*](./d3-geo/shape.md#_graticule) - generate a MultiLineString of meridians and parallels.
* [*graticule*.lines](./d3-geo/shape.md#graticule_lines) - generate an array of LineStrings of meridians and parallels.
Expand All @@ -589,29 +582,22 @@ Geographic projections, shapes and math.
* [*graticule*.stepMinor](./d3-geo/shape.md#graticule_stepMinor) - get or set the minor step intervals.
* [*graticule*.precision](./d3-geo/shape.md#graticule_precision) - get or set the latitudinal precision.
* [d3.geoGraticule10](./d3-geo/shape.md#geoGraticule10) - generate the default 10° global graticule.
* [d3.geoCircle](./d3-geo/shape.md#geoCircle) - create a circle generator.
* [*circle*](./d3-geo/shape.md#_circle) - generate a piecewise circle as a Polygon.
* [*circle*.center](./d3-geo/shape.md#circle_center) - specify the circle center in latitude and longitude.
* [*circle*.radius](./d3-geo/shape.md#circle_radius) - specify the angular radius in degrees.
* [*circle*.precision](./d3-geo/shape.md#circle_precision) - specify the precision of the piecewise circle.

### [Streams](./d3-geo/stream.md)

* [d3.geoStream](./d3-geo/stream.md#geoStream) - convert a GeoJSON object to a geometry stream.
* [*stream*.point](./d3-geo/stream.md#stream_point) - indicates a point with the specified coordinates.
* [*stream*.lineStart](./d3-geo/stream.md#stream_lineStart) - indicates the start of a line or ring.
* [*stream*.lineEnd](./d3-geo/stream.md#stream_lineEnd) - indicates the end of a line or ring.
* [*stream*.polygonStart](./d3-geo/stream.md#stream_polygonStart) - indicates the start of a polygon.
* [*stream*.polygonEnd](./d3-geo/stream.md#stream_polygonEnd) - indicates the end of a polygon.
* [*stream*.sphere](./d3-geo/stream.md#stream_sphere) - indicates the sphere.

### [Transforms](./d3-geo/projection.md#geoTransform)

* [d3.geoTransform](./d3-geo/projection.md#geoTransform) - define a custom geometry transform.
* [d3.geoIdentity](./d3-geo/projection.md#geoIdentity) - scale, translate or clip planar geometry.

### [Clipping](./d3-geo/projection.md#geoClipAntimeridian)
### [Spherical math](./d3-geo/math.md)

* [*preclip*](./d3-geo/projection.md#preclip) - pre-clipping in geographic coordinates.
* [*postclip*](./d3-geo/projection.md#postclip) - post-clipping in planar coordinates.
* [d3.geoClipAntimeridian](./d3-geo/projection.md#geoClipAntimeridian) - cuts spherical geometries that cross the antimeridian.
* [d3.geoClipCircle](./d3-geo/projection.md#geoClipCircle) - clips spherical geometries to a small circle.
* [d3.geoClipRectangle](./d3-geo/projection.md#geoClipRectangle) - clips planar geometries to a rectangular viewport.
* [d3.geoArea](./d3-geo/math.md#geoArea) - compute the spherical area of a given feature.
* [d3.geoBounds](./d3-geo/math.md#geoBounds) - compute the latitude-longitude bounding box for a given feature.
* [d3.geoCentroid](./d3-geo/math.md#geoCentroid) - compute the spherical centroid of a given feature.
* [d3.geoDistance](./d3-geo/math.md#geoDistance) - compute the great-arc distance between two points.
* [d3.geoLength](./d3-geo/math.md#geoLength) - compute the length of a line string or the perimeter of a polygon.
* [d3.geoInterpolate](./d3-geo/math.md#geoInterpolate) - interpolate between two points along a great arc.
* [d3.geoContains](./d3-geo/math.md#geoContains) - test whether a point is inside a given feature.
* [d3.geoRotation](./d3-geo/math.md#geoRotation) - create a rotation function for the specified angles.

## [d3-hierarchy](./d3-hierarchy.md)

Expand Down Expand Up @@ -1171,7 +1157,6 @@ A spline or polyline, as in a line chart.
* [*lineRadial*.defined](./d3-shape/radial-line.md#lineRadial_defined) - set the defined accessor.
* [*lineRadial*.curve](./d3-shape/radial-line.md#lineRadial_curve) - set the curve interpolator.
* [*lineRadial*.context](./d3-shape/radial-line.md#lineRadial_context) - set the rendering context.
* [*lineRadial*.digits](./d3-shape/radial-line.md#lineRadial_digits) - set the output precision.

### [Areas](./d3-shape/area.md)

Expand Down Expand Up @@ -1204,7 +1189,6 @@ An area, defined by a bounding topline and baseline, as in an area chart.
* [*areaRadial*.defined](./d3-shape/radial-area.md#areaRadial_defined) - set the defined accessor.
* [*areaRadial*.curve](./d3-shape/radial-area.md#areaRadial_curve) - set the curve interpolator.
* [*areaRadial*.context](./d3-shape/radial-area.md#areaRadial_context) - set the rendering context.
* [*areaRadial*.digits](./d3-shape/radial-area.md#areaRadial_digits) - set the output precision.
* [*areaRadial*.lineStartAngle](./d3-shape/radial-area.md#areaRadial_lineStartAngle) - derive a line for the start edge of an area.
* [*areaRadial*.lineInnerRadius](./d3-shape/radial-area.md#areaRadial_lineInnerRadius) - derive a line for the inner edge of an area.
* [*areaRadial*.lineEndAngle](./d3-shape/radial-area.md#areaRadial_lineEndAngle) - derive a line for the end edge of an area.
Expand Down
4 changes: 2 additions & 2 deletions docs/d3-contour/contour.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Here is an example that loads a GeoTIFF of surface temperatures, and another tha

[<img alt="Cloud Contours" src="https://raw.githubusercontent.com/d3/d3-contour/main/img/clouds.png" width="420" height="219">](https://observablehq.com/@d3/cloud-contours)

Since the contour polygons are GeoJSON, you can transform and display them using standard tools; see [geoPath](../d3-geo.md#geoPath), [geoProject](https://github.com/d3/d3-geo-projection/blob/main/README.md#geoProject) and [geoStitch](https://github.com/d3/d3-geo-projection/blob/main/README.md#geoStitch), for example. Here the above contours of surface temperature are displayed in the Natural Earth projection:
Since the contour polygons are GeoJSON, you can transform and display them using standard tools; see [geoPath](../d3-geo/path.md#geoPath), [geoProject](https://github.com/d3/d3-geo-projection/blob/main/README.md#geoProject) and [geoStitch](https://github.com/d3/d3-geo-projection/blob/main/README.md#geoStitch), for example. Here the above contours of surface temperature are displayed in the Natural Earth projection:

[<img alt="GeoTiff Contours II" src="https://raw.githubusercontent.com/d3/d3-contour/main/img/reprojection.png" width="420" height="219">](https://observablehq.com/@d3/geotiff-contours-ii)

Expand Down Expand Up @@ -75,6 +75,6 @@ The input *values* must be an array of length <i>n</i>×<i>m</i> where [<i>n</i>

[Source](https://github.com/d3/d3-contour/blob/main/src/contours.js) · If *thresholds* is specified, sets the threshold generator to the specified function or array and returns this contour generator. If *thresholds* is not specified, returns the current threshold generator, which by default implements [Sturges’ formula](../d3-array/bin.md#thresholdSturges).

Thresholds are defined as an array of values [*x0*, *x1*, …]. The first [generated contour](#_contour) corresponds to the area where the input values are greater than or equal to *x0*; the second contour corresponds to the area where the input values are greater than or equal to *x1*, and so on. Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value; the threshold value is exposed as <i>geometry</i>.value.
Thresholds are defined as an array of values [*x0*, *x1*, …]. The first generated contour corresponds to the area where the input values are greater than or equal to *x0*; the second contour corresponds to the area where the input values are greater than or equal to *x1*, and so on. Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value; the threshold value is exposed as <i>geometry</i>.value.

If a *count* is specified instead of an array of *thresholds*, then the input values’ [extent](../d3-array/summarize.md#extent) will be uniformly divided into approximately *count* bins; see [ticks](../d3-array/ticks.md#ticks).
2 changes: 1 addition & 1 deletion docs/d3-force.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can even use it as a rudimentary physics engine, say to simulate cloth:

[<img alt="Force-Directed Lattice" src="https://raw.githubusercontent.com/d3/d3-force/master/img/lattice.png" width="480" height="250">](https://observablehq.com/@d3/force-directed-lattice)

To use this module, create a [simulation](#simulation) for an array of [nodes](./d3-force/simulation.md#simulation_nodes), and compose the desired [forces](./d3-force/simulation.md#simulation_force). Then [listen](./d3-force/simulation.md#simulation_on) for tick events to render the nodes as they update in your preferred graphics system, such as Canvas or SVG.
To use this module, create a [simulation](./d3-force/simulation.md) for an array of [nodes](./d3-force/simulation.md#simulation_nodes), and compose the desired [forces](./d3-force/simulation.md#simulation_force). Then [listen](./d3-force/simulation.md#simulation_on) for tick events to render the nodes as they update in your preferred graphics system, such as Canvas or SVG.

See one of:

Expand Down
2 changes: 1 addition & 1 deletion docs/d3-geo.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ To convert shapefiles to GeoJSON, use [shp2json](https://github.com/mbostock/sha
:::

:::warning CAUTION
D3’s winding order convention is also used by [TopoJSON](https://github.com/topojson) and [ESRI shapefiles](https://github.com/mbostock/shapefile); however, it is the opposite convention of GeoJSON’s [RFC 7946](https://tools.ietf.org/html/rfc7946#section-3.1.6). Also note that standard GeoJSON WGS84 uses planar equirectangular coordinates, not spherical coordinates, and thus may require [stitching](https://github.com/d3/d3-geo-projection/blob/main/README.md#geostitch) to remove antimeridian cuts.
D3’s winding order convention is also used by [TopoJSON](https://github.com/topojson) and [ESRI shapefiles](https://github.com/mbostock/shapefile); however, it is the opposite convention of GeoJSON’s [RFC 7946](https://tools.ietf.org/html/rfc7946#section-3.1.6). Also note that standard GeoJSON WGS84 uses planar equirectangular coordinates, not spherical coordinates, and thus may require [stitching](./d3-geo/extended.md#geoStitch) to remove antimeridian cuts.
:::