Re: masking an area of china, there is a error or a bug.

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Mon Jan 03 2011 - 10:29:15 MST

Hi Dazhen,

I can't tell for certain what the issue is. Multiple polygons within a shapefile is certainly an issue; you might do a printVarSummary(f) on that shapefile to verify that i) it is a polygon-type shapefile (as opposed to polyline), and how many polygons there are. If there are multiple polygons, you'll need to loop over them to properly build your mask (See shapefile example 1). Alternatively and depending on the resolution of your data, you might select and use only the largest polygon, on the presumption that it represents the mainland, and that masking the islands is negligible.

Also, I have to wonder if perhaps your indices are backwards:

  ilt1 = ilt_mn(dimsizes(ilt_mn)-1) ; Start of lat box
  iln1 = iln_mn(dimsizes(iln_mn)-1) ; Start of lon box
  ilt2 = ilt_mx(0) ; End of lat box
  iln2 = iln_mx(0) ; End of lon box

Should that be?

  ilt1 = ilt_mn(0)
  ilt2 = ilt_mx(dimsizes(ilt_mx)-1)
  iln1 = iln_mn(0)
  iln2 = iln_mx(dimsizes(iln_mx)-1)

I'm not certain about that -- it might help to print these values to see if they are what you think they are.

Hope that helps,

Rick

On Jan 2, 2011, at 10:55 PM, Dazhen HUANG wrote:

> Hello all,
>
> I try to mask an area of china with the shp file, but something goes wrong, it showed as:
>
> "fatal:Subscript out of range, error in subscript #0
> fatal:An error occurred reading lat1d
> fatal:Execute: Error occurred at or near line 73 in file mask_9_cn.ncl"
>
> David Brown told me that,
> " the problem starts with the line:
> ilt_mn = ind(min_mrb_lat.gt.lat1d)
> The variable ilt_mn gets set to a missing value because there are no values of the array lat1d where the value of min_mrb_lat is greater. Therefore lit_mn gets set to a missing value and therefore causes an out-of-range subscript in the line that reports the error:
> if(gc_inout(lat1d(ilt),lon1d(iln),mrb_lat,mrb_lon)) then "
>
> I guest that the problem is from the shp file, Maybe there are two or more areas other than one area. so the function gc_inout() connot do it. I am trying to make a new shp file now, but I'm not sure this will work then.
>
> Is there anyone would like to help me?
>
> Thanks!
>
> Dazhen
>
> ------------------
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Dazhen HUANG, Mr. #(黄大贞)
> Department of Atmospheric Sciences,
> Sun Yat-sen University,
> No.135, Xingang West Road. Guangzhou, 510275, P.R.China
> Email: huangdzh@foxmail.com
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> <mask_9_cn.ncl>_______________________________________________
> 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 Mon Jan 3 10:29:22 2011

This archive was generated by hypermail 2.1.8 : Tue Jan 04 2011 - 09:16:52 MST