Questions tagged [turf]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
24 views

lineString will not appear on Mapbox map

I'm trying to show an updating trailing line (path of movement) on my mapbox map, but it doesn't seem to be appearing. My updating lng/lat array is coming up correctly when tested in the console, so I ...
0
votes
1answer
23 views

Turf.js length gives incorrect result

I'm trying to calculate the distance between 2 points given by GPS coordinates using the turf.js library. My code looks like this: const s1 = { lat: 48.60538779779193, lng: 18.887075288025212 }...
0
votes
0answers
43 views

Why do I get a circle when I try to buffer a squared polygon with turf.js?

I have created the following node.js code with turf.js: const turf = require('@turf/turf') let polygon = [ [ [ -46.70527960466082, -23.515693805007327 ], [ -46.70525061354379, -23....
0
votes
1answer
46 views

Leaflet Turf.buffer projection

I successfully created a buffer on Leaflet with Turf.JS . I had to change the map CRS to WGS84 (epsg:4326) to make it work. But the problem is that I need to go back to the default CRS of Leaflet ...
0
votes
1answer
57 views

Custom sized buffer , Turf.js and Leaflet Draw

I'm looking forward to buffering an object drawed with Leaflet Draw , and with a custom width in kilometers in a div. First Name: <input type="text" id="myText" value="...
-1
votes
1answer
53 views

Difference between interpolated map using IDW in ArcGIS and turfjs

I did the interpolation from the same map using arcgis and the turf.js library, using the same parameters and points. Could anyone say why the difference? ArcGIS params ArcGIS Map Turf.js params ...
1
vote
0answers
60 views

How to convert a multipolygon to multiple single polygons

I have a polygon clipping function in my OpenLayers app which may return me a multipolygon. Unfortunately, my app does not support multipolygons by design. So I need to convert a multipolygon to ...
0
votes
1answer
86 views

Splitting / Highlighting area in filled in turf polygon in leaflet.js based on input 1-100%

In my previous questions, how to split a polygon into rectangles of a specific length, this is the code i arrived at in the end with the help of a fellow programmer. Splitting polygon with turf....
1
vote
1answer
141 views

Splitting polygon with turf.rectangleGrid in vue.js Leaflet map

The turf.rectangleGrid function from turf.js (https://www.npmjs.com/package/@turf/rectangle-grid) makes rectangles inside a bbox, but I want them in a polygon. The options take in a mask: Polygon not ...
4
votes
2answers
342 views

Closest point on 5km line

Given a point and a line, I am trying to determine the point on the line that is closest to the given point. The given point is always at least fairly close to the line (3-4 meters max) Originally I ...
3
votes
0answers
108 views

Smart way of finding the polygon intersection of a huge GeoJSON file with a small GeoJSON file without looping through all polygons

I have a huge GeoJSON file (over 300MB) which has multiple different polygons. Also, I have a very small GeoJSON file with only one polygon that doesn't have more than ten points. Using the ...
0
votes
0answers
23 views

Intersection with turf.js [duplicate]

This is my full code for intersection of a drawn line with polygon feature class. I am not getting any error on console neither getting the required output. What is the problem with my code? Here is ...
1
vote
0answers
23 views

Intersection using turf js [duplicate]

I am giving this for intersection of a polyline using Leaflet draw plugin with polygons feature class. Here is my code function intersectPolyByPolyFC(poly,fcPoly){ var fgp=[];//variable for ...
1
vote
1answer
44 views

Plotting polygon with hole as two separate polygons using Leaflet

I've a polygon with a hole which I created using turf.difference method. Now, I need to plot that GeoJSON on another screen and make both the inner polygon as well as outer polygon editable. Since I'm ...
2
votes
0answers
226 views

Polygon intersection using turf js

I have given this code for intersection: function intersectPolyByPolyFC(poly,fcPoly){ var fgp=[];//variable for feature group var bbPoly=turf.bboxPolygon(turf.bbox(poly));//polygon ...
1
vote
0answers
19 views

Spheroid distance to sphere distance

I have linestring that is calculated on a spheroid. Shpere distance of where the point should be on the linestring Distance spheroid / sphare. On one lib, its all calculated in spheroid (Normal map)....
0
votes
0answers
40 views

Returning polygon attributes intersecting a buffer

I am trying to return attributes of polygons (from the SAC feature) that intersect the buffer created around the route, but I keep getting: Uncaught Error: geojson must be a valid Feature or Geometry ...
1
vote
0answers
67 views

Find nearest boundary of inner feature (Turf.js)

Imagine a GeoJSON FeatureCollection that contains a boundary and a feature. The feature should be thought of as a Building and the boundary as a plot of land. When rendered this shows the follow https:...
1
vote
1answer
289 views

Add polygon (buffered line) created by turf.js to map in Leaflet?

I am trying to create a buffered line layer by creating GeoJSON line string from routing line and buffering it with turf.js and then show it on the map. Here is my code: route.on('routeselected', ...
0
votes
1answer
223 views

Calculate Rhumb-bearing applicable for showing directly pointing arrow in EPSG:3067?

In short: A pointer from one point towards another, angle calculated with any Bearing tool / formula in hand, did not show correctly, but some degrees wrong. Calculate made in lat / lon values and ...
0
votes
1answer
43 views

How to contract geojson polygon

I'd like to convert the big red area to a smaller one (blue) by shifting their borders parallelly by a certain distance to inner direction. This is not equivalent to scale as the result shape will ...
2
votes
0answers
48 views

How to get a segment between two points

I have a map made of two layers, the first is a list of trails (path) and the second is a point based layer (different intersection between the trails). I am looking for a way to select a segment ...
2
votes
1answer
128 views

How to intersect more than 2 polygons using Turf.js?

We use Mapbox GL JS 1.12.0 in our Vue.js project. I need to create intersection objects if I have 2 or more polygons. But, I'm able to do it with 2 polygons only. The code looks as following: import * ...
1
vote
1answer
164 views

Combine multiple points to polygons by property

I'm working on a website with a Cesium map, and I'm using turf.js for geo calculations. I need to find a way to merge a large set of points on the map (with a fixed distance between them) to polygons, ...
1
vote
1answer
206 views

Create a rectangle with specific height from two points

I need to be able to create a rectangle with height x from two points. This is probably not clear enough so I tried to draw it: The two points that I have are the centroids of those circles, and what ...
1
vote
0answers
49 views

Determine if two geometries are similar in shape and location

Suppose I have two geometries that have almost identical location and shape. I say almost on purpose here, since one or the other might have an extra node, or the order of coordinates in GeoJSON might ...
0
votes
0answers
32 views

@turf/boolean-contains reports false, even though one geometry is fully contained in another

I have the following FeatureCollection: { "type": "FeatureCollection", "features": [ { "id": 47306, "type": "Feature", ...
1
vote
1answer
84 views

Finding node on polyline immediately after given point using Turf

I have 2 polylines, A and B. My objective is to Find closest point on B from a given node on A Find tangent on that point So I use function nearestPointOnLine to find point on B closest to a node on ...
3
votes
1answer
89 views

Python shapely unary_union in JavaScript

I have seen turf.js has union() but this isn't equal to the unary_union. Or does anyone know what the unary_union actually does? Maybe I can try to recreate it, I have seen the source code in python ...
1
vote
1answer
399 views

OpenLayers drawing curves

I'm trying to draw a Bezier curve in OpenLayers (geometryFunction2) but there is something wrong with my approach I don't get. The first line seems fine but I can't place the next one. It work's fine ...
1
vote
1answer
230 views

TurfJS dissolve not working as expected

Why are these two overlapping polygons not dissolving? I would expect the smaller polygon to dissolve into the larger but instead two individual features remain. See fiddle for code example. http://...
0
votes
1answer
302 views

Detecting line intersections between MultiPolygon and LineString in Turf.js

I am trying to write a section of JavaScript code that allows a user to analyse a route they have plotted on a map. After the user has finished plotting their route, I want to determine if the route ...
1
vote
1answer
334 views

Leaflet GeoJSON Polygon Label Remaining in Frame when Zooming

I have a polygon layer being loaded into Leaflet in GeoJson format. When using the code below I'm able to get labels for each feature to appear at the center but they remain fixed there. I'd like for ...
3
votes
1answer
999 views

Turf intersect doesn't always work with polygons

I have a GeoJSON of two obvious colliding polygons but turf.intersect doesn't seem to detect it. Here the GeoJSON: { "type": "FeatureCollection", "name": "invalid_import", "features": [ ...
1
vote
0answers
44 views

Method to determine of coordinates in GeoJSON feature are Lat/Lng or UTM?

Is there a @turf or any other helper method to quickly determine if coordinates in GeoJSON feature are Lat/Lng or UTM?
2
votes
1answer
268 views

How to perform spatial computation in a Mercator projection in turf?

TL;DR: Spatial computation with turfjs does not work well in a EPSG:3857 map. In a OpenLayers map, I use turf for transforming a line into a polygon by computing the offset line (aka side-buffer for ...
3
votes
1answer
786 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....
2
votes
0answers
341 views

Turf difference function and coincident polygon boundaries [closed]

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 difference command in Turf. ...
1
vote
0answers
271 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
2k 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 ...
2
votes
1answer
949 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
493 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 ...
3
votes
2answers
4k 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
628 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 ...
3
votes
1answer
2k 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
298 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 ...
4
votes
1answer
940 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
137 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
543 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
13 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