Questions tagged [turfjs]
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.
turfjs
300
questions
2
votes
0
answers
50
views
Trouble with correctly triangulating a polygon on a sphere in THREE.js
tldr: help I can't correctly triangulate a GeoJSON polygon in 3D space to make it spherical and it has been haunting me for weeks. The question at the end of this novel is "Is this a poly2tri ...
0
votes
0
answers
14
views
How to create Bezier curve that doesn't pass through control points
I need to create a Bezier curve with 6 points. I have 2 end points and 4 control points. When I use the turf.bezierSpline() function I get a curve that passes through all 6 points. My understanding ...
0
votes
0
answers
15
views
error when trying to display a multipolygon in react with leaflet
I have the following function
// Función para unir los polígonos superpuestos
export const unifyPolygons = (zones: Zone[]) => {
const turfPolygons = zones.map(zone =>
turf.polygon([zone....
0
votes
0
answers
87
views
geojson lat lon polygon draw smaller inner polygon
I need to write a function that takes a GeoJSON based on lat and lon values and draws polygon to 2d canvas.
In addition to that I need to add some distance and draw inner polygon where 4 sides (north,...
0
votes
0
answers
32
views
How to detect intersection / contains between two shapes?
What's is the best way in Two.js to implement shape intersection? Currently trying with turf.js like this:
import { point, polygon } from '@turf/turf';
import pointInPolygon from '@turf/boolean-point-...
0
votes
0
answers
20
views
Calculating offset for linestring's coordinates is different to point coordinate
I am trying to calculate geojson's linestring and points offset by using turf.js, but I am not getting correct results.
For example this is the geojson where the point has the same coordinate as ...
0
votes
0
answers
71
views
map.queryRenderedFeatures returns wrong polygon area on click with maplibre-gl-js, mapbox-gl-draw and turf
I'm using maplibre-gl-js with the draw plugin mapbox-gl-draw. I need to calculate the area when the user create/update polygon or the user click on the polygon.
For the click event, i'm using map....
0
votes
1
answer
35
views
is this posible to extract coastline or border line from multipolygon geojson but keep them separate
i have multipolygon cities , how to get coastline or border line that not intersect with other cities, and keep separate each cities,
is that possible? there any software or programing method (like ...
0
votes
0
answers
39
views
How to apply mask (transparent area) in mapboxGL?
I have a Map where I draw polygons for the coordinates that define the roofs:
However, I struggle to disable specific areas on the roofs by making them transparent ( the gray area ) where these ...
0
votes
1
answer
313
views
Turf.js - Type declarations not found when importing into Vue/Vite project
I use Turf.js's bbox functionality. No matter what I try, TS type definitions seem not to be found.
I tried the following:
package.json:
"dependencies": {
...
"@turf/turf": &...
1
vote
0
answers
150
views
MapLibre order fill-layer feature collection render position/z-index
In my maplibre app I render a feature-collection of polygons and display popups when a specific feature is hovered. As some polygons may overlap others I want to order them based on their size.
Only ...
0
votes
1
answer
42
views
How can I draw a sector with internal radius using Turf
I know I can draw a sector using Turf
What I need is to give another radius information, to "cut" the internal part of the sector, like the image ( consider the red polygon my goal ).
I ...
0
votes
1
answer
80
views
Trying to add a Feature of a Polygon ( square, or rectangle ) on OpenLayers with predefined width and heigth
I'm trying to programmatically add a feature with a geometry of a square or a rectangle polygon in OpenLayers with the help of turfjs to get the correct dimensions.
Giving the same width and height, ...
0
votes
1
answer
60
views
I'm trying to perform point in polygon analysis via turf, however it's consistently returning a ring undefined error
So, i'm building a react project as part of a code exercise. I've got a sheet of geojson data with various polygons defined within. I'm tasked with taking a pair of user coordinates and checking ...
0
votes
2
answers
80
views
How to add two turf.js masks together in order to get multiple holes in a single polygon
I am trying to merge two turf masks into a single polygon with turf.union. However I keep getting it to return null.
My two masks look like this:
{"type":"Feature","...