GithubHelp home page GithubHelp logo

Support curvilinear grids about d3-contour HOT 11 CLOSED

d3 avatar d3 commented on April 20, 2024
Support curvilinear grids

from d3-contour.

Comments (11)

Fil avatar Fil commented on April 20, 2024

Have you tried https://github.com/Fil/d3-tricontour instead?

from d3-contour.

zachsa avatar zachsa commented on April 20, 2024

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 d3-tricontour with d3-contour I can see that creating contours with 100 steps takes 450 ms using tricontours vs 110ms with this library. That's a pretty substantial difference on the performance side.

from d3-contour.

Fil avatar Fil commented on April 20, 2024

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.

from d3-contour.

zachsa avatar zachsa commented on April 20, 2024

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)

from d3-contour.

Fil avatar Fil commented on April 20, 2024

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.

from d3-contour.

zachsa avatar zachsa commented on April 20, 2024

My grid looks like this:

image

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)

from d3-contour.

zachsa avatar zachsa commented on April 20, 2024

Thank you very much for the notebook example - I will have a chance to try it out either tomorrow or the week after next.

from d3-contour.

Fil avatar Fil commented on April 20, 2024

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.
geo contours

from d3-contour.

zachsa avatar zachsa commented on April 20, 2024

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:

image

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.

============

from d3-contour.

Fil avatar Fil commented on April 20, 2024

from d3-contour.

zachsa avatar zachsa commented on April 20, 2024

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.

from d3-contour.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.