[ncl-talk] Question about map and shapfile

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Sun Oct 15 06:50:01 MDT 2023


It looks like NCL example topo_4 does what you want.  Try carefully
changing this example for your region of interest.

Those thin lines are the "fill value perimeter line" at the -100 meter
elevation.  You can experiment with resources that control or modify this
feature.  Look at the cnMissingValPerim* resources.  Try
res at cnMissingValPerimOn = False.  Also look at your color map and color
fill settings.  You might try setting the ocean fill colors to white or
light blue, instead of transparent.


On Sun, Oct 15, 2023 at 4:21 AM lzl lai via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Hi
>
> I have a problem for deleting those thin lines (the red arrow pointed area)
> . Could you please help me to remove it? Thanks a lot!
>
> I use "ETOPO_2022_v1_60s_N90W180_bed.nc"  ,for drawing topography,
>   and "gadm41_TWN_0.shp" , for drawing coastline in Taiwan
>
> my scrip is below :
> ========================================
> ;---Read data
> ;  topo_file = "../topo/ETOPO_2022_v1_60s_N90W180_geoid.nc"
>   topo_file = "../topo/ETOPO_2022_v1_60s_N90W180_bed.nc"
>   f  = addfile(topo_file,"r")
>   elev  = f->z
> ;
> ; Set all values below -100 to missing, hence removing all
> ; the ocean elevation values. The ocean will be filled in
> ; a light blue (see mpOceanFillColor below).
> ;
>   elev = where(elev.lt.-100.,elev at _FillValue,elev)
>
> ;;file --- 2
>   shpdir = "/home/lzl/data2/lzl/CWBtrend/topo/TW/"
>   filename ="gadm41_TWN_0.shp"
>
>   wks = gsn_open_wks("pdf","./pic/TW_topo")           ; send graphics to
> PNG file
>   gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")
>
>   res                    = True
>   res at gsnMaximize        = True     ; maximize plot in frame
>
>   res at cnFillOn           = True     ; turn on contour fill
> ;  res at cnFillPalette      = cmap(2:,:) ; set color map
>   res at cnLinesOn          = False    ; turn off contour lines
>   res at cnLineLabelsOn     = False    ; turn off line labels
>   res at cnInfoLabelOn      = False    ; turn off info label
>   res at lbBoxLinesOn       = False    ; turn off labelbar box lines
>
>   res at cnFillMode         = "MeshFill"   ; for faster draw
>
> ;---Pick "nice" contour levels
> ;  mnmxint = nice_mnmxintvl( min(elev), max(elev), 18, False)
>   mnmxint = nice_mnmxintvl( min(elev), max(elev), 5, False)
>
>  printVarSummary(mnmxint)
>  print(mnmxint(1))
>  print(mnmxint(2))
>   res at cnLevelSelectionMode = "ManualLevels"
>   res at cnMinLevelValF       = 100.
>   res at cnMaxLevelValF       = mnmxint(1)
>   res at cnLevelSpacingF      = mnmxint(2)/20.   ; Increase the number of
> levels
>                                              ; by choosing a smaller
> spacing.
>                                              ;higher number mean higher
> resol
>
>   res at gsnAddCyclic         = False           ; don't add longitude cyclic
> point
>
> ;---Zoom in on map
>   res at mpLimitMode           = "LatLon"
>   res at mpMinLatF            = 21.5
>   res at mpMaxLatF            = 25.5
>   res at mpMinLonF            = 119.5
>   res at mpMaxLonF            = 122.5
> ;  res at mpCenterLonF         = (res at mpMinLonF + res at mpMaxLonF) / 2.
>
>   res at mpFillOn             = True
>
>   res at mpInlandWaterFillColor="Background"
>   res at mpOceanFillColor     = "transparent"
>   res at mpLandFillColor      = "transparent"
>
>   res at mpFillDrawOrder      = "PostDraw"
>   res at mpDataBaseVersion = "MediumRes"
>   res at mpOutlineOn           = False
>   res at pmTickMarkDisplayMode       = "Always"
>   res at mpGeophysicalLineThicknessF = 2
>   plot = gsn_csm_contour_map(wks,elev,res)
>
>   nres                  = True
>   lnres at gsLineColor = "black"
>   lnres at gsLineThicknessF = 3.0
>   dum  = gsn_add_shapefile_polylines(wks,plot,shpdir+filename,lnres)
>
>   draw(plot)   ; This will draw the map and the shapefile outlines.
>   frame(wks)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20231015/caed62a5/attachment.htm>


More information about the ncl-talk mailing list