On 1 November 2014 18:20, Hartmut Kaiser <hartmut.kai...@gmail.com> wrote:

> Thanks Ian! Your detailed answer is much appreciated.
>
> As you might have already guessed, we have quite some problems creating
> clean geometries from the generated contour data. I have tried to put
> together one (reasonably) small test case illustrating at least one of our
> issues. I apologize for the lengthy code attached.
>
> The two attached figures demonstrate what we see. Matplotlib.png
> (generated by the library) does not really look ok. Also, the attached
> shape.png shows that there are a lot of geometries generated which are
> self-intersecting (highlighted in dark blue), and we already skip polygons
> with less than 3 points. BTW, there are many polygons stacked with the same
> geometries.
>
> Anything we can do about this?
>
> Thanks!
> Regards Hartmut
>

Hartmut,

You are using masked arrays where you shouldn't, again.  The documentation
for tricontour states that it expects z to be an array, it doesn't say
masked array.  If you pass it a masked array, it will ignore the mask.
Hence you have a number of triangles that include a vertex with a z-value
of -99999; when contoured these are going to give you lots of thin polygons
that you don't want.

You need to stop using masked arrays where they are not expected.  Your
triangulation should only contain triangles for which you have valid data
at all three vertices.  So either remove invalid triangles from your 'ele'
array before creating the triangulation, or set a mask on the triangulation
once it has been created, e.g.

    point_mask_indices = numpy.where(z.mask)
    tri_mask = numpy.any(numpy.in1d(ele, point_mask_indices).reshape(-1,
3), axis=1)
    triang.set_mask(tri_mask)

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

Reply via email to