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

contour problems at antimeridian line #25

Closed
PBrockmann opened this issue Mar 19, 2018 · 6 comments
Closed

contour problems at antimeridian line #25

PBrockmann opened this issue Mar 19, 2018 · 6 comments

Comments

@PBrockmann
Copy link

PBrockmann commented Mar 19, 2018

Starting from GeoTIFF Contours II (https://bl.ocks.org/mbostock/83c0be21dba7602ee14982b020b12f51), I have tested direct reading from netCDF files (the standard of all Climate Models from IPCC and all Earth System Modeling community). See https://github.com/PBrockmann/D3_netcdfjs and try netcdfjs_05.html

It sounds very promissing. So a great great thank for this d3.contour module !
In my dreams, I would also like to get a raster pixels rendering as in http://geoexamples.com/d3-raster-tools-docs/code_samples/raster-pixels-page.html but that is another story. Is there an official d3 to do that BTW ?

The problem with d3.countour in a geo context is that some contours at antemeridian line are shifted either up or down.
See:
image
The map get from netcdfjs_05.html is zoomable so the problem can clearly be seen.

I haven't been able to find where this shift comes from ?

Any help welcomed on this topic that could help a huge community.

@PBrockmann PBrockmann changed the title contours problems at antimeridian contour problems at antimeridian Mar 19, 2018
@PBrockmann PBrockmann changed the title contour problems at antimeridian contour problems at antimeridian line Mar 19, 2018
@mbostock
Copy link
Member

mbostock commented Mar 19, 2018

My guess is that the shift comes from beveling at the edges #4 because the contour algorithm must contain the polygon with the grid. In GeoTIFF Contours II, I map x = [0, n] in the source raster to [-180, +180]. Is it possible you’re mapping from x = [0, n - 1] instead?

@PBrockmann
Copy link
Author

PBrockmann commented Mar 19, 2018

No I don't think so and moreover I have also noticed the problem directly from the GeoTIFF Contours II example.
See d3_contours_01.html in my repository that is a copy of this example and rotate the projection to see the problem.
Thank for your interest in this issue.

I have just updated my repo because a file was missing to test the netcdfjs_05.html

@PBrockmann
Copy link
Author

PBrockmann commented Mar 19, 2018

Here is a capture from your GeoTIFF Contours II example with contours set with
var contours = d3.contours().thresholds(d3.range(-0, 40, 1)).size([n, m]);
Here zoomed on contours where the problem occurs ie lines have oddly unsmooth path.

@PBrockmann
Copy link
Author

PBrockmann commented Mar 26, 2018

Try to analyze this problem. The geoStitch algorithm does correct the fact that the 2 polygons are separated by the antimeridian line and should be considered as one unique polygon but it leaves 2 small up and down stitches that should not be there.

A solution could be to run d3-contour with duplicates columns at start and end of the array but my tries are not successfull for now.

@Fil
Copy link
Member

Fil commented Mar 30, 2018

capture d ecran 2018-03-31 a 00 32 05

my solution is to remove the shared points from the stitched polygons
PBrockmann/D3_netcdfjs#1

@mbostock
Copy link
Member

Updated example: https://observablehq.com/@d3/geotiff-contours-ii

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

No branches or pull requests

3 participants