All,

We try to generate contour polygons from an unstructured triangular grid
stored in a netcdf file:

  import netCDF4
  import matplotlib.tri as tri

  # read data
  var = netCDF4.Dataset('filename.cdf').variables
  x = var['x'][:]
  y = var['y'][:]
  elems = var['element'][:,:]-1
  data = var['attrname'][:]     

  # create triangulation
  triang = tri.Triangulation(x, y, triangles=elems)

  # generate contour polygons
  levels = numpy.linspace(0, maxlevel, num=numlevels)
  contour = plt.tricontourf(triang, data, levels=levels)

  # extract geometries
  for coll in contour.collections:
    # handle all geometries for one level
    for p in coll.get_paths():
      polys = p.to_polygons()
      ...

At this point we assume, that polys[0] is a linear ring to be interpreted as
a polygon exterior and polys[1:] are the corresponding interiors for
polys[0]. 

Here are our questions: 

Is this assumption correct? 
Is there any detailed documentation describing the structure of the returned
geometries? 
Are the linear rings supposed to be correctly oriented (area > 0 for
exteriors and area < 0 for the interiors)?

Thanks!
Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu



------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to