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

Isoline from example returning MultiLineString with no coordinates #829

Closed
bakerac4 opened this issue Jul 6, 2017 · 7 comments
Closed
Assignees
Labels

Comments

@bakerac4
Copy link

bakerac4 commented Jul 6, 2017

Following the example found at http://turfjs.org/docs/#isolines after downloading the minified turf.js file and including it in my project ends up giving me 10 features that each have 1 geometry object inside, with type MultiLineString that has an empty array of coordinates.

Here is a GIST of the GeoJSON I am getting back
https://gist.github.com/bakerac4/89656a65e7388b290d223facdaf5dc75

The code I am using seems to be a copy and paste from the docs.

var points = turf.random('point', 100, {
  bbox: [0, 30, 20, 50]
});
for (var i = 0; i < points.features.length; i++) {
  points.features[i].properties.temperature = Math.random() * 10;
}
var breaks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var isolines = turf.isolines(points, breaks, 'temperature');
@DenisCarriere
Copy link
Member

Huh... interesting.

Also getting the same result:

//= isoloines.features[0]
{ type: 'Feature',
  properties: { temperature: 1 },
  geometry: { type: 'MultiLineString', coordinates: [] } }

Thoughts? @stebogit

@stebogit
Copy link
Collaborator

stebogit commented Jul 7, 2017

@bakerac4 turf-isolines (like turf-isobands) expects a pointGrid as input, which will be internally converter into a matrix (Array<Array<number>>) of zProperty values to be able to calculate the isolines. With just random points there is no matrix (that's why a @turf/interpolate module has been desirable for long time).
If you have though a matrix and you want to convert it into a pointGrid you could use matrix-to-grid.

I'm surprised (and sorry) the documentation have not been correctly updated when the module was re-implemented, I'll commit the appropriate correction.

@stebogit stebogit self-assigned this Jul 7, 2017
@stebogit stebogit added docs and removed bug labels Jul 7, 2017
@stebogit
Copy link
Collaborator

stebogit commented Jul 7, 2017

Done. I did also fix a small bug in isobands and made sure also its example was working.
@DenisCarriere how can I update also the API website?

@bakerac4
Copy link
Author

bakerac4 commented Jul 7, 2017

Thank you @stebogit for clearing that up. That leaves me a bit confused (and Im sure its just me misunderstanding something). Does pointGrid create a grid of points that are always evenly spaced out?

Im trying to create a isoline heatmap like this but I am being given a list of objects (with lat, lng and temp). From what Im gathering, since turf/interpolate doesn't actually exist yet Im out of luck?

Thanks again for your help !

@stebogit
Copy link
Collaborator

stebogit commented Jul 7, 2017

Does pointGrid create a grid of points that are always evenly spaced out?

Yes @bakerac4, this is an example of pointGrid output
screen shot 2017-07-07 at 7 37 06 am

I'm trying to create a isoline heatmap like this

You might want to take a look at @turf/isobands then, it's probably what you need as it created the contour polygons instead of just the isolines.

I'm out of luck?

Look at @turf/idw, it might give you some hints on how to generate a pointGrid.

@DenisCarriere
Copy link
Member

DenisCarriere commented Jul 7, 2017

@bakerac4 interpolation operations with TurfJS can be significantly improved, like @stebogit was mentioning, you might have a better result using one of these TurfJS libraries:

@Ir001
Copy link

Ir001 commented Nov 6, 2023

Screenshot 2023-11-06 114847
Im using isobands for creating contour. If i using Math.random() for zProperty value its work
Screenshot 2023-11-06 114725
,but if i use real data isoband returning MultiPolygon with empty coordinates.
Screenshot 2023-11-06 115157

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

No branches or pull requests

4 participants