Questions tagged [turf]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
12 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
8 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
0
votes
0answers
35 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
33 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
235 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
32 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
113 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
191 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
101 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
216 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
38 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
335 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
941 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
80 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
553 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
156 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
729 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
256 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
726 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
139 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
173 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
124 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
244 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
68 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
554 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
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
395 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
565 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
52 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
296 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
118 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
762 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
545 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
358 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
106 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
260 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
923 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
879 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
358 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
604 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
728 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
386 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
927 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', ...