Handling negative buffer with NaN coordinates
See original GitHub issueBased on https://github.com/Turfjs/turf/pull/736#issuecomment-301937747, I wanted to add this morphological closing behavior to the test cases, however I noticed when entering a radius
which is greater than the polygon, the geometry’s coordinates will result in NaN
values.
Question: Is this expected output correct? Or should we return undefined
or an empty FeatureCollection
?
Example
https://jsfiddle.net/pvLx12n1/
const poly = turf.polygon([[[11, 0], [22, 4], [31, 0], [31, 11], [21, 15], [11, 11], [11, 0]]]);
turf.buffer(poly, -500, 'miles').geometry.coordinates;
//=[ [ NaN, NaN ] ]
Output Geometry
Seems like this output would be an invalid GeoJSON Polygon
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[null, null]]
}
}
CC: @rafaelalmeida
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Shapely Documentation - Read the Docs
Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects. It is using.
Read more >The Shapely User Manual — Shapely 2.0.0 documentation
Shapely is a Python package for set-theoretic analysis and manipulation of planar ... this manual will make a distinction between constructive ( buffer...
Read more >Buffer (Analysis)—ArcGIS Pro | Documentation
ArcGIS geoprocessing tool that creates buffer polygons around input features to a specified distance.
Read more >Metal Shading Language Specification - Apple Developer
A vertex shader generates positions in clip-space coordinates. ... Texture buffers handle type conversion more efficiently than other ...
Read more >Spatial Data — Geographic Data Science with Python
In xarray , these indices are called coordinates, and they can be ... in surfaces not as a class of its own (e.g.,...
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 Free
Top 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
Agreed. If there’s an easy mechanism to return error details along with response, maybe it could be used if the cost to implement is low enough. Otherwise, a quick note in the docs would suffice, like:
“When using a negative radius, the resulting geometry may be invalid if it’s too small compared to the radius magnitude. If the input is a FeatureCollection, only valid members will be returned in the output FeatureCollection - i.e., the output collection may have fewer members than the input, or even be empty.”
While this does not say exactly what failed, should give devs a hint on where to look.
On Thu, May 18, 2017 at 2:37 PM, Denis notifications@github.com wrote:
Yes, if a feature collection of 2 polygons is the input and only 1 of them has valid geometry, then the FeatureCollection will only contain 1 polygon.
Returning a “bad” geometry would most likely cause things to break by having
NaN
in the coordinates.