turf.lineOffset precision
See original GitHub issueHello, I’m using line offset to build parallels to short segments (a few kilometers long) but I found an issue with the precision of the function:
const turf = require('@turf/turf')
const line = turf.lineString([ [4.35,50.845], [4.347,50.85] ])
const parallel = turf.lineOffset(line, 1) // kilometer
const distance0 = turf.distance(line.geometry.coordinates[0], parallel.geometry.coordinates[0])
const distance1 = turf.distance(line.geometry.coordinates[1], parallel.geometry.coordinates[1])
console.log(distance0, distance1)
// output: 0.7468818837096454 0.7468398187109684
This can be reproduced at other places in the world. Any idea on how to improve precision? Thanks.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Advanced geospatial analysis - Turf.js
Takes a GeoJSON Feature or FeatureCollection and truncates the precision of the ... will need to import @turf/line-offset and call the lineOffset method....
Read more >@turf/line-offset - npm
@turf/line-offset. TypeScript icon, indicating that this package has built-in type declarations · Readme · Code Beta · 3 Dependencies · 8 Dependents ...
Read more >@turf/line-offset | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Turfjs/turf - Gitter
This definition is listed in a few places, and I think it is a good (reasonably precise) description: "A buffer is an area...
Read more >Top 5 @turf/invariant Code Examples - Snyk
Learn more about how to use @turf/invariant, based on @turf/invariant code examples ... {precision: 7}); switch (splitterType) { case 'Point': return ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I made a PR for this: https://github.com/Turfjs/turf/pull/1949 But couldn’t get my env going, so it’s untested.
To be honnest, I redid the function I needed, it is quite easy: For line (p1, p2), compute the bearing p1->p2. Add or substract 90° to the bearing. Use “destination” function to compute a point with calculated bearing and supplied distance from p1 and from p2. I understand this might not be a “parallel” in spherical geometry, but for short segments (a dozen kilometer long), it is acceptable. I will not work for larger segments. Regards. P.