[pyngl-talk] polyline draw order
Mary Haley
haley at ucar.edu
Mon May 11 16:47:31 MDT 2015
[Sorry, I hit send too early]
I didn't have a chance to tab the new code correctly, but hopefully you can
see from the previous message that you don't need the double "for" loop.
You simply set the special "gsSegments" resources to the "segm" array, and
make sure you pass in LON and LAT as 1D arrays (maybe it would work without
having to do this).
Our PyNGL website is down at the moment due to scheduled semi-annual
maintenance, but I think that "shapefiles4.py" and/or "shapefiles2.py" on
the gallery page use this new resources. I've attached shapefiles4.py here
in case the website doesn't have the latest version.
If you are interested in trying 1.5.0-beta of PyNGL, we have some binaries
at (when the website is back up, hopefully Sunday):
http://www.pyngl.ucar.edu/Training/SEA2015/
which we created for the tutorial. Note that we also have PyNIO binaries
listed here, which also has a number of new features. When we release 1.5.0
of both packages, we hope to do so under "conda", so you don't have to
download them this way.
Some of the binaries may have shared library issues, which are usually easy
to fix. Let me know if you try to download one of the binaries and have
issues with it.
--Mary
On Sat, Apr 18, 2015 at 12:10 PM, Mary Haley <haley at ucar.edu> wrote:
> 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/20150511/a764a7d1/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shapefile4.py
Type: text/x-python-script
Size: 2975 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20150511/a764a7d1/attachment.bin
More information about the pyngl-talk
mailing list