[ncl-talk] map outline using shapefile

Debasish Hazra debasish.hazra5 at gmail.com
Wed Nov 28 09:59:24 MST 2018


Thanks Mary and Adam, issue is resolved now.
Debasish

On Wed, Nov 28, 2018 at 11:38 AM Mary Haley <haley at ucar.edu> wrote:

> I think the issue is with this "if" statement:
>
> if(USE_SHAPEFILE_OUTLINES) then
>        res at mpOutlineOn               = True
>     ;   res at mpOutlineBoundarySets = "National"
>   else
>        res at mpDataBaseVersion         = "MediumRes"        ; higher
> resolution basemap
>        res at mpDataSetName             = "Earth..4"         ; contains
> divisions for other countries
>         res at mpOutlineMaskingOn = True
>         res at mpMaskOutlineSpecifiers = "Indian:states"
>      end if
>
> If you want the masking to be used when you do the shapefile outlines,
> then the above logic is faulty, because the masking is only being applied
> if USE_SHAPEFILES_OUTLINES is False.
>
> What I think you need is this:
>
> if(USE_SHAPEFILE_OUTLINES) then
>        res at mpOutlineOn               = True
>        res at mpOutlineBoundarySets = "National"
>        res at mpDataBaseVersion         = "MediumRes"        ; higher
> resolution basemap
>        res at mpDataSetName             = "Earth..4"         ; contains
> divisions for other countries
>         res at mpOutlineMaskingOn = True
>         res at mpMaskOutlineSpecifiers = "Indian:states"
>   else
>        res at mpDataBaseVersion         = "MediumRes"        ; higher
> resolution basemap
>        res at mpDataSetName             = "Earth..4"         ; contains
> divisions for other countries
>         res at mpOutlineMaskingOn = True
>         res at mpMaskOutlineSpecifiers = "Indian:states"
>      end if
>
> See the attached script which illustrates the masking in a simple map plot
> script. I had an "indian_met_zones v2.shp" shapefile that I downloaded
> awhile back.
>
> --Mary
>
>
> On Wed, Nov 28, 2018 at 8:46 AM Debasish Hazra <debasish.hazra5 at gmail.com>
> wrote:
>
>> Mary,
>> That does not work unfortunately. So, here is the part of code I changed
>> after your suggestion :
>>
>> if(USE_SHAPEFILE_OUTLINES) then
>>        res at mpOutlineOn               = True
>>     ;   res at mpOutlineBoundarySets = "National"
>>   else
>>        res at mpDataBaseVersion         = "MediumRes"        ; higher
>> resolution basemap
>>        res at mpDataSetName             = "Earth..4"         ; contains
>> divisions for other countries
>>         res at mpOutlineMaskingOn = True
>>         res at mpMaskOutlineSpecifiers = "Indian:states"
>>      end if
>>
>> and reading shapefile
>>   if(USE_SHAPEFILE_OUTLINES) then
>>          lnres= True
>>          ind_met =
>> gsn_add_shapefile_polylines(wks,plot_A,"./Indian_met_zones-master/indian_met_zones.v2.shp",lnres)
>>          end if
>>
>> So I run first run with setting res at mpOutlineOn               = True,
>> which does not produce boundaries over Pakistan, Agfanisthan, Iran . If I
>> comment out  res at mpOutlineOn               = True and just use
>> res at mpOutlineBoundarySets = "National", it draws all the boundaries of
>> the above mentioned countries, but produces double outlines over India.
>> Attached are the figures.
>> Thanks
>> Debasish
>>
>> On Wed, Nov 28, 2018 at 10:01 AM Mary Haley <haley at ucar.edu> wrote:
>>
>>> I think the issue is simply that the script is setting mpOutlineOn to
>>> False if shapefile outlines are turned on. You want to set this to True
>>> since you want to see the outlines from both NCL and the shapefiles.
>>>
>>>
>>>
>>> On Tue, Nov 27, 2018 at 7:53 PM Debasish Hazra <
>>> debasish.hazra5 at gmail.com> wrote:
>>>
>>>> Thanks Adam.I applied your changes and it removed double lines over
>>>> India, but it still not drawing other neighbouring country borders. Here is
>>>> the script I am using and attached is current figure generated :
>>>>
>>>> plot_A   = new (2 , graphic)                    ; create graphical array
>>>>   res      = True               ; plot options desired
>>>>    USE_SHAPEFILE_OUTLINES = True
>>>>   res at gsnDraw = False
>>>>   res at gsnFrame = False
>>>>   res at gsnMajorLatSpacing = 10             ; change maj lat tm spacing
>>>>   res at gsnMajorLonSpacing = 20
>>>>  res at cnLinesOn            = False
>>>>   res at cnFillOn             = True               ; turn on color fill
>>>>   res at cnInfoLabelOn        = False              ; turn off contour
>>>> info label
>>>>   res at cnLineLabelsOn       = False              ; turn off line labels
>>>>    res at cnFillDrawOrder  = "Predraw"
>>>>   res at gsnSpreadColors      = True            ; use full color table
>>>>   res at mpFillOn             = False              ; do not grey fill land
>>>>   res at lbLabelBarOn         = False           ; turn off individual
>>>> color bars
>>>>   res at gsnStringFontHeightF = 0.018
>>>>   res at tmYRMode             = "Automatic"          ; turn off special
>>>> labels on right axis
>>>>   res at lbAutoManage          = False             ; we control label bar
>>>>   if(USE_SHAPEFILE_OUTLINES) then
>>>>        res at mpOutlineOn               = False
>>>>   else
>>>> ;       res at mpOutlineOn               = True
>>>> ;        res at mpOutlineBoundarySets = "National"
>>>>        res at mpDataBaseVersion         = "MediumRes"        ; higher
>>>> resolution basemap
>>>>        res at mpDataSetName             = "Earth..4"         ; contains
>>>> divisions for other countries
>>>>         res at mpOutlineMaskingOn = True
>>>>         res at mpMaskOutlineSpecifiers = "Indian:states"
>>>>     end if
>>>>
>>>>    res at mpLimitMode = "Corners"
>>>>    res at mpLeftCornerLatF  =  0.0
>>>>    res at mpLeftCornerLonF  =  50.0
>>>>    res at mpRightCornerLatF =  40.0
>>>>    res at mpRightCornerLonF =  100.0
>>>>
>>>>    res at gsnDraw = False
>>>>    res at gsnFrame = False
>>>>     res at gsnLeftString = ""
>>>>     res at gsnRightString = ""
>>>>
>>>>         res at gsnCenterString   = labes(0)
>>>>         plot_A(0) = gsn_csm_contour_map_ce (wks, rainl(:,:), res)
>>>>         res at gsnCenterString   = labes(1)
>>>>         plot_A(1) = gsn_csm_contour_map_ce (wks, rain2(:,:), res)
>>>>
>>>>          if(USE_SHAPEFILE_OUTLINES) then
>>>>          lnres= True
>>>>          ind_met =
>>>> gsn_add_shapefile_polylines(wks,plot_A,"./Indian_met_zones-master/indian_met_zones.v2.shp",lnres)
>>>>          end if
>>>>    pres1                     = True               ; panel options
>>>>    pres1 at gsnFrame         = False
>>>>    pres1 at gsnDraw = True
>>>>   pres1 at gsnMaximize         = True               ; maximize image
>>>>   pres1 at gsnPanelLabelBar    = True               ; Add common label bar
>>>>
>>>>  gsn_panel(wks,plot_A,(/1,2/),pres1)
>>>>        ;draw(plot)
>>>> frame(wks)
>>>>
>>>> Any help.
>>>> Thanks
>>>> Debasish
>>>>
>>>> On Tue, Nov 27, 2018 at 3:43 PM Adam Phillips <asphilli at ucar.edu>
>>>> wrote:
>>>>
>>>>> Hi Debasish,
>>>>> I am guessing your shapefile outlines are more precise than NCL's
>>>>> built in outlines, and that's why you're getting double boundaries being
>>>>> shown. I would suggest continuing what you're doing, but tell NCL to
>>>>> exclude drawing the Indian states by utilizing the mpMaskOutlineSpecifiers:
>>>>> res at mpDataBaseVersion       = "MediumRes"
>>>>> res at mpDataSetName         = "Earth..4"
>>>>> res at mpOutlineMaskingOn = True
>>>>> res at mpMaskOutlineSpecifiers = "Indian:states"    ; do not draw any
>>>>> outlines specified here
>>>>>
>>>>>
>>>>> http://www.ncl.ucar.edu/Document/Graphics/Resources/mp.shtml#mpMaskOutlineSpecifiers
>>>>> Example showing mpMaskOutlineSpecifier use:
>>>>> http://www.ncl.ucar.edu/Applications/Scripts/maponly_14.ncl
>>>>> Example showing how to specify Indian states:
>>>>> http://www.ncl.ucar.edu/Applications/Scripts/maponly_16.ncl
>>>>>
>>>>> If you have any further questions let ncl-talk know.
>>>>> Adam
>>>>>
>>>>>
>>>>> On Tue, Nov 27, 2018 at 1:16 PM Debasish Hazra <
>>>>> debasish.hazra5 at gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>> I am using shapefile to draw outline over India following
>>>>>> polyg_shp_9.ncl example. However, my plotting domain covers other area
>>>>>> besides India and when I am using
>>>>>>  lnres= True
>>>>>>  ind_met =
>>>>>> gsn_add_shapefile_polylines(wks,plot_A,"./Indian_met_zones-master/indian_met_zones.v2.shp",lnres)
>>>>>> in combination with
>>>>>> res at mpOutlineOn               = False
>>>>>>
>>>>>> I am getting outline of India only, with neighboring counties
>>>>>> boundaries not drawn.
>>>>>>
>>>>>> But when I am using
>>>>>> res at mpOutlineOn               = True
>>>>>> in combination with the above mentioned shapefile over India, I am
>>>>>> getting double line borders over India (coming from both India met
>>>>>> shapefile and ncl map outline). I have attached both resulting figures. How
>>>>>> do I  solve this to combine both in proper way ?
>>>>>>
>>>>>> Thanks
>>>>>> Debasish
>>>>>> _______________________________________________
>>>>>> ncl-talk mailing list
>>>>>> ncl-talk at ucar.edu
>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Adam Phillips
>>>>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>>>>> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>>>>>
>>>>> <http://www.cgd.ucar.edu/staff/asphilli>
>>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181128/238cc3a8/attachment.html>


More information about the ncl-talk mailing list