Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turf buffer buffer distance slightly off #801

Closed
mclaeysb opened this issue Jun 18, 2017 · 14 comments
Closed

Turf buffer buffer distance slightly off #801

mclaeysb opened this issue Jun 18, 2017 · 14 comments

Comments

@mclaeysb
Copy link

Buffering points creates circles with the required radius, but buffering polygons seems to create buffers with a wrong radius. Here's an example on a very small polygon, buffered with radius 1 miles:

screen shot 2017-06-18 at 18 45 16

Radius of @turf/buffer output is to small

screen shot 2017-06-18 at 18 45 12

Buffer with correct radius

Inner object made with @turf/buffer, outer object made with this old PR of turf-buffer (but same can be made using @turf/destination).

I used this data as input.

Not sure what this is due to..

@mclaeysb
Copy link
Author

Judging from the initial picture in #786, it seems like this might be related to that issue..

@DenisCarriere
Copy link
Member

Definitely looks like there's a bug somewhere... looks like it might be the reprojection.

@songololo
Copy link

songololo commented Aug 14, 2017

I'm running into the same issue:

let p1 = point([-0.12, 51.2])
let p2 = point([-0.13, 51.8])
let l1 = lineString([[-0.12, 51.2], [-0.13, 51.8]])
let d1 = lineDistance(l1, 'kilometers')
console.log('distance 1: ' + d1)
// distance 1: 66.74149167617327
let b = buffer(p1, d1, 'kilometers')
let e1 = envelope(b)
let l2 = lineString([e1.geometry.coordinates[0][0], e1.geometry.coordinates[0][1]])
let d2 = lineDistance(l2, 'kilometers')
console.log('distance 2: ' + d2 / 2)
// distance 2: 58.858493793982554
let c = circle(p1, d1, 64, 'kilometers')
let e2 = envelope(c)
let l3 = lineString([e2.geometry.coordinates[0][0], e2.geometry.coordinates[0][1]])
let d3 = lineDistance(l3, 'kilometers')
console.log('distance horizontal 3: ' + d3 / 2)
// distance horizontal 3: 67.60143597789236
let l4 = lineString([e2.geometry.coordinates[0][1], e2.geometry.coordinates[0][2]])
let d4 = lineDistance(l4, 'kilometers')
console.log('distance vertical 3: ' + d4 / 2)
// distance vertical 3: 66.74149167617331

EDIT: Corrected variable reference for e2 from b to c -> circles appear good for vertical measurements but off for horizontal measurements per @stebogit comment

@stebogit
Copy link
Collaborator

@Shongololo it seems actually that d2 and d3 are equals in your example because e1 and e2 are both "enveloping" b.
@turf/circle doesn't seem to have issues.
screen shot 2017-08-14 at 11 15 02 pm

Also, you might want to measure the vertical side of the envelop (lineString([e2.geometry.coordinates[0][1], e2.geometry.coordinates[0][2]])) to compare with the vertical radius of the circle (lineString([[-0.12, 51.2], [-0.13, 51.8]])), because the projection does cause some small difference (see #684).

DenisCarriere added a commit that referenced this issue Sep 1, 2017
@DenisCarriere DenisCarriere modified the milestones: 4.8.0, 4.7.0 Sep 4, 2017
@songololo
Copy link

songololo commented Sep 4, 2017

@stebogit thanks, corrected the typo, circles now are good for vertical though still off for horizontal distances per discussion #684 in your comment.

@stebogit
Copy link
Collaborator

stebogit commented Sep 4, 2017

👍

@DenisCarriere DenisCarriere modified the milestones: 4.8.0, 5.1.0 Sep 29, 2017
@jaapster
Copy link

jaapster commented Nov 6, 2017

How do you guys get this circle? Turf returns an oval when I use buffer.

@DenisCarriere
Copy link
Member

Which version of turf are you using?

@jaapster
Copy link

jaapster commented Nov 6, 2017

@DenisCarriere package.json version is 3.14.3

I'll try updating to the latest version

@DenisCarriere
Copy link
Member

Yep that will help, I think the buffet got fixed in 4.5 or so

@jaapster
Copy link

jaapster commented Nov 7, 2017

@DenisCarriere Yes, that solved it, thanks!

@DenisCarriere DenisCarriere modified the milestones: 5.1.0, 5.2.0 Nov 21, 2017
@omar-alnayme
Copy link

Hi, where to get the latest version of turf?

@omar-alnayme
Copy link

I get the oval buffer as well.

@smallsaucepan
Copy link
Member

This looks suspiciously like a duplicate of #1470. Closing given it's age and similarities. If still an issue on later versions of Turf please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants