toMercator changes polygons geometry
See original GitHub issueWhen using toMercator on a polygon that overlap the -180 or 180 longitude, without antimeridian cutting.
The current implementation wraps every point one by one which ends up returning a wrong polygon:
Here is a polygon overlapping the -180 longitude:
- https://gist.github.com/Darune/d73952fbe586d1e8116d6e779042ccb3
Here is the result of a
toMercator
transformation reconverted usingtoWgs84
: - https://gist.github.com/Darune/dbd604f5b697cbbd36b918acab2dea94
code to reproduce the issue:
import { toWgs84, toMercator } from '@turf/projection';
toWgs84(toMercator({
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-181, 60],
[-181, 61],
[-179, 61],
[-179, 60],
[-181, 60]
]]
}
}));
I think that when calling toMercator
with a GeoJson, turf should not try to wrap longitude as it does.
if this is an acceptable behavior I could submit a PR
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
r - st_transform appears to change the area of the geometry of ...
No, the area of polygons is not guaranteed to remain constant when transforming between different CRSes. The Earth is round, maps & computer ......
Read more >Solved: Detect Feature Changes for Polygons and Points
Is there any tool for detect feature changes (only geometry) for POINT and POLYGON features? Many thanks in advance ! Solved!
Read more >Managing Projections — GeoPandas 0.12.2+0.gefcb367.dirty ...
The Coordinate Reference System (CRS) is important because the geometric shapes ... Re-projecting is the process of changing the representation of locations ...
Read more >Advanced geospatial analysis - Turf.js
Feature <Polygon> - a Polygon representation of the bounding box ... cleanCoords. Removes redundant coordinates from any GeoJSON Geometry.
Read more >Why does polygon area change when projection is changed ...
Some differences between the two features may be due to the geometry of the input feature. If the feature is built with two-point...
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 could retry writing tests for this, it has been stalled for way too long, but I might have time next week to digg this out of the dirt
Yeah unfortunately the tests and the code are currently setup to run against individual coordinates rather than seeing them in context of a geometry that is crossing the anti-median, so a bit of thought needs to happen to get things behaving and tested properly.