Turf is a collection of independent Javascript modules providing common geospatial capabilites, against geometries encoded in GeoJSON format. It can be run in a Nodejs environment or included in a minified form in a script tag. It draws heavily on the JSTS (Javascript Topology Suite) library under the hood.
Questions tagged [turfjs]
289 questions
4
votes
1 answer
Geojson/ turf : merge multiple polygons to one polygon keeping hole
So I want to merge adjacent polygons in javascript this is what I actually have with my code:
I want to remove inside stroke but keep border stroke.
So I want to go from this:
To this:
I want to keep the hole for Paris - I can defined which…

user10863293
- 770
- 4
- 11
- 32
4
votes
1 answer
Show multiple great circles on mapbox with turf.js
I am trying to add multiple great circle lines between the markers in the same map container. I managed to show one with greatCircle in turf.js.
for(var i = 0; i < 2 ;i++) {
var getStart = json.features[0].geometry.coordinates[0];
var…

MDB
- 41
- 1
4
votes
1 answer
Create a buffer on polyline - Leaflet
I am trying to achieve a buffer similar to Leaflet.buffer on my map. However, Leaflet.buffer seems to be only working with Leaflet.Draw.
I am using Leaflet Editable to draw my layers and I have a polyline I would like to add a buffer to. However, I…

vtCode
- 71
- 7
4
votes
1 answer
turfjs unexpected shapes with polygon difference()
After difference() implementation for my polygon map, I find out, that when I zoom in map some unexpected shapes appear or disappear which shouldn't be there. There are MultyPolygon and Polygon type polygons and I compare them and even checking the…

BinaryTie
- 281
- 1
- 21
- 49
4
votes
0 answers
Combining multiple linestrings to a valid polygon (Turf.js)
My main goal is to combine linestrings into a polygon. The problem is that concatenating the linestrings does not produce valid polygons. The used library Turf.js does not provide clear answer.
Building the concave hull of the points also does not…

fhristov
- 41
- 3
4
votes
2 answers
How to mask/trim voronoi polygons around country?
I have mapbox map with ~2000 points and I have voronoi polygons drawn around them vith turf.js, how can set boundaries around country so polygon don't stretch all over the world? I just want to mask/trim them and keep polygons around country…

Dominik
- 121
- 9
4
votes
1 answer
Turfjs Point In Polygon always returns false
I'm using Google maps API that geolocates the user and, if they are in the city of Los Angeles, will tell them what LAPD reporting district they are in. I have a geojson overlay of the reporting districts (RD's) that's loading from here.
I want to…

Chachi_Arcola
- 159
- 1
- 2
- 11
4
votes
3 answers
Turf.js to find bounding box of data loaded with Mapbox GL JS?
I'm using Mapbox GL JS to load in GeoJSON from an external URL on some pages. I would like to automatically fit the map to the boundaries of the polygon I'm loading.
I understand that turf.js's bbox method can help with this, but I'm not sure how to…

Richard
- 62,943
- 126
- 334
- 542
4
votes
4 answers
Check if one polygon crosses another polygon in Turf.js
I'm using Turf.js for advanced geospatial analysis in my application, but can not find a method which checks if two polygons cross one another. Intersect method is not what I want, since if I have a tiny polygon and want to find polygon that crosses…

Jacobian
- 10,122
- 29
- 128
- 221
4
votes
3 answers
Outer envelope to a group of polygons
I have a GeoJson file which has multiple polygons.
Something like this.
I use Leaflet to render this GeoJson in a website.
I want to draw an outline around the polygoins that envelopes all the polygons. Something like this.
Format of GeoJSOn i am…

Shaswat Rungta
- 3,635
- 2
- 19
- 26
3
votes
0 answers
Leaflet highlight GeoJSON points within the other highlighted GeoJSON polygon
I would like to have all the points highlighted within the other highlighted GeoJSON polygon.
Next, I would like to have them displayed in the panel next to or at least in the console (for now).
The problem is, that code I provided doesn't work. I…

Geographos
- 827
- 2
- 23
- 57
3
votes
2 answers
Quickly merge many contiguous polygons in javascript
Does anyone know of a way to merge thousands of polygons that are contiguous? I've been using turf's union function to do this in my prototypes but the time it takes grows to be way too slow as the list of polygons increases. I'm hoping/aiming for a…

Matthew Whittemore
- 465
- 2
- 11
3
votes
1 answer
Can turfjs provide a coordinate transform between geo coords and application coords
I need a transform from geo coord system to/from another coord system.
I'd think the obvious way to do this would be to give the two bounding boxes of the systems.
So if I had a geo bbox, in lon/lat coords, and a non-geo bbox that corresponds to…

backspaces
- 3,802
- 6
- 34
- 58
3
votes
2 answers
Turf js drawing perfect square with center point and radius
I am trying to generate p square polygon out of center point and radius. Like below.
bboxPolygon(square(bbox(circle(_circle.center, 0.5, { steps: 64 }))))
All the function is from the turf.js
I believe that should generate perfect square or at…

fiddlest
- 1,262
- 2
- 17
- 42
3
votes
1 answer
How to add Turf.js squareGrid layer to mapbox gl?
I am new to this and trying to add a grid layer, using Mapbox GL. Would appreciate some help.
var bbox = [-95, 30 ,-85, 40];
var cellSide = 50;
var options = {units: 'miles'};
var squareGrid = turf.squareGrid(bbox, cellSide, options);

Jasmine
- 41
- 3