Questions tagged [turf]

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

Filter by
Sorted by
Tagged with
2
votes
0answers
36 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
30 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
45 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
48 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
32 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
13 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
38 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
29 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
98 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
92 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
122 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
146 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
387 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
25 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?
1
vote
1answer
121 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 ...
0
votes
0answers
37 views

Getting the sum of features for points inside a polygon in Mapbox

I am new to Mapbox and am currently stuck with a problem. After generating an Isochrone polygon, I wanted to find all the points and the total population associated that fall in that polygon. Turf ...
3
votes
1answer
481 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
213 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
171 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
1k 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
490 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
317 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
3k 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
373 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 ...
1
vote
1answer
1k 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
245 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
637 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
96 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
397 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
10 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
315 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
54 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
1k 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
587 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
518 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
734 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 "...
1
vote
1answer
532 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
2k 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
732 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
43 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
2answers
3k 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
250 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 ...
4
votes
2answers
2k 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
364 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 ...
2
votes
0answers
1k 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
726 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
2k 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
9k 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
220 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
590 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 ...