Re: Background map

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Mar 16 2011 - 09:21:23 MDT

Hi Vanesa,

I assume that the shapefile data you want to add are "polylines" and not "polygons" or "points". If so, please see example 3 at:

http://ncl.ucar.edu/Applications/shapefiles.shtml

The code of interest comes after the comments:

;*************************************************
; Section to add polylines to map.
;*************************************************

You didn't say which WRF function you're using, but I'll assume it's wrf_map_overlays.

What you'll need to do is set the resource "PanelPlot" to True before you call this routine, so that it doesn't remove any data that you add to the map. Your code wil look something like this:

...
            pltres@PanelPlot = True
      plot = wrf_map_overlays(a,wks,(/contour_tc,contour_psl,vector/),pltres,mpres)
;*************************************************
; Section to add polylines to map.
;*************************************************
  shp_filename = "name_of_shapefile.shp"
  f = addfile(shp_filename, "r") ; Open shapefile

;---Read data off shapefile
  segments = f->segments
  geometry = f->geometry
  segsDims = dimsizes(segments)
  geomDims = dimsizes(geometry)

;---Read global attributes
  geom_segIndex = f@geom_segIndex
  geom_numSegs = f@geom_numSegs
  segs_xyzIndex = f@segs_xyzIndex
  segs_numPnts = f@segs_numPnts
  numFeatures = geomDims(0)

  lines = new(segsDims(0),graphic) ; array to hold polylines

  plres = True ; resources for polylines
  plres@gsLineColor = "blue" ; Default is foreground color
  plres@gsLineThicknessF = 2.0 ; Default is 1
;---Add polylines to plot
  lon = f->x
  lat = f->y
  segNum = 0 ; Counter for adding polylines
  do i=0, numFeatures-1
     startSegment = geometry(i, geom_segIndex)
     numSegments = geometry(i, geom_numSegs)
     do seg=startSegment, startSegment+numSegments-1
        startPT = segments(seg, segs_xyzIndex)
        endPT = startPT + segments(seg, segs_numPnts) - 1
        lines(segNum) = gsn_add_polyline(wks, plot, lon(startPT:endPT), \
                                                    lat(startPT:endPT), plres)
        segNum = segNum + 1
     end do
  end do
;---Drawing the plot will draw the newly attached polylines.
  draw(plot)
  frame(wks) ; Advanced frame.

If this works, and you'd like to contribute it to our applications page, let me know.

--Mary
On Mar 15, 2011, at 12:58 PM, Vanesa Bdm wrote:

> Hello everybody: I used wrf_ script to generate real-data plots,
> For example I generate precipitation, in the other hand I have a "background" map, which I used shapefile.ncl toi generate this using a shp file.
> The question is, how I put that background in my precipitacion plot?
> I want to se my region limits, that's why I want to do this.
>
> I hope you understand what I'm trying to do.
>
> Regards
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Mar 16 09:21:31 2011

This archive was generated by hypermail 2.1.8 : Wed Mar 16 2011 - 09:22:37 MDT