Skip to content

Instantly share code, notes, and snippets.

@harllos
Created March 15, 2019 00:04
Show Gist options
  • Save harllos/81ebc0770a3d7fe9f35d9769b084c2f5 to your computer and use it in GitHub Desktop.
Save harllos/81ebc0770a3d7fe9f35d9769b084c2f5 to your computer and use it in GitHub Desktop.
function getFeatureDomain(geojson_data, myproperty) {
 let data_domain = []
 turf.propEach(geojson_data, function(currentProperties, featureIndex) {
 data_domain.push(Math.round(Number(currentProperties[myproperty]) * 100 / 100))
 })
 return data_domain
 }
function createColorStops(stops_domain, scale) {
 let stops = []
 stops_domain.forEach(function(d) {
 stops.push([d, scale(d).hex()])
 });
 return stops
 }
function createRadiusStops(stops_domain, min_radius, max_radius) {
 let stops = []
 let stops_len = stops_domain.length
 let count = 1
 stops_domain.forEach(function(d) {
 stops.push([d, min_radius + (count / stops_len * (max_radius - min_radius))])
 count += 1
 });
 return stops
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment