<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"><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="OWAAutoLink" id="LPlnk519286" previewremoved="true">area_poly_sphere</a>,</span></span></p>
<p style="margin-top:0;margin-bottom:0"><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"> </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"> </span>[156]</div>
<div>Coordinates: </div>
<div>(0)<span style="white-space:pre"> </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>
<div><br>
</div>
<div>data = readAsciiTable("inventory.asc",ncols,"float",7) </div>
<div> </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 .</div>
<div><br>
</div>
<div>shp_filename = "universidad.shp" </div>
<div>data_mask = shapefile_mask_data(data,shp_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>
</span></span>
<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="OWAAutoLink" id="LPlnk24337" previewremoved="true"></a></span><br>
<br>
</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> Dennis Shea <shea@ucar.edu><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> ncl-talk@ucar.edu<br>
<b>Assunto:</b> Re: [ncl-talk] area of a shapefile</font>
<div> </div>
</div>
<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">https://www.ncl.ucar.edu/Document/Functions/Built-in/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">https://www.ncl.ucar.edu/Document/Functions/Built-in/gc_qarea.shtml</a><br>
</div>
<div>See Examples<br>
<br>
</div>
<div>Good luck<br>
</div>
<div><br>
</div>
</div>
<div class="x_gmail_extra"><br>
<div class="x_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.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_-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_<wbr>filename,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">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>