Public
Edited
Jan 23, 2024
Insert cell
# UD Fall 2023 - New Orleans (Large Scale)
Insert cell
d3 = require("d3@6")
Insert cell
chart = {
const width = 1100,
height = 600;
const svg = d3.create("svg")
.attr("viewBox", [65, 35, width-100, height-100]); //use in tandom to create a better square
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], bbox1);

var path1 = d3.geoPath().projection(projection);//any path that comes from qgis
var path2 = d3.geoPath().projection(projection);
var path3 = d3.geoPath().projection(projection);
var path4 = d3.geoPath().projection(projection);

var g = svg.append("g").attr("id", "paths");

svg.append('image')
.attr('href',view)
.attr('class','spotImage')
.attr('x', '-21')
.attr('y','14')
.attr('width', 1100)
.attr('height', 550)
g.selectAll("path3") //d3 geopath
.data(harvest.features) //get data to define path
.enter() //there are more data than elements, this selects them
.append("path") //appends path to data
.attr('class','outlines')
.attr("d", path3) //The d attribute defines a path to be drawn, only applies to appended elements
.style("fill", "green")
.style("fill-opacity", ".25")
.style('stroke-opacity','0')
.style("stroke-width", '.5')
.style("stroke", "black")


var c = svg.selectAll("circle")
.data(reefs.features)
.enter()
.append("circle")
.attr("cx", function(d) {return path1.centroid(d)[0]})
.attr("cy", function(d) {return path1.centroid(d)[1]})
.attr('r',6)
.style('fill','white')
.style('fill-opacity','1')
.style("stroke-width", '2')
.style("stroke", "black")
.on('mouseover',fireText)
.on('mouseout',removefireText)

function fireText(event,d){
console.log(d)

svg
.append("text")
.attr('x','90')
.attr('y','120')
.attr('class','mypoints_position')
.style('font-family','garamond')
.style('font-size','16px')
.style('font-weight','light')
.text(d.properties.name)

var wrap = svg.selectAll("text.mypoints_position")
.each(function(d, i) { wrap_text(d3.select(this), 100) });

svg
.append("line")
.attr('x1','90')
.attr('y1','120')
.attr('x2', path1.centroid(d)[0])
.attr('y2', path1.centroid(d)[1])
.attr('class','fireLine')
.style("stroke-width", '.25')
.style("stroke", "rgb(0,0,0)")
.style('stroke-dasharray', '6 4')
}

function removefireText(){
d3.selectAll('text.mypoints_position').remove()
d3.selectAll('line.fireLine').remove()
}

svg
.append("text")
.attr('x','878')
.attr('y','195')
.style('font-family','garamond')
.style('font-size','12px')
.style('font-weight','light')
.text('26 Years: 52,316 FT')
svg
.append("text")
.attr('x','878')
.attr('y','145')
.style('font-family','garamond')
.style('font-size','12px')
.style('font-weight','light')
.text('15 Years: 30,300 FT')
svg
.append("text")
.attr('x','878')
.attr('y','96')
.style('font-family','garamond')
.style('font-size','12px')
.style('font-weight','light')
.text('5 Years: 10,100 FT')
svg
.append("text")
.attr('x','708')
.attr('y','78')
.style('font-family','garamond')
.style('font-size','14px')
.style('font-weight','bold')
.text('Lake Borgne Reef Proposal')
svg
.append("text")
.attr('x','825')
.attr('y','245')
.style('font-family','garamond')
.style('font-size','14px')
.style('font-weight','bold')
.text('New Orleans')
svg
.append("line")
.attr('x1','825')
.attr('y1','245')
.attr('x2','775')
.attr('y2','275')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
svg
.append("text")
.attr('x','90')
.attr('y','75')
.style('font-family','garamond')
.style('font-size','24px')
.style('font-weight','bold')
.text('Louisiana Oyster Reefs')

svg
.append("text")
.attr('x','140')
.attr('y','470')
.style('font-family','garamond')
.style('font-size','14px')
.style('font-weight','bold')
.text('Oyster Harvest Regions')

svg
.append("text")
.attr('x','90')
.attr('y','100')
.style('font-family','garamond')
.style('font-size','18px')
.style('font-weight','bold')
.text('Existing Oyster Reefs:')

svg
.append("line")
.attr('x1','90')
.attr('y1','82.5')
.attr('x2','333')
.attr('y2','82.5')
.style("stroke-width", '1')
.style("stroke", "rgb(0,0,0)")
return svg.node();
}

Insert cell
bbox1 = FileAttachment("bbox.geojson").json()
Insert cell
harvest = FileAttachment("harvest.geojson").json()
Insert cell
reefs = FileAttachment("reefs.geojson").json()
Insert cell
cities = FileAttachment("cities.geojson").json()
Insert cell
bbox = FileAttachment("Bbox.geojson").json()
Insert cell
traffic1 = FileAttachment("Rivers.geojson").json()
Insert cell
Insert cell
personal_spots = d3.csv(personal_spots_link,d3.autoType)
Insert cell
import { wrap_text, wrap_text_nchar } from "@ben-tanen/svg-text-and-tspan-word-wrapping"
Insert cell
view = FileAttachment("ViewCapture13.png").url()
Insert cell
oysterharvest1 = FileAttachment("oysterharvest@1.geojson").json()
Insert cell
viewcapture6 = FileAttachment("ViewCapture6.png").image()
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