[pyngl-talk] polyline draw order

Mary Haley haley at ucar.edu
Sat Apr 18 12:10:41 MDT 2015


Hi Diego,

Sorry for the delay in response. Ironically, the delay was caused by us
being at a Python conference this week at NCAR.

The problem with using Ngl.polyline, is that the lines are not "attached"
to the plot, and hence when you do the maximize_plot call later, the lines
are getting ignored and probably discarded.

There are a couple of things you can try:


   - Move the #10 part of your code to *after* the #11 code, so that the
   lines get drawn after you maximize the plot and draw the map.

or


   - Updated to PyNGL 1.5.0-beta, and use the special "gsSegments" resource
   which allows you to add shapefile outlines with a single call. So instead
   of this code:


# 10. Add Natura2000 polylines to map
                   for i in range(0,numFeatures):
        startSegment = geom[i, geom_segIndex]
        numSegments = geom[i, geom_numSegs]
        for seg in range(startSegment, startSegment+numSegments):
            startPT = segm[seg, segs_xyzIndex]
            endPT = startPT + segm[seg, segs_numPnts]# - 1

            Ngl.polyline(wks, mp, LON[startPT:endPT], LAT[startPT:endPT],
natres)


It would look something like this::


LON1D = numpy.ravel(LON)
LAT1D = numpy.ravel(LAT)

natres.gsSegments  = segm
id = Ngl.add_polyline(wks, mp, LON1D, LAT1D, natres)



On Mon, Apr 13, 2015 at 4:40 AM, Diego Bruciaferri <
diego.bruciaferri at ingv.it> wrote:

> Dear all,
>
> I'm trying to plot several polylines from a shapefile over a map which
> contains both scalar (oil concentration) and vector fields (current and
> stokes' drift fields).
>
> As I've seen in yours example scripts to plot shapefiles, I want to use
> the Ngl.polyline function over the Ngl.add_polyline because the first is
> faster, but it doesn't work (I don't see the lines) for me.
>
> I've tried to "play" with the DrawOrder resources, without any effect.
> Can you please suggest me some possible solution?
>
> Attached, you can find the code.
> Thanks in advance!
>
> Diego
>
> --
> Diego Bruciaferri
> Istituto Nazionale di Geofisica e Vulcanologia (INGV)
> National Institute of Geophysics and Volcanology
>
> Viale Aldo Moro 44
> 40127 Bologna
> Italy
> Tel: +39 051 3782665
>
> _______________________________________________
> pyngl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20150418/6a9df56b/attachment.html 


More information about the pyngl-talk mailing list