<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:14pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi Mary,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">The print_shapefile_info:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>(0)<span style="white-space:pre"> </span>======================================================================</div>
<div>(0)<span style="white-space:pre"> </span>Filename: "Cuenca_Universidad.shp"</div>
<div>(0)<span style="white-space:pre"> </span> Geometry type: polygon</div>
<div>(0)<span style="white-space:pre"> </span> # of features: 1</div>
<div>(0)<span style="white-space:pre"> </span> Min/max lat: -34.77/ -34.62</div>
<div>(0)<span style="white-space:pre"> </span> Min/max lon: -70.44/ -70.25</div>
<div>(0)<span style="white-space:pre"> </span> Variable names and their types:</div>
<div>(0)<span style="white-space:pre"> </span> geometry : integer</div>
<div>(0)<span style="white-space:pre"> </span> segments : integer</div>
<div>(0)<span style="white-space:pre"> </span> x : double</div>
<div>(0)<span style="white-space:pre"> </span> y : double</div>
<div>(0)<span style="white-space:pre"> </span> COD_CUEN : string</div>
<div>(0)<span style="white-space:pre"> </span> COD_SUBC : string</div>
<div>(0)<span style="white-space:pre"> </span> COD_SSUBC : string</div>
<div>(0)<span style="white-space:pre"> </span> NOMBRE : string</div>
<div>(0)<span style="white-space:pre"> </span> AREAKM2 : double</div>
<div>(0)<span style="white-space:pre"> </span>======================================================================</div>
<div><br>
</div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0">The shapefiles are attached. </p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">2) <span>The inventory.asc <span>it's a mascara file</span>, in which values are only for some pixels of interest.</span></p>
<p style="margin-top:0;margin-bottom:0"><span><span>I need to select the non-missing values of this file for the shapefile region.</span><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span>And then calculate the area of the file, according to the original file: inventory.asc</span><br>
</span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><span><span>I want to know the value of the area for non-missing data in the shapefile region</span><br>
</span></span></span></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>De:</b> Mary Haley <haley@ucar.edu><br>
<b>Enviado:</b> quarta-feira, 14 de março de 2018 11:42:58<br>
<b>Para:</b> Vanúcia Schumacher<br>
<b>Cc:</b> Dennis Shea; ncl-talk@ucar.edu<br>
<b>Assunto:</b> Re: [ncl-talk] area of a shapefile</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div class="x_gmail_default" style="font-size:small">Vanúcia,</div>
<div class="x_gmail_default" style="font-size:small"><br>
</div>
<div class="x_gmail_default" style="font-size:small">Dennis asked me to look into this.</div>
<div class="x_gmail_default" style="font-size:small"><br>
</div>
<div class="x_gmail_default" style="font-size:small">I tried looking at the shapefile and script you provided, but either something is wrong with the shapefile, or we don't have all the necessary files. Without the necessary files, you cannot correctly mask
your data against a shapefile.</div>
<div class="x_gmail_default" style="font-size:small"><br>
</div>
<div class="x_gmail_default" style="font-size:small">I used a simple procedure called "print_shapefile_info" to print out basic information about the shapefile, and the lat/lon values are out-of-range. I think this is because the <span style="color:rgb(34,34,34); font-family:arial,sans-serif; font-size:small; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">Cuenca_Universidad.prj
file is not available. Can you provide this?</span></div>
<div class="x_gmail_default" style="font-size:small"><span style="color:rgb(34,34,34); font-family:arial,sans-serif; font-size:small; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline"><br>
</span></div>
<div class="x_gmail_default" style="font-size:small"><span style="color:rgb(34,34,34); font-family:arial,sans-serif; font-size:small; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">Here
is the simple script I used, by downloading "shapefiles_utils.ncl" from the shapefiles example page:</span></div>
<div class="x_gmail_default" style="font-size:small"><br>
</div>
<div class="x_gmail_default" style="font-size:small">
<div class="x_gmail_default">load "./shapefile_utils.ncl"</div>
<div class="x_gmail_default">sname = "<span style="color:rgb(34,34,34); font-family:arial,sans-serif; font-size:small; font-style:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); float:none; display:inline">Cuenca_Universidad</span>.shp"</div>
<div class="x_gmail_default">print_shapefile_info(sname)</div>
<div class="x_gmail_default">; plot_shapefile(sname)</div>
</div>
<div class="x_gmail_default" style="font-size:small"><br>
</div>
<div class="x_gmail_default" style="font-size:small">And here's the output. Note the min/max of the lat/lons, which are very clearly wrong. They should be in the range -90 to 90 and -180 to 180:</div>
<div class="x_gmail_default" style="font-size:small"><br>
</div>
<div class="x_gmail_default">
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span>Filename: "Cuenca_Universidad.shp"</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> Geometry type: polygon</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> # of features: 1</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> Min/max lat: 6151442.45/6167964.95</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> Min/max lon: 368312.46/385366.64</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> Variable names and their types:</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> geometry : integer</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> segments : integer</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> x : double</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> y : double</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> COD_CUEN : string</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> COD_SUBC : string</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> COD_SSUBC : string</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> NOMBRE : string</div>
<div class="x_gmail_default">(0)<span style="white-space:pre"> </span> AREAKM2 : double</div>
<div class="x_gmail_default"><br>
</div>
<div class="x_gmail_default">Secondly, Dennis and I are not sure what you are trying to accomplish with the script. When the inventory values are read in, many of them are missing, and the rest appear to be all equal to 1. Can you explain more about what
you want to do with this data?</div>
<div class="x_gmail_default"><br>
</div>
<div class="x_gmail_default">Thanks,</div>
<div class="x_gmail_default"><br>
</div>
<div class="x_gmail_default"><br>
--Mary</div>
<div class="x_gmail_default"><br>
</div>
<div class="x_gmail_default"><br>
</div>
</div>
</div>
<div class="x_gmail_extra"><br>
<div class="x_gmail_quote">On Mon, Mar 12, 2018 at 12:50 PM, Vanúcia Schumacher <span dir="ltr">
<<a href="mailto:vanucia-schumacher@hotmail.com" target="_blank">vanucia-schumacher@hotmail.com</a>></span> wrote:<br>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-4790289169492009167divtagdefaultwrapper" dir="ltr" style="font-size:14pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0"><span>Thanks for the tips, but I'm not making progress on this issue.</span><br>
</p>
<p style="margin-top:0; margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0; margin-bottom:0"><span><span>I tried to follow example 4 of the function: <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/area_poly_sphere.shtml" class="x_m_-4790289169492009167OWAAutoLink" id="x_m_-4790289169492009167LPlnk519286" target="_blank">area_poly_sphere</a>,</span></span></p>
<p style="margin-top:0; margin-bottom:0"><span><span></span></span></p>
<div>but the area I need to calculate is not from the shapefile, it refers to<span style="font-size:14pt"> inventory.asc file,</span></div>
<div><span style="font-size:14pt">in which I use the shapefile to extract the pixel values in the polygon region of the shapefile.</span></div>
<div>The only information I have from the inventory.asc are:</div>
<div><br>
</div>
<div>
<div>ncols 129</div>
<div>nrows 156</div>
<div>xllcorner -70.8944702148438</div>
<div>yllcorner -35.3186645507812</div>
<div>xcellsize 0.0109375946281492</div>
<div>ycellsize 0.00894945095746945</div>
<div>nodata_value -9999</div>
<br>
</div>
<div>
<div>The script I tried follows below, but I get the following error</div>
<div><span>gc_clkwise: the arrays must have the same dimension sizes</span><br>
</div>
<div><span><br>
</span></div>
<div><span>link to line:</span></div>
<div><span><span>if (gc_clkwise(mrb_lat, mrb_lon)) then</span><br>
</span></div>
<div><span><span><br>
</span></span></div>
<div><span><span>
<div style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
which I believe that lat and lon information are wrong. </div>
<div style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
Thank you very much any help</div>
<br>
</span></span></div>
<div><span><span><br>
</span></span></div>
<div><span><span><br>
</span></span></div>
<div><span>
<div>Variable: lonss</div>
<div>Type: float</div>
<div>Total Size: 516 bytes</div>
<div> 129 values</div>
<div>Number of Dimensions: 1</div>
<div>Dimensions and sizes:<span style="white-space:pre-wrap"> </span>[129]</div>
<div>Coordinates: </div>
<div><br>
</div>
<div>Variable: latss</div>
<div>Type: float</div>
<div>Total Size: 624 bytes</div>
<div> 156 values</div>
<div>Number of Dimensions: 1</div>
<div>Dimensions and sizes:<span style="white-space:pre-wrap"> </span>[156]</div>
<div>Coordinates: </div>
<div>(0)<span style="white-space:pre-wrap"> </span>n_mrb=156</div>
<div><br>
</div>
<br>
</span></div>
<div>Script:</div>
<div>
<div> </div>
<div> ncols = <span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
129</span></div>
<div> nrows = <span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
156</span></div>
<div> lonLL = <span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
-70.8944702148438</span></div>
<div> latLL = <span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
-35.3186645507812</span></div>
<div> deltaLon = <span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
0.0109375946281492</span></div>
<div> deltaLat = <span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">
0.00894945095746945</span></div>
<div>missingVal = <span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:18.6667px">-9999.0</span></div>
<span class="">
<div><br>
</div>
<div>data = readAsciiTable("inventory.asc"<wbr>,ncols,"float",7) </div>
<div> </div>
</span><span class="">
<div>;----- construct 1D coordinates....</div>
<div>lons = ispan(0,ncols-1,1) * deltaLon + lonLL</div>
<div>lats = ispan(0,nrows-1,1) * deltaLat + latLL</div>
<div>lats = lats(::-1)</div>
<div><br>
</div>
<div>;---- gsn_coordinates wants 2D coordinate arrays</div>
<div>data@lon2d = conform_dims((/ nrows, ncols/), lons, 1)</div>
<div>data@lat2d = conform_dims((/ nrows, ncols/), lats, 0)</div>
<div>data@_FillValue = missingVal</div>
<div><br>
</div>
</span>
<div>;---- Open shapefile .</div>
<div><br>
</div>
<div>shp_filename = "universidad.shp" </div>
<div>data_mask = shapefile_mask_data(data,shp_<wbr>filename,True)</div>
<div><br>
</div>
<div>;---- Selecting just non-missing values, from the inventory.asc using shapefile region:</div>
<div><br>
</div>
<div>x = ndtooned(data_mask(:,:)) ; reduce to 1D array</div>
<div><span style="font-size:14pt">igood = ind(.not.ismissing(x)) ; extract only the non-missing values.</span><br>
</div>
<div>xgood = x(igood)</div>
<div><br>
</div>
<div>;----- construct 1D coordinates to xgood var:</div>
<div><br>
</div>
<div>lonss = ispan(0,ncols-1,1) * deltaLon + lonLL</div>
<div>latss = ispan(0,nrows-1,1) * deltaLat + latLL</div>
<div>latss = lats(::-1)</div>
<div><br>
</div>
<div>;---- gsn_coordinates wants 2D coordinate arrays to xgood var:</div>
<div><br>
</div>
<div>xgood@lon2d = conform_dims((/ nrows, ncols/), lons, 1)</div>
<div>xgood@lat2d = conform_dims((/ nrows, ncols/), lats, 0)</div>
<div>xgood@_FillValue = missingVal</div>
<div><br>
</div>
<div></div>
<div><br>
</div>
<div> mrb_lon = lonss Problem is here! </div>
<div> mrb_lat = latss </div>
<div><br>
</div>
<div> n_mrb = dimsizes(mrb_lat) </div>
<div> print("n_mrb="+n_mrb)</div>
<div><br>
</div>
<div> re = 6371.</div>
<div> re@units= "km"</div>
<div><br>
</div>
<div> if (gc_clkwise(mrb_lat, mrb_lon)) then</div>
<div> area_mrb = area_poly_sphere(mrb_lat, mrb_lon, re)</div>
<div><br>
</div>
<div> area_mrb@units = "km^2"</div>
<div> area_mrb@long_name = "Area Enclosed by the MRB"</div>
<div><br>
</div>
<div> print (area_mrb)</div>
<div> else</div>
<div> print ("MRB points are not in clockwise order.")</div>
<div> exit</div>
<div> end if</div>
<br>
</div>
<div></div>
<br>
</div>
<br>
<p></p>
<p style="margin-top:0; margin-bottom:0"><span><span><a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/area_poly_sphere.shtml" class="x_m_-4790289169492009167OWAAutoLink" id="x_m_-4790289169492009167LPlnk24337" target="_blank"></a></span><br>
<br>
</span></p>
</div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-4790289169492009167divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>De:</b> Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>><br>
<b>Enviado:</b> segunda-feira, 12 de março de 2018 11:25:03<br>
<b>Para:</b> Vanúcia Schumacher<br>
<b>Cc:</b> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Assunto:</b> Re: [ncl-talk] area of a shapefile</font>
<div> </div>
</div>
<div>
<div class="x_h5">
<div>
<div dir="ltr">
<div>You could click "Functions" [Alphabetical]; then, search for the word 'area'<br>
</div>
Keep clicking ....<br>
<div><br>
<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/area_poly_sphere.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Functions/Built-in/<wbr>area_poly_sphere.shtml</a><br>
<br>
</div>
<div>Also,<br>
<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/gc_qarea.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Functions/Built-in/<wbr>gc_qarea.shtml</a><br>
</div>
<div>See Examples<br>
<br>
</div>
<div>Good luck<br>
</div>
<div><br>
</div>
</div>
<div class="x_m_-4790289169492009167x_gmail_extra"><br>
<div class="x_m_-4790289169492009167x_gmail_quote">On Mon, Mar 12, 2018 at 8:14 AM, Vanúcia Schumacher
<span dir="ltr"><<a href="mailto:vanucia-schumacher@hotmail.com" target="_blank">vanucia-schumacher@hotmail.<wbr>com</a>></span> wrote:<br>
<blockquote class="x_m_-4790289169492009167x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-4790289169492009167x_m_-8478355152293599047divtagdefaultwrapper" dir="ltr" style="font-size:14pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0"></p>
<div> Hi NCL users,</div>
<div>
<div>I would like help to calculate the area from the shapefile.</div>
<div>Any ideas how can I proceed?</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div> hdr = readAsciiHead("inventory.asc", 7)</div>
<div> ncols = stringtoint( str_get_field(hdr(0), 2, " ") )</div>
<div> nrows = stringtoint( str_get_field(hdr(1), 2, " ") )</div>
<div> lonLL = stringtofloat( str_get_field(hdr(2), 2, " ") )</div>
<div> latLL = stringtofloat( str_get_field(hdr(3), 2, " ") )</div>
<div> deltaLon = stringtofloat( str_get_field(hdr(4), 2, " " ) )</div>
<div> deltaLat = stringtofloat( str_get_field(hdr(5), 2, " ") )</div>
<div>missingVal = stringtofloat( str_get_field(hdr(6), 2, " ") )</div>
<div><br>
</div>
<div>data = readAsciiTable("inventory.asc"<wbr>,ncols,"float",7) </div>
<div> data@_FillValue =-9999.0</div>
<div><br>
</div>
<div>;----- construct 1D coordinates....</div>
<div>lons = ispan(0,ncols-1,1) * deltaLon + lonLL</div>
<div>lats = ispan(0,nrows-1,1) * deltaLat + latLL</div>
<div>lats = lats(::-1)</div>
<div><br>
</div>
<div>;---- gsn_coordinates wants 2D coordinate arrays</div>
<div>data@lon2d = conform_dims((/ nrows, ncols/), lons, 1)</div>
<div>data@lat2d = conform_dims((/ nrows, ncols/), lats, 0)</div>
<div>data@_FillValue = missingVal</div>
<div><br>
</div>
<div>;---- Open shapefile and read lat/lon values.</div>
<div><br>
</div>
<div>shp_filename = "Cuenca_Universidad.shp" </div>
<div>data_mask = shapefile_mask_data(data,shp_f<wbr>ilename,True)</div>
<div><br>
</div>
<div>;--- Area ?</div>
<br>
<p></p>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</body>
</html>