Public
Edited
Mar 2, 2023
6 stars
Insert cell
Insert cell
Insert cell
geoLine = (value = 0, direction = 'lat', precision = 2.5, geojson = false) => {
const v = parseFloat(value)
precision = parseFloat(precision)
const lineString = {type: "LineString", coordinates: []}
let coordinates
switch (direction) {
case 'latitude':
case 'lat':
coordinates = d3.range(-180, 180+1, precision).map(x => [x,v])
return geojson ? (lineString.coordinates = coordinates, lineString) : coordinates
break
case 'longitude':
case 'long':
case 'lon':
coordinates = d3.range(-90, 90+1, precision).map(y => [v,y])
return geojson ? (lineString.coordinates = coordinates, lineString) : coordinates
break
default:
return `'${direction}' n'est pas une valeur de direction possible. 'lat' ou 'long' attendu`
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Latitude 10° au format array
geoLine(10, 'lat', 2.5, false)
Insert cell
// Latitude 10° au format array
// en prenant en compte les valeurs par défaut
geoLine(10)
Insert cell
// Latitude 10° au format geojson
geoLine(10, 'lat', 2.5, true)
Insert cell
// Longitude -70° au format array
// précision de 30° = chaque couple de coordonnées est espacé de 30° de latitude
geoLine(-60, 'lon', 30)
Insert cell
// Longitude -70° au format geojson
geoLine(-60, 'lon', 30, true)
Insert cell
Insert cell
geographicLines = ({
type: "MultiLineString",
coordinates: [
geoLine(66.563, 'lat'), // Cercle polaire arctique
geoLine(23.436, 'lat'), // Tropique du Cancer
geoLine(0, 'lat', 90), // Équateur
geoLine(-23.436, 'lat'), // Tropique du Capricorne
geoLine(-66.563, 'lat'), // Cercle polaire antarctique
geoLine(0, 'lon', 90), // Méridien de Greenwitch
geoLine(180, 'lon', 90), // Antiméridien
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
projection = d3.geoOrthographic().rotate([rotate,rotate])
Insert cell
path = d3.geoPath(projection)
Insert cell
height = {
const [[x0, y0], [x1, y1]] = d3.geoPath(projection.fitWidth(width, outline)).bounds(outline);
const dy = Math.ceil(y1 - y0)
return dy;
}
Insert cell
outline = ({type: "Sphere"})
Insert cell
Insert cell
Insert cell
// conversion de topojson en geojson
countries_110m = topojson.feature(countries_simplified, countries_simplified.objects.countries_110m)
Insert cell
Insert cell
urban = {
const geo = await FileAttachment("urban_500k.json").json()
return topojson.feature(geo, geo.objects.urban)
}
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