Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [turf]

Turf.js is an open-source JavaScript library for spatial analysis.

0
votes
0answers
17 views

Box Select using leaflet by modifying box zoom with turf intersect

I have been trying to select multiple polygons using box select. I have modified box zoom for this purpose and included turf.js for intersect function. The problem is if i select a particular area and ...
0
votes
1answer
31 views

What do you call this combination of two district maps?

My real-world problem is that I want to combine state House and Senate legislative districts so that a user can pick a region (not a point) on a map that is included in both their House and Senate ...
0
votes
1answer
133 views

Turf intersect point with Leaflet GeoJSON error

Leaflet and Turf. I am trying find all the layers on a Leaflet map that intersect a point when the user clicks on the map. I am using the turf library to test for this. In the console when I click on ...
0
votes
1answer
23 views

How do I implement a JSON file with coordinates into a var with featurecollection? (TURF)

I am trying to use the nearest function in TURF, so what I have is a JSON file with information about parkades: { "type" : "FeatureCollection", "name" : "ubcv_parking_www", "features" : [ { ...
2
votes
1answer
84 views

Creating a rectangle using leaflet / turf.js

I have written some code which creates a rectangle at the position of the user's cursor. There does not seem to be any method to do this in turf.js itself. And of course using the latlong-based ...
1
vote
1answer
124 views

Detecting polygon self-intersection

Currently using OpenLayers to allow users to zoom/pan to an area and drop a modifiable 1x1KM Square Polygon. As this polygon is modifiable, for the purposes of validation I need to ensure the final "...
0
votes
1answer
51 views

Clip linesegment at a polygon boundary using turfjs

Having a linestring and a polygon, Is there a way to clip the linesegment at the boundary of the polygon and retain the shape of the linestring which runs inside the polygon? Example Linestring { ...
0
votes
1answer
164 views

Union GeoJSON polygons

I'm using OpenLayers and give some try on Turf.js, but with no result. I've an array with several GeoJSON string and I want to merge them all. (Below an example of just one element of my array that ...
0
votes
0answers
32 views

Generate Markers from WFS via turf.centroid() with Popups

I have successfully made a map that computes points from a WFS consisting of polygons and generates them as markers. The calculation is carried out by turf.js. However, I do not get all the properties ...
0
votes
1answer
251 views

turf.js point never found inside or within GeoJSON features loop

I have a GeoJSON http://radikal.com.mx/distrito.json and all I am trying to do is find if a turf point that has a longitude and latitude is inside or within that GeoJSON. No matter what point I use I ...
1
vote
0answers
25 views

Merge node results into one MultilineString

I'm trying to generate MultiLineStrings from street data nodes. Right now my workflow is as follows: I run something like the following through the Overpass Api, to get all the nodes: [out:json][...
0
votes
1answer
726 views

turfjs intersect line and polygon

In old turfjs versions, it was possible to intersect a line and a polygon, like in this example. But changing the turf.js version to the last one makes it fail, as shown in this other example. The ...
1
vote
0answers
75 views

Looped query rendered feature function for a set of intersect points upon a GeoJSON building layer in Mapbox GL JS

I'm currently using mapbox gl to visualise and analyse a GeoJSON layer of buildings. My current aim is to develop a function that will use the mapbox draw functionality to draw a line (using the ...
2
votes
2answers
428 views

Merge two FeatureCollections with Turf

I'm considering implementing a WFS client that, each time the map's view area is moved, fetches the features within that bounding box, and combines them with features previously fetched. Much of the ...
0
votes
1answer
138 views

TurfJS + PHP + MySQL

I have a PHP endpoint/service that receives Lat/Long data from a 3rd party. The data is then processed in PHP code and saved into a MySQL database. This process works fine without any issues. I need ...
1
vote
0answers
676 views

Show marker only in area polygon [closed]

I got task, to plot polygon on map. After finish draw only marker inside a polygon appear on map. I'm done with leaflet.draw and Draw.Event.Created. What method I can use to check which marker inside ...
2
votes
1answer
229 views

How to check if GeoJSON feature is in rectangular shape and find corner points?

I have a collection of GeoJSON features as Polygon & MultiPolygon which are saved in MongoDB. Many among them are in rectangular or square shape, while others are odd shaped. How can I find all ...
0
votes
1answer
631 views

Calculate area with OpenLayers4 and Turf.js

I've been working with OL4 for a few months now but this is the first time I try to calculate an area and after some research looks like Turf.js seems like the way to go. First, allow me to add all ...
0
votes
2answers
3k views

How to get the exact Circle that user has drawn using Leaflet.draw.Circle?

I have a simple Leaflet map, where The user can draw a Circle, using Leaflet.Draw. When you use the following code to get the geometry, map.on(L.Draw.Event.CREATED, function (event) { var ...
0
votes
0answers
125 views

Does Turf.js work with geodjango?

I am trying to do a simple buffer around a geojson I created with a model. The buffer does not show up. Here is my code. lyrStores2 = L.geoJSON.ajax("{% url 'stores' %}", { }).addTo(...
1
vote
0answers
156 views

Turf.js midpoint of line

I'd like to open a popup in on the midpoint of a polyline/linestring in Mapbox GL, like it's the default case in Leaflet. How can I do this via turf.js? If I use centroid/center/centerOfMass it will ...
1
vote
0answers
118 views

Creating polygon in turf surrounding route generated by OSRM?

I am generating a route using the osrm rendering it by leaflet, and I was trying to create a buffer automatically surrounding this route As you can see in the previous image, there are parts of ...
0
votes
1answer
218 views

Turfjs buffer + Leaflet return Uncaught _u {}

I'm trying to set a buffer with turfjs in a polygon. The polygon is loaded by L.geoJSON(); . When I execute bufferConcesion, this line var turfBuffer = turf.buffer(feature,value,{units:"kilometers"}); ...
1
vote
2answers
2k views

turf.js intersect problem?

I have two geojson data sets. One of them is polygon feature "yolbuf" and the other one is a polygon feature collection "polygon". I want to calculate intersections of every feature in polygon feature ...
0
votes
1answer
66 views

TurfJS Intersect not functioning with real coordinates the way it does with regular numbers

I have function that takes a users coordinates and tests it against a polygon. When I create the fence with whole numbers such as [3,2], [3,4],[5,6],[3,2]. My function returns correctly. I tried ...
0
votes
2answers
511 views

turf.js Invalid unit error for buffer

I have 2 geojson feature collections in leaflet. One of them is road and the other one is parcels. I want to calculate buffer for road and then intersect this buffer layer with parcels. But when I ...
1
vote
1answer
1k views

Buffer and intersect using turf.js and leaflet

I have 2 geojson feature collections in leaflet. One of them is road and the other one is parcels. I want to calculate buffer for road and then intersect this buffer layer with parcels. How can I do ...
2
votes
1answer
368 views

Turf Envelope returns 5 array coordinates for rectangle polygon

I'm trying to understand why turf.envelope() returns 5 coordinate arrays. I'd expect to see only 4. Is this normal/expected behavior? I ask because I'm currently trying to debug an issue I'm having ...
0
votes
1answer
512 views

Apply onEachFeature only on Points. Ignore LineStrings

I have a couple of GeoJSON files where each GeoJSON file contains a LineString and some Points (a LineString represents a hiking route and the points represent shelters). I would like to display the ...
1
vote
1answer
46 views

Erasing a part from a line-GeoJSON

Consider the following line (GeoJSON): { "type": "FeatureCollection", "name": "longline", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "features": [ { "type": ...
1
vote
0answers
284 views

Merging non-contiguous polygons in OpenLayers 3 / Turf.js

I need to merge polygons that are in close vicinity to each other. Consider the following screenshot: I want the user to select both polygons and then merge them when clicking on a button, so ...
1
vote
0answers
99 views

Why is the Turf Javascript library's 'transformTranslate' function distorting geometries?

I'm working on a webapp using MapBoxGL and TurfJS and I've encountered an issue using Turf's transformTranslate, which is defined here. Now, the issue is that a geometry that is being transformed is ...
1
vote
1answer
722 views

Spatial Queries in Leaflet, select polygons from (A1,A2…An) which intersect with polygon (B)

I am looking for an online solution for leaflet where I can select and export (console log, geojson, addLayer) a group of polygon from a geojson file which intersect with a drawn polygon (with leaflet ...
1
vote
0answers
517 views

Spatially join geojson point and polygon

I'm trying to join attribute values from a geojson polygon to a geojson point geometry. I'm using Terraformer.js to create a geojson from a pair of coordinates and Turf.js to do the join. The current ...
0
votes
2answers
2k views

turf js union with array of features

I am using Mapbox GL JS and querying a source on a common ID. var tempId= 55; var relatedFeatures=map.querySourceFeatures('featureSource', { sourceLayer: "sourceLayerId", filter: ['in', "...
1
vote
0answers
344 views

Calculate statistics on overlapping polygons with turf.js

In my Mapbox application, I have added draw tools to calculate the area of a polygon according to the example provided in the documentation. var draw = new MapboxDraw({ displayControlsDefault: ...
1
vote
2answers
3k views

Selecting markers within a GeoJSON polygon (Leaflet)

I have a GeoJSON FeatureCollection object made up of several polygons and I would like to select the markers which lie within each polygon. The information contained within the markers is to be used ...
0
votes
1answer
86 views

Calculating TurfJS planepoint values for a set of points / Get containing feature with TurfJS

Turf.planepoint() calculates the z value for a point that falls on the plane of a triangle. I am struggling to make this work with a tin from turf.tin() and a set of points. Is there a turf function ...
3
votes
1answer
250 views

Coordinate array to layer using cheap-ruler

I have calculated a destination from bearing/distance (feet) using cheap-ruler.js https://github.com/mapbox/cheap-ruler Console.log() returns this array from the calculation.. [-87.36328091530362, ...
1
vote
1answer
2k views

How to get coordinates of all polygon drawn on mapbox

I am new to GIS world and looking to get coordinates of the polygon drawn on mapbox map , so that i can pass the coordinates to my python program. In below program I am trying to capture all co-...
2
votes
2answers
881 views

Using Leaflet Turf.js to count number of points within buffer?

I would like to count the number of points within the buffer. The draggable marker and buffer seems to work fine but the point count within the buffer doesn't give the correct result with the console ...
1
vote
1answer
816 views

Point “inside” many polygons (leafletjs, turfjs, geojson)

I'm trying to use "inside" function of turf js and leafletjs. I've prepered the basic example with one geojson point and one polygon but I cannot do the same with more than two polygons (geojson). Any ...
1
vote
1answer
2k views

Reading through GeoJSON using Turf.js?

I have a simple app that takes a coordinate and determines what GeoJSON polygons it falls inside, then I take the polygon data and put it into a table. I have working code that uses turfjs and ...
3
votes
0answers
351 views

Maintaining Curves in Mapbox-GL

I am trying out Mapbox-gl-js as an alternative to our current openLayers 3 solution. This is primarily due to a desire to shift away from raster backgrounds and to utilize the webGL and vector tile ...
0
votes
1answer
572 views

Uncaught TypeError: o.intersection is not a function in turf.js

I'm working on a buffer analysis and then intersection using turf.js. I have a buffered output layer to which I need to intersect another polygon layer and get the output. Below is my code, ...
1
vote
2answers
707 views

Pass Leaflet Draw Marker to Turf.js point

I am trying to dynamically supply turf.point([coordinate array]) with values from leaflet.draw markers. I can only find hard coded examples for all turf examples. I hope my goal is clear here. I ...
0
votes
1answer
366 views

turf-isobands doesn't work

I am trying to use turf and turf-isobands. But it doesn't seemed to be included to turf.min.js. I downloaded turf-isobands-master. var isobands = turf.isobands(elLayer.toGeoJSON(), 'elevation', ...
0
votes
1answer
887 views

Create buffer around point with Turf

This code is not working and I don't know why? function getlatlong(b,d){ return b,d; } function buffer(feature){ var point = { type: 'Feature', geometry: { type: 'Point', ...
0
votes
1answer
406 views

Create a turf polygon from extents to check intersection with other polygons

I am storing the bbox of layers as strings, as the following string : var layerExtent='[768039.2602094524, 5772524.37609651, 2313901.7202488566, 7435794.111581946]' and I'm using this method to ...
2
votes
1answer
371 views

What is default unit of calculated area in turf.js?

Here is a good example how to calculate area in turf.js http://turfjs.org/static/docs/module-turf_area.html But what is its unit of area measurement (acre/hectare) ?