How to use the turf.intersect function in turf

To help you get started, we’ve selected a few turf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github funkeinteraktiv / cogran / lib / methods / binary-dasymetric-weighting-relative.js View on Github external
const sourceList = sourceFeatures.filter(f => {
	//console.log("f: " + Turf.area(f));
	  
	// There might be areas too tiny to be useful and they crash Turf.intersect(featureSimpl, f);
	if (Turf.area(f) < 180) {  // TODO: sinnvollen Wert (à la 1cm) für minimale Fläche finden. Mit 0.1e-10 scheint gut für wenige Testdaten Berlin
		console.log("Dropping Feature with tiny area");
		return;
	}
	  
    let intersection = Turf.intersect(featureSimpl, f);  // This crashes if f is really really small or something. 23.1.2017

    if(!isUndefined(intersection)) {
	  intersection = arealizeGeometryCollection(intersection);
      intersection.properties = f.properties;

      if(f.properties.binary !== 0) {
        intersects.push(intersection);
      }
    }

    return !isUndefined(intersection)// && f.properties.binary !== 0;
  });
github probr / probr-analysis / worker / components / location / location.foreach.js View on Github external
var derivedFrom = [];

      do {
        multiplier *= 1.05;
        circlesTooSmallForIntersection = 0;
        noOfTrueIntersections = 1;
        derivedFrom = [];

        // First intersection is just the first circle itself
        intersection = locationToCircle(locs[0], multiplier);
        derivedFrom.push(locs[0]);

        // Loop through all available locations/circles
        for(var i=1; i= 3);

      return {
        "centroid": turf.centroid(intersection),
github mapbox / tile-reduce / index.js View on Github external
tileLayer.layers.forEach(function(layer){
    layers[layer] = turf.featurecollection([]);
    if (vt && vt.layers[layer]) {
      for (var i = 0; i < vt.layers[layer].length; i++) {
        f = vt.layers[layer].feature(i).toGeoJSON(tile[0],tile[1],tile[2]);
        try {
          if (tileLayer.overzoom) {
            bbox = turf.polygon(tilebelt.tileToGeoJSON(childTile).coordinates);

            if (f.geometry.type === 'Point') {
              if (turf.inside(f, bbox)) layers[layer].features.push(f);
            } else {
              // Clip features of parent tile to child tile
              var clipped = turf.intersect(f, bbox);

              if (clipped) {
                clipped.properties = f.properties;
                layers[layer].features.push(clipped);
              }
            }
          } else {
            layers[layer].features.push(f);
          }
        } catch(e) {
          cb(e, null);
        }
      }
    }
  });
github funkeinteraktiv / cogran / lib / methods / areal-weighting-advanced.js View on Github external
const sourceList = sourceFeatures.filter(f => {
    let intersection = Turf.intersect(featureSimpl, f);

    if(!isUndefined(intersection)) {
      intersection.properties = f.properties;

      if(f.properties.binary !== 0) {
        intersects.push(intersection);
      }
    }

    return !isUndefined(intersection) && f.properties.binary !== 0;
  });
github funkeinteraktiv / cogran / lib / methods / linear-regression.js View on Github external
b.features.forEach(e => {
      const isIntersect = Turf.intersect(d, e);

      if(isIntersect && Turf.area(isIntersect) > 0) {
        isIntersect.properties = objectAssign({}, e.properties, d.properties);
        isIntersect.properties.parentArea = Turf.area(d);
        resultFeatures.push(isIntersect);
      }
    });
  });
github funkeinteraktiv / cogran / lib / methods / areal-weighting.js View on Github external
const sourceList = sourceFeatures.filter(f => {
    let intersection = Turf.intersect(featureSimpl, f);

    if(!isUndefined(intersection)) {
      intersection.properties = f.properties;

      if(f.properties.binary !== 0) {
        intersects.push(intersection);
      }
    }

    return !isUndefined(intersection) && f.properties.binary !== 0;
  });
github funkeinteraktiv / cogran / lib / methods / attribute-weighting.js View on Github external
const sourceList = sourceFeatures.filter(f => {
    let intersection = Turf.intersect(targetFeature, f);

    if(!isUndefined(intersection)) {
      intersection.properties = f.properties;

      if(f.properties.binary !== 0) {
        intersects.push(intersection);
      }
    }

    return !isUndefined(intersection) && f.properties.binary !== 0;
  });
github funkeinteraktiv / cogran / lib / methods / attribute-weighting-relative.js View on Github external
const sourceList = sourceFeatures.filter(f => {
    let intersection = Turf.intersect(targetFeature, f);

    if(!isUndefined(intersection)) {
      intersection.properties = f.properties;

      if(f.properties.binary !== 0) {
        intersects.push(intersection);
      }
    }

    return !isUndefined(intersection) && f.properties.binary !== 0;
  });
github funkeinteraktiv / cogran / lib / areal-interpolation-methods.js View on Github external
const sourceList = sourceFeatures.filter(f => {
    let intersection = Turf.intersect(featureSimpl, f);

    if(!isUndefined(intersection)) {
      intersection.properties = f.properties;

      if(f.properties.binary !== 0) {
        intersects.push(intersection);
      }
    }

    return !isUndefined(intersection) && f.properties.binary !== 0;
  });
github funkeinteraktiv / cogran / lib / methods / binary-dasymetric-weighting.js View on Github external
const sourceList = sourceFeatures.filter(f => {
    let intersection = Turf.intersect(featureSimpl, f);
	
    if(!isUndefined(intersection)) {
      intersection.properties = f.properties;

      if(f.properties.binary !== 0) {
        intersects.push(intersection);
      }
    }

    return !isUndefined(intersection) && f.properties.binary !== 0;
  });