Public
Edited
Jun 20, 2023
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
proj4 = require("proj4")
Insert cell
Insert cell
Insert cell
firstProjection = 'PROJCS["NAD83 / Massachusetts Mainland",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",42.68333333333333],PARAMETER["standard_parallel_2",41.71666666666667],PARAMETER["latitude_of_origin",41],PARAMETER["central_meridian",-71.5],PARAMETER["false_easting",200000],PARAMETER["false_northing",750000],AUTHORITY["EPSG","26986"],AXIS["X",EAST],AXIS["Y",NORTH]]'
Insert cell
secondProjection = "+proj=gnom +lat_0=90 +lon_0=0 +x_0=6300000 +y_0=6300000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
Insert cell
proj4(firstProjection, secondProjection, [-122.305887, 58.9465872, 10])
Insert cell
Insert cell
proj4(secondProjection, [-71, 41])
Insert cell
Insert cell
transform = proj4(firstProjection, secondProjection)
Insert cell
transform.forward([-71, 41])
Insert cell
transform.inverse([-2690599.9886444192, 3662814.7663661353])
Insert cell
Insert cell
Insert cell
proj4.defs([
[
"EPSG:4326",
"+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"
],
[
"EPSG:4269",
"+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"
]
])
Insert cell
proj4("EPSG:4326")
Insert cell
proj4("EPSG:4326").oProj
Insert cell
Insert cell
Insert cell
Insert cell
world = d3
.json(
"https://cdn.jsdelivr.net/npm/visionscarto-world-atlas@0.1.0/world/110m.json"
)
.then((d) => topojson.feature(d, d.objects.countries))
Insert cell
Insert cell
Insert cell
Insert cell
bertin = require("bertin")
Insert cell
bertin.draw({
params: { projection: prj },
layers: [
{ geojson: world, fill: "#909ede" },
{ type: "graticule" },
{ type: "outline" }
]
})
Insert cell
Insert cell
Insert cell
d3 = require("d3", "d3-geo-projection")
Insert cell
import { proj4d3 } from "@fil/proj4js-d3"
Insert cell
Insert cell
Insert cell
worldMollweide = d3.geoProject(world, proj4d3(prj).reflectY(true))
Insert cell
button(worldMollweide, "worldMollowoide.geojson")
Insert cell
Insert cell
bertin.draw({
params: { projection: "user" },
layers: [{ geojson: worldMollweide, fill: "#909ede" }]
})
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more