Questions tagged [turf]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
40 views

Turf.js buffer distance not accurate

I'm facing a strange behavior using buffers in Turf.js. When trying to do a 50m buffer around a point, the result is actually closer to 35m. On the screenshot below, the smaller circle is a turf....
3
votes
0answers
53 views

Turf difference function and coincident polygon boundaries [closed]

enter image description here I've been wrestling with this issue for a few days. The tool I'm creating takes one polygon and essentially minuses/subtracts another from it. A perfect use of the ...
1
vote
0answers
28 views

Trying to find percentage of overlap using turf intersect returns 'found non-noded intersection between LINESTRING'

This worked just the other day and now it's throwing an error for every call. The original code (before adding the try/catch) is this: var cbgShape = turf.polygon(shapeData.geometry.coordinates....
1
vote
1answer
69 views

Splitting a polygon by multiple linestrings leaflet and turf.js

I am trying to implement an utility for land subdivision using leaflet and turf. I am not sure if these tools are the right ones for the task. I've got it right for most of the scenarios but sometimes ...
1
vote
1answer
79 views

Do Leaflet and turfjs have different projections?

I am trying to use turfjs with leaflet for splitting a polygon by a number of linestrings(using my own algorithm that uses turf.lineIntersect()). It works most of the time ok. but sometimes produces ...
0
votes
1answer
120 views

Overlapping two line problem

I want to check if 2 linestrings intersects (or overlaps) or no. I use turf.js overlap. Here are the results I want to get: CodePen 1- If only first or last points of line 1 intersects with first ...
2
votes
2answers
518 views

Splitting A polygon into multiple polygon by multiple line strings in Leaflet and turf.js

I have need to split a polygon into multiple polygons based on the line strings drawn on the polygon. I have come across another post that splits a polygon into two based one line string. If a new ...
1
vote
1answer
91 views

turfjs cannot detect all self intersections

I am working with OpenLayers/Turfjs to detect self intersection in users manually drawn polygons on a web map. The function that detects the self intersection is a property of the condition of the ...
0
votes
0answers
29 views

Combining Multiples Linestrings into Polygon (Turf.js)

My main goal is to combine linestrings into a polygon. Is there a way to accomplish this using a library like Turf.js, or are there any geometrical rules to follow ? I Tried building the concave hull ...
1
vote
1answer
230 views

Transforming GeoJSON data to turf.polygon?

I want to transform GeoJSON multipolygon to turf.polygon for find point within polygon but it can't read property from GeoJSON. Is there any way to do that? This is my polygon data in GeoJSON: ...
1
vote
0answers
92 views

How to find point within polygon with in TURF

I want to find point within polygon with TURF, but it doesn't work. My point is geoJSON format (.geojson) My polygon is geoJSON format, too (.js) This is my code: var ranh_gioi_JS; var ...
0
votes
0answers
9 views

Changing bands color of turf.isobands?

How can I change bands color of turf.isobands? I see all the bands in blue with isolines in blue too. I don't know how to use: options.commonProperties options.breaksProperties
3
votes
1answer
269 views

Converting Entity to GeoJSON with Cesium

I know there is a way to load entities from a GeoJSON using GeoJsonDataSource but is there any way to do the opposite: get any entity as a GeoJSON representation? My goal is to use Turf.JS with ...
0
votes
1answer
51 views

Generate concentric polygons using Turf

I'm interested in trying to reproduce this kind of cartography in a Mapbox/Turf/vector tile stack: I would start with the polygon for the lake edge, and generate a series of concentric polygons ...
0
votes
0answers
131 views

Transforming Alaska and Hawaii to be next to USA with TurfJS?

I'm working on an app that contains a map; right now, the map just includes the Continental US, but it would be great if Alaska and Hawaii could be included as well. So far, I've found shapefiles ...
1
vote
0answers
9 views

Map-box layer to zoom [closed]

I have used a sector in my Geo map using turf.sector(),and using add layers() filling the sector with colors. Now how can I add zoom option to this sector.? I want it to reduce size on zooming in
1
vote
0answers
166 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
44 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
555 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
218 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
287 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
357 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
245 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
497 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
1answer
486 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
36 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][...
1
vote
1answer
2k 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
124 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 ...
3
votes
2answers
971 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
230 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
902 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
386 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
1k 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
5k 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
173 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(...
2
votes
0answers
301 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
135 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
344 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
3k 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
98 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
779 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 ...
2
votes
1answer
2k 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
490 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
716 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
56 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
339 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
159 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
915 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
619 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
3k 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', "...