Open lodhajyoti opened 5 years ago
Hi,
The error messages stem from the call to shapefile_mask_data(), which expects only a single shapefile name in the second argument (argument
it return regions of the grid that have been masked out as missing_values (_FillValue), then it might be possible to run shapefile_mask_data() separately for each shapefile, and then add together the resultant masks (effectively performing an intersect operation).
Hope that helps.... Rick
On Tue, Jul 16, 2019 at 9:48 AM lodhajyoti notifications@github.com wrote:
Hi I have to mask number of shapes files like rajasthan and Skimm together in the same code winch you have written. Can it be Possible. As I tried but I got the error as it asking for "expected (1) elements" . As I am having 2 different shape file.
ncl test1.ncl Copyright (C) 1995-2015 - All Rights Reserved University Corporation for Atmospheric Research NCAR Command Language Version 6.3.0 The use of this software is governed by a License Agreement. See http://www.ncl.ucar.edu/ for more details. fatal:Number of elements of dimension (0) of argument (1) is (2) in function (shapefile_mask_data), expected (1) elements fatal:["Execute.c":8575]:Execute: Error occurred at or near line 19 in file test1.ncl
fatal:Variable (mask_array) is undefined fatal:["Execute.c":8575]:Execute: Error occurred at or near line 20 in file test1.ncl
fatal:Variable (mask_array) is undefined fatal:["Execute.c":8575]:Execute: Error occurred at or near line 21 in file test1.ncl
fatal:Variable (mask_array) is undefined, can not assign attribute (coordinates) fatal:["Execute.c":8575]:Execute: Error occurred at or near line 22 in file test1.ncl
fatal:Variable (mask_array) is undefined fatal:["Execute.c":8575]:Execute: Error occurred at or near line 28 in file test1.ncl
Wait for a positive reply My script is
load "/usr/lib/ncarg/nclscripts/csm/shapefile_utils.ncl" load "/usr/lib/ncarg/nclscripts/csm/gsn_code.ncl"
files=systemfunc("ls *.shp") f = addfiles(files, "r") maskname = "test1.nc" fdata = addfile("fdETCCDI_yr_CCCma-CanESM2_H+rcp45_IITM-RegCM4_1981-2099.nc","r")
;-- read variable var = fdata->fdETCCDI(0,:,:) var@lat2d = fdata->lat var@lon2d = fdata->lon
;-- shapefile mask resources opt = True opt@return_mask = True ;-- this forces the return of a 0s and 1s mask array
;-- create the mask based on the given shapefile mask_array = shapefile_mask_data(var,files, opt) mask_array!0 = "y" mask_array!1 = "x" mask_array@coordinates = "XLAT XLONG"
;-- create new netCDF file and write mask array system("rm -f " + maskname) fout = addfile(maskname,"c")
fout->mask_array = mask_array fout->XLAT = fdata->lon fout->XLONG = fdata->lat
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/NCAR/ncl/issues/105?email_source=notifications&email_token=ADLWOXTQKHWLBARHHGFGSALP7XUTFA5CNFSM4IECNHYKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G7QJHGQ, or mute the thread https://github.com/notifications/unsubscribe-auth/ADLWOXX7URVDLH77MNDEEULP7XUTFANCNFSM4IECNHYA .
Hi Thanks for your reply. I appreciate it. But I issue is of taking multiples files together as I am having 40 shapefiles for masking and covert it into shapefile, So to run 40 times the same code doesn't solve my issues. Is there is another way out? As there is another function except for shapefile_mask_data(), as it takes one input at a time.
Thanks Wait for a reply.
I am sorry, but I am unaware of any existing means of doing what you'd like/need to do.
Rick
On Thu, Jul 18, 2019 at 1:13 AM lodhajyoti notifications@github.com wrote:
Hi Thanks for your reply. I appreciate it. But I issue is of taking multiples files together as I am having 40 shapefiles for masking and covert it into shapefile, So to run 40 times the same code doesn't solve my issues. Is there is another way out? As there is another function except for shapefile_mask_data(), as it takes one input at a time.
Thanks Wait for a reply.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NCAR/ncl/issues/105?email_source=notifications&email_token=ADLWOXSMGBR4C7IZOPE4TO3QAAJZTA5CNFSM4IECNHYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2HRWQI#issuecomment-512695105, or mute the thread https://github.com/notifications/unsubscribe-auth/ADLWOXQTFKMZC2PLILNF64TQAAJZTANCNFSM4IECNHYA .
Hi I have to mask number of shapes files like rajasthan and Skimm together in the same code winch you have written. Can it be Possible. As I tried but I got the error as it asking for "expected (1) elements" . As I am having 2 different shape file.
ncl test1.ncl Copyright (C) 1995-2015 - All Rights Reserved University Corporation for Atmospheric Research NCAR Command Language Version 6.3.0 The use of this software is governed by a License Agreement. See http://www.ncl.ucar.edu/ for more details. fatal:Number of elements of dimension (0) of argument (1) is (2) in function (shapefile_mask_data), expected (1) elements fatal:["Execute.c":8575]:Execute: Error occurred at or near line 19 in file test1.ncl
fatal:Variable (mask_array) is undefined fatal:["Execute.c":8575]:Execute: Error occurred at or near line 20 in file test1.ncl
fatal:Variable (mask_array) is undefined fatal:["Execute.c":8575]:Execute: Error occurred at or near line 21 in file test1.ncl
fatal:Variable (mask_array) is undefined, can not assign attribute (coordinates) fatal:["Execute.c":8575]:Execute: Error occurred at or near line 22 in file test1.ncl
fatal:Variable (mask_array) is undefined fatal:["Execute.c":8575]:Execute: Error occurred at or near line 28 in file test1.ncl
Wait for a positive reply My script is
load "/usr/lib/ncarg/nclscripts/csm/shapefile_utils.ncl" load "/usr/lib/ncarg/nclscripts/csm/gsn_code.ncl"
files=systemfunc("ls *.shp") f = addfiles(files, "r") maskname = "test1.nc"
fdata = addfile("fdETCCDI_yr_CCCma-CanESM2_H+rcp45_IITM-RegCM4_1981-2099.nc","r")
;-- read variable var = fdata->fdETCCDI(0,:,:) var@lat2d = fdata->lat var@lon2d = fdata->lon
;-- shapefile mask resources opt = True opt@return_mask = True ;-- this forces the return of a 0s and 1s mask array
;-- create the mask based on the given shapefile mask_array = shapefile_mask_data(var,files, opt) mask_array!0 = "y" mask_array!1 = "x" mask_array@coordinates = "XLAT XLONG"
;-- create new netCDF file and write mask array system("rm -f " + maskname) fout = addfile(maskname,"c")
fout->mask_array = mask_array fout->XLAT = fdata->lon fout->XLONG = fdata->lat