title: .NET: How to draw Contours Lines and Filled Contours from grid data
body: <p>I am working on a project where I need to draw contours lines and filled contours. I have generated (X,Y,Z) data series from a algorithm.</p>
  
  <p>Data series generated in <strong>Rows X Columns</strong> grid format e.g <strong>3X3, 50X50</strong> ..</p>
  
  <p>(0,10,0.5), (0, 20, 5), (0, 30, 10)</p>
  
  <p>(1,10,0.5), (1, 20, 5), (1, 30, 10)</p>
  
  <p>(2,10,0.5), (2, 20, 5), (2, 30, 10)</p>
  
  <p><strong>Drawing of data series grid. (50 X 50)</strong></p>
  
  <p><a href="https://i.stack.imgur.com/JDgFI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JDgFI.png" alt="enter image description here"></a></p>
  
  <p><strong>Software which generated the contours lines from above grid</strong></p>
  
  <p><a href="https://i.stack.imgur.com/bdKAU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bdKAU.png" alt="enter image description here"></a></p>
  
  <p>I have searched on it but can't found any precise code. Mostly I have found software's which generate all the things.</p>
  
  <p>I have also tried <a href="https://stackoverflow.com/a/13303023/1558544">following solution</a> but doesn't generate correct output.</p>
  
  <p>How can I do this? If there is no solution Please suggest me the learning content.</p>
  
  <p><strong>Updated: Code Which returns Lines and Polygons.</strong></p>
  
  <pre><code>class Demo
  {
      IntPtr M_Pointer_Contour;
  
      // Filled by another function from grid data
      public double[] CoordX = new double[1000000];
      public double[] CoordY = new double[1000000];
  
      public void GetPolygons()
      {
          var polygonCount = Contour.ContourGetPolygonsCount(M_Pointer_Contour); // Returns Polygon Count
  
          for (int i = 0; i &lt; polygonCount; i++)
          {
              int PolgyonVerticesCount;
              double DistanceValue;
  
              // returns Polygon vertices
              Contour.ContourGetPolygonsParameters(M_Pointer_Contour, i, out PolgyonVerticesCount, out DistanceValue);
  
              // As per software documentation
              for (int v = 0; v &lt; PolgyonVerticesCount; v++)
              {
                  var x = CoordX[i];
                  var y = CoordY[i];
  
                  // Adding x,y in list for each polygon
              }
          }
      }
  
      public void GetPolyLines()
      {
          var polyLineCount = Contour.ContourGetPolylinesCount(M_Pointer_Contour); // Returns Polygon Count
  
          for (int i = 0; i &lt; polyLineCount; i++)
          {
              int PolyLineVerticesCount;
              double DistanceValue;
  
              // returns Polygon vertices
              Contour.ContourGetPolylineParameters(M_Pointer_Contour, i, out PolyLineVerticesCount, out DistanceValue);
  
              // As per software documentation
              for (int v = 0; v &lt; PolyLineVerticesCount; v++)
              {
                  var x = CoordX[i];
                  var y = CoordY[i];
  
                  // Adding x, y in list for each line
              }
          }
      }
  }
  </code></pre>
  
  <p>My Code output from this code</p>
  
  <p><a href="https://i.stack.imgur.com/NcjLK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NcjLK.png" alt="enter image description here"></a></p>
  
  <p>Thank you</p>