-
Notifications
You must be signed in to change notification settings - Fork 62
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
Support curvilinear grids #64
Comments
Have you tried https://github.com/Fil/d3-tricontour instead? |
I have tried it and it works quite well - I just read that marching squares is more efficient and the contouring is slightly better. Also, I'm porting some logic from matplotlib, which uses the marching squares contouring algorithm and does support curvilinear grids. Comparing |
There's no built-in support for curvilinear grids, so I guess it's just a matter of finding an efficient way to compute the projection back to the original coordinates system. |
Okay thanks. Generally speaking, is it possible to calculate polygons using x/y values that correspond to value positions instead of numeric grid positions? (or in the case of matplotlib is the library just interpolating the result) |
I've made this notebook with a projection that uses bilinear interpolation on the grid: https://observablehq.com/@recifs/contours-on-a-curvilinear-grid If you want to share a dataset I'd be happy to try it. |
My grid looks like this: You can download data from this endpoint: curl 'https://somisana.ac.za/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://somisana.ac.za' --data-binary '{"query":"{\n data(timeStep:120 runId:8 depth:0) {\n id,\n json\n }\n}"}' --compressed > data-issue-64.json The endpoint may disappear/change/etc but if it's helpful you are welcome to use the image and data in an example. The format of the data is: {
data: {
{
id: "...",
json: [
[lng, lat, temperature],
[lng, lat, temperature],
[lng, lat, temperature],
etc
]
}
}
} (It's sea-surface temperature as output from a run of the Coastal and Regional Ocean Community model) |
Thank you very much for the notebook example - I will have a chance to try it out either tomorrow or the week after next. |
See https://observablehq.com/@recifs/contours-on-a-curvilinear-grid-geo for a geo version using your dataset. Remains to link this to a mapbox view, I guess. |
Wow - that's really nice! Currently I'm plotting the geojon directly onto the maplibre view (https://somisana.ac.za/explore/1). I hadn't considered using d3 plots on a mapview before. This plot currently uses the tricontour library. It's actually pretty close in terms of contouring: The dataset is actually a cumulative effort of a number of different people including research funded by SAEON. Would you mind changing the description to reflect that? I'd like to get feedback from others involved in this before confirming, but would something along these lines be suitable? ============ Sea-surface temperature as output from a run of the Coastal and Regional Ocean Community model, configured by SAEON, for the Algoa Bay region. Data made available by Zach Smith on behalf of the South African Sustainable Ocean Modelling Initiative; see this notebook for generated data. ============ |
Sure! Thanks
… Message ID: ***@***.***>
|
I've confirmed with others that the blurb mentioned above is fine. Please can you update the notebook when you get a chance. Thanks very much for your help. |
I have an XY grid, with each cell address mapped to a specific GPS coordinate. After generating contours I see I get polygons with coordinates based on cell positions.
I guess for earth data where pixels are regular and bound by some projection system, I would be able to re-project back to map coordinates, but I can't easily do this with my irregular grid - I think I would need to interpolate every coordinate of the resulting polygon based on closest known real coordinates.
Would it be possible to update the API to allow for specifying coordinates along with a values array that the library then uses to calculate the resulting polygons? (I'm not sure if this makes sense as I don't know how the marching squares algorithm works)
If so, I would be happy to try contribute to this, although I would probably need some guidance!
The text was updated successfully, but these errors were encountered: