Hot answers tagged

11 votes
Accepted

Splitting a polygon by multiple linestrings leaflet and turf.js

Solution below is not direct answer to the question, it's just improved version of answer to similar question Splitting A polygon into multiple polygon by multiple line strings in Leaflet and turf.js, ...
user avatar
  • 17.9k
10 votes

Turf.js only with Mapbox.js?

Turf.js is not dependent on Mapbox.js or access token. I was initially confused with the documentation, I think, but it works fine with plain leaflet.js.
user avatar
  • 1,344
9 votes

mapping over a million points using QGIS

I would recommend using PostgreSQL/PostGIS, since it is natively supported by QGIS, has some handy built-in functions to join with other spatial data (like census tracts), and the use of a database ...
user avatar
  • 3,247
8 votes
Accepted

How to check for geometry intersection (point in polygon) using OpenLayers3?

OL3 does not support polygon intersection natively, but you can use the turf.js library, which seems to be rapidly growing in popularity and functionality. Under the hood all geometries in turf.js ...
user avatar
  • 13.3k
7 votes

Running turf.js on desktop?

Since you are a beginner at Node, I'll try to give you a step by step answer Firstly you need to install Node on your system. The exact steps will depend on your Operating system, and version, but it'...
user avatar
6 votes

Turf.js only with Mapbox.js?

Turf has no visualization dependencies at all. It does not require any map display, and works with raw GeoJSON data. For example, I often use Turf on my desktop (via Node.js) for running analysis that ...
user avatar
6 votes
Accepted

Turf Envelope returns 5 array coordinates for rectangle polygon

It is returning a polygon which must have the start and end point the same to close the polygon.
user avatar
  • 75.5k
5 votes
Accepted

Closest point on 5km line

The >0 distance returned by the query is actually correct. Let's remember that when using the type geometry, distances are computed using a straight line while with the type geography, the great ...
user avatar
  • 35.3k
4 votes

How can obtain geojson geometry ? OL3

You don't provide the "right" content to Turf (your geom is not the expected content for Turf) feats = select2.getFeatures(); var geojson = new ol.format.GeoJSON(); as_geojson = geojson....
user avatar
  • 28.9k
4 votes
Accepted

Converting Mapbox Vector Tiles To GeoJSON

I think you're out of luck, there is no third option. I cannot claim this with 100% certainty, but I'm at the moment doing an extensive research about vector tiling, and in short MapBox vector tiles ...
user avatar
  • 334
4 votes

How to check for geometry intersection (point in polygon) using OpenLayers3?

@JohnBarça Just a note, while turf.intersect(polygon, point) does seem to work, it was pointed out to me that turf.inside(point, polygon) is the proper function to use, for checking that a point is ...
user avatar
  • 269
4 votes
Accepted

Turf.js Check if polygon "Contains" another polygon

You should be able to use the turf/boolean-contains module, noting that this only returns a true or false answer. Hope that helps
user avatar
  • 391
4 votes
Accepted

How to check if GeoJSON feature is in rectangular shape and find corner points?

You could sum up angles. If you want to stick to Turf.js, try function isRectangle(turfInputPolygon, threshold) { var threshold = threshold || 2; var turfPolygon = turfInputPolygon; if (turf....
user avatar
  • 24.6k
4 votes
Accepted

Converting Entity to GeoJSON with Cesium

Here you have a solution to export to json and for export it to kml. Everything is obtained from this official thread of Cesium. They are links that talk about the question and there isn't method to ...
user avatar
  • 7,285
4 votes
Accepted

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

Update: See improved split method here: Splitting a polygon by multiple linestrings leaflet and turf.js Code mentioned in the question was produced as kind of a proof of concept that polygons can be ...
user avatar
  • 17.9k
4 votes

Turf.js buffer distance not accurate

Simple experiment show it's really question of projection. If you take coordinate [0, 0] as center of the circle and buffer, they match. If you calculate factor for diameter difference betwee buffer ...
user avatar
  • 17.9k
3 votes

mapping over a million points using QGIS

I recently worked with a dataset of 1.4 million points imported from a CSV. I made sure to delete any irrelevant fields in the csv. It worked fine for me, even though some processes took a bit of time ...
user avatar
  • 8,262
3 votes

Adding turf.js polygons from shapefiles?

You can convert shapfiles to geojson using shapefile-js library or other similar libraries, in the browser without making any server calls. then use that geojson data with Turf.js
user avatar
  • 4,500
3 votes

How to check for geometry intersection (point in polygon) using OpenLayers3?

The logic here would be to first buffer the line upto the given width, and do a simple intersection query. Both these operations require some topology and geometry operations, and can be done either ...
user avatar
3 votes

turf js union with array of features

Your approach of iterating over each feature is a valid approach. According to http://turfjs.org/docs/#union union doesn't accept an array of features instead each feature must be an argument to ...
user avatar
  • 2,093
3 votes

Buffer and intersect using turf.js and leaflet

Try something like this. var buffered = turf.buffer(road.toGeoJSON(), road.width, {units: 'meters'}); var roadbuf = L.polygon(buffered, {style:myStyle}).addTo(mymap); A Leaflet layer is not quite ...
user avatar
3 votes

turf.js intersect problem?

Your buffer distance was too small to touch a parcel boundary; This is your code working: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</...
user avatar
3 votes

Transforming GeoJSON data to turf.polygon?

There are several things that are wrong here: Syntax of coordinates definition in GeoJSON is not OK, but I suppose that just because of copying for question. features property of GeoJSON is an array, ...
user avatar
  • 17.9k
3 votes
Accepted

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

This is going to be step-by-step answer. turf.squareGrid method will be used for grid creation since turf.rectangleGrid is fairly new and I couldn't find corresponding turf.min.js library. First ...
user avatar
  • 17.9k
2 votes

Intersecting FeatureCollections in turf.js?

I use the following code to find the intersection between two networks as polylines, I turn them in GeoJSON and then calculate the intersections with turf, iterating every feature of the collection. ...
user avatar
2 votes

mapping over a million points using QGIS

An R candidate fwiw, in pseudocode: library(rgdal) ## for spatial export library(readr) ## for fast file read x <- read_csv("file.csv") names(x) ## some as yet unknown columns coordinates(x) &...
user avatar
  • 7,907
2 votes

OL3 GeoJSON vs. turf GeoJSON

Turf follows the GeoJSON specification. One aspect of this specification is that geometries should use WGS 84 coordinates. Each coordinate should look like: [longitude, latitude]. Your sample data is ...
user avatar
2 votes

What is default unit of calculated area in turf.js?

Looks like square meters based on your link. Unless that's not what you're looking for.
user avatar
  • 1,344
2 votes
Accepted

Pass Leaflet Draw Marker to Turf.js point

You can grab the marker's coordinates from the draw:created event like this: e.layer._latlng You can then pass these coordinates to your Turf.js function like this: map.on('draw:created', function (...
user avatar
  • 2,575
2 votes
Accepted

Reading through GeoJSON using Turf.js?

Got it, create a JS object and load it with features from the GeoJSON file. Next loop through the object passing it through the turf function inside. var cluster = []; var features=[]; var point1 = ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible