<div dir="ltr"><div dir="ltr">Those are geographic coordinates, approximately correct for the Spring Fire; and they are swapped. Therefore, use the <b>replacement shapefile_utils.ncl</b>; and <b>do not</b> convert any farther with ogr2ogr.</div><div dir="ltr"><br></div><div dir="ltr">Use this diagnostic to make a simple check plot for the whole perimeter. This is from the shapefiles example page, under "Shapefile plotting and masking routines". This will find out whether NCL can fully understand this shapefile and place it on a map. This is silent, but it should immediately write a PNG file in your working directory. Open the PNG file with any browser or graphics viewer.</div><div dir="ltr"><div><br> load "./shapefile_utils.ncl" (the replacement version)<br> plot_shapefile("shapefile_name.shp")<br></div></div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 6, 2022 at 3:50 PM Vanessa Vincente <<a href="mailto:vincente@ucar.edu">vincente@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dave and Rick,<div><br></div><div>Thank you both for your help. I have conducted the test locally, and get the following:</div><div><br></div><div>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Variable: x</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Type: double</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Total Size: 110992 bytes</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span> </span>13874 values</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Number of Dimensions: 1</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Dimensions and sizes:<span style="white-space:pre-wrap"> </span>[num_points | 13874]</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Coordinates:<span> </span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><span> </span>num_points: not a coordinate variable</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">Number of Attributes: 0</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">(0)<span style="white-space:pre-wrap"> </span>Print MinMax for x...</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">(0)<span style="white-space:pre-wrap"> </span>min=37.39254516610051 <span> </span>max=37.69200009599813</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">(0)<span style="white-space:pre-wrap"> </span>Print MinMax for y...</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">(0)<span style="white-space:pre-wrap"> </span>min=-105.2910941200151 <span> </span>max=-105.0002034698655</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p>I did this test using both the original shapefile_utils.ncl and replacement shapefile_untils.ncl, and got the same output. It looks like latitudes are x and latitudes are y. Does this mean I can use the original shapefile_utils.ncl, but I still need to deproject the Perimeter_...shp file using ogr2ogr? If so, can you please provide a bit more guidance on how I can deproject?</div><div><br></div><div>Thanks,</div><div>Vanessa</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 6, 2022 at 1:02 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Rick, thank you for discovering the projection problem. Here is a simple way to determine whether coordinates are swapped. Remember, the swapping bug is a characteristic of the local NCL installation, not the shapefile. So Vanessa will need to do this test locally. Exclude all outside influences, and verify the reprojected shapefile by NCL direct access:</div><div><div><br></div><div> f = addfile (shapefile_name, "r")<br> printFileVarSummary(f,"x")<br> printMinMax (f->x, 0)</div><div> printMinMax (f->y, 0)<br></div><div><br></div><div>If geographic projection, then longitudes are x, and latitudes are y. This will immediately tell you whether NCL is reading normal or swapped coordinates, also whether the shapefile is even valid or readable. It will also determine metric vs. geographic coordinates, if you understand what ranges to expect.</div><div><br></div><div>If the coordinates are normal from this test, then use the original shapefile_utils.ncl. If the coordinates are swapped, then use the replacement shapefile_utils.ncl.</div><br></div><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 6, 2022 at 12:39 PM Rick Brownrigg <<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Actually, it turned out to be quite easy to deproject the file with ogr2ogr:</div><div><br></div><div> ogr2ogr -t_srs EPSG:4326 Perimeter_20180715_SpringCreek_COHUX001313_latlon.shp Perimeter_20180715_SpringCreek_COHUX001313.shp</div><div><br></div><div>The resultant coords are definitely in lat/lon and look like values for Colorado. I *assume* ogr2gr used the information in the *.prj file, to properly set up the requisite deprojection parameters -- check that the outline is spatially registered correctly. Also, the swapped X/Y *may* still be an issue, I can't tell.</div><div><br></div><div>Rick</div><div> <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 6, 2022 at 12:17 PM Rick Brownrigg <<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Vanessa,</div><div><br></div><div>The issue is that the Perimeter_xxxx.shp file's coordinates are in meters in a Mercator Projection, as seen by the associated Perimeter_xxxx.prj file (and verified by using NCL to print the x/y coordinates). NCL can only deal with shapefiles in geographic (lat/lon) coordinates. It's not clear to me whether the X/Y values are also swapped in this case; I can't tell by looking at the values.</div><div><br></div><div>There are a couple of ways forward: The GDAL package has a command, ogr2ogr, that in principle, can perform the needed deprojection. Another possible solution is that NCL has an undocumented interface to the PROJ cartographic projection library that could do the deproject. Both of these would take me some experimentation to get it right. I won't be able to give it a try until later this evening. <br></div><div><br></div><div>Perhaps the best, easiest, and do-it-yourself solution is that if you have access to GIS tools such as ArcGIS, that could also create a geographic-coords version of your shapefile.</div><div><br></div><div>Rick <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 6, 2022 at 11:36 AM Vanessa Vincente via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thank you for sharing this workaround. I have replaced the shapefile_utils.ncl with the one provided, and ran the code, but it is still not displaying the burn scar perimeter polygon. I am running the ncl code in the directory that houses all the shapefiles and the new shapefile_utils.ncl.<div><br></div><div><div>I am using version 6.6.2 and the source of the NCL installation was conda 4.11.0.</div></div><div>Below is a copy of my code again for reference.</div><div><br>load "./shapefile_utils.ncl"<br><br>;----------------------------------------------------------------------<br>; This function creates a cylindrical equidistant map of Colorado.<br>;----------------------------------------------------------------------<br><br>function create_colorado_map(wks,res,draw_ncl_outlines)<br>local a, mpres<br>begin<br> mpres = res<br><br> mpres@gsnMaximize = True<br> mpres@gsnPaperOrientation = "portrait"<br><br> mpres@gsnDraw = False<br> mpres@gsnFrame = False<br><br> mpres@mpFillOn = False <br><br>;---Turn on fancier tickmark labels.<br> mpres@pmTickMarkDisplayMode = "Always"<br> mpres@tmXBLabelFontHeightF = 0.008 ; smaller tickmark labels<br><br>;---Zoom in on area of interest<br> mpres@mpLimitMode = "LatLon"<br> mpres@mpMinLatF = 37<br> mpres@mpMaxLatF = 41<br> mpres@mpMinLonF = -109.05<br> mpres@mpMaxLonF = -102.05<br> mpres@mpFillOn = False<br><br> if(draw_ncl_outlines) then<br> mpres@mpOutlineOn = True<br> mpres@mpOutlineBoundarySets = "AllBoundaries"<br> mpres@mpDataBaseVersion = "MediumRes"<br> mpres@mpDataSetName = "Earth..4" ; U.S. counties<br> else<br> mpres@mpOutlineOn = False<br> end if<br><br>;---Create map.<br> map = gsn_csm_map(wks,mpres)<br><br> return(map)<br>end<br><br>;--------------------------------------------------<br>; Main code<br>;--------------------------------------------------<br>begin<br> wtype = "png" ; send graphics to PNG file<br> wtype@wkWidth = 2000<br> wtype@wkHeight = 2000<br> wks = gsn_open_wks(wtype,"shapefiles")<br><br> ncl_version = get_ncl_version()<br><br>;---Create two maps of Colorado<br> res = True<br> res@tiMainFontHeightF = 0.015<br> <br> res@tiMainString = "Colorado counties - shapefile"<br> map_shp = create_colorado_map(wks,res,False)<br><br> res@tiMainString = "Colorado counties - NCL (version " + ncl_version + ")"<br> map_ncl = create_colorado_map(wks,res,True)<br><br>;---Add shapefiles to one of the maps<br> lnres = True<br> lnres@gsLineColor = "red"<br><br> plot_line_shp = gsn_add_shapefile_polylines(wks,map_shp,"./usa/gadm40_USA_2.shp",lnres)<br><br>;---Add a slightly transparent marker to both maps to show location of county updates<br> mkres = True<br> mkres@gsMarkerIndex = 16 ; filled dot<br> mkres@gsMarkerOpacityF = 0.5 ; make the marker half transparent<br> mkres@gsMarkerColor = "red"<br> mkres@gsMarkerSizeF = 50.<br><br> counties_lat_center = 39.8<br> counties_lon_center = -104.9<br> <br> plot_marker_ncl = gsn_add_polymarker(wks,map_ncl,counties_lon_center,counties_lat_center,mkres)<br> plot_marker_shp = gsn_add_polymarker(wks,map_shp,counties_lon_center,counties_lat_center,mkres)<br><br>print("Adding polygons to ncl map and shp map...")<br><br>filename = "Perimeter_20180715_SpringCreek_COHUX001313.shp"<br> <br> ;---Set some options for the polygons<br> bscar = True<br> bscar@gsLineColor = "Blue"<br> bscar@gsLineThicknessF = 3.0 ; 3x thickness<br> <br>id1 = gsn_add_shapefile_polygons(wks,map_ncl,filename,bscar)<br>id2 = gsn_add_shapefile_polygons(wks,map_shp,filename,bscar)<br><br>;---Panel both plots. Markers, lines, and polygons will be drawn.<br> pres = True<br> pres@gsnMaximize = True<br> gsn_panel(wks,(/map_ncl,map_shp/),(/1,2/),pres)<br> <br>end<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 5, 2022 at 4:39 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>You may have encountered a known bug whereby the X and Y coordinates from a shapefile are swapped with each other. We think this was caused by a change in an underlying library. Please see this report for details and a possible easy workaround. Let us know if that works.</div><div><br></div><div> <a href="https://github.com/NCAR/ncl/issues/176" target="_blank">https://github.com/NCAR/ncl/issues/176</a><br></div><div><br></div><div>What version of NCL are you using, and what was the source of your NCL installation?</div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 5, 2022 at 4:29 PM Vanessa Vincente via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I am having trouble plotting polygon data from a shapefile of a burn scar perimeter over a map of Colorado with counties. I am using the example shapefiles_15.ncl from the <a href="https://www.ncl.ucar.edu/Applications/shapefiles.shtml" target="_blank">ncl page</a>. I am able to successfully plot the state of Colorado and its counties, but not the burn scar perimeter. Burn scar shapefile can be found <a href="https://ftp.wildfire.gov/public/incident_specific_data/rocky_mtn/2018/SpringCreek/IR/20180715/PerimeterFileProvidedByIncident/" target="_blank">here</a>. Can you please help? Thanks in advance!</div><div><br></div><div>Below is a copy of my ncl script:</div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"<br>load "./shapefile_utils.ncl"<br><br>;----------------------------------------------------------------------<br>; This function creates a cylindrical equidistant map of Colorado.<br>;----------------------------------------------------------------------<br><br>function create_colorado_map(wks,res,draw_ncl_outlines)<br>local a, mpres<br>begin<br> mpres = res<br><br> mpres@gsnMaximize = True<br> mpres@gsnPaperOrientation = "portrait"<br><br> mpres@gsnDraw = False<br> mpres@gsnFrame = False<br><br> mpres@mpFillOn = False <br><br>;---Turn on fancier tickmark labels.<br> mpres@pmTickMarkDisplayMode = "Always"<br> mpres@tmXBLabelFontHeightF = 0.008 ; smaller tickmark labels<br><br>;---Zoom in on area of interest<br> mpres@mpLimitMode = "LatLon"<br> mpres@mpMinLatF = 37<br> mpres@mpMaxLatF = 41<br> mpres@mpMinLonF = -109.05<br> mpres@mpMaxLonF = -102.05<br> mpres@mpFillOn = False<br><br> if(draw_ncl_outlines) then<br> mpres@mpOutlineOn = True<br> mpres@mpOutlineBoundarySets = "AllBoundaries"<br> mpres@mpDataBaseVersion = "MediumRes"<br> mpres@mpDataSetName = "Earth..4" ; U.S. counties<br> else<br> mpres@mpOutlineOn = False<br> end if<br><br>;---Create map.<br> map = gsn_csm_map(wks,mpres)<br><br> return(map)<br>end<br><br>;--------------------------------------------------<br>; Main code<br>;--------------------------------------------------<br>begin<br> wtype = "png" ; send graphics to PNG file<br> wtype@wkWidth = 2000<br> wtype@wkHeight = 2000<br> wks = gsn_open_wks(wtype,"shapefiles")<br><br> ncl_version = get_ncl_version()<br><br>;---Create two maps of Colorado<br> res = True<br> res@tiMainFontHeightF = 0.015<br> <br> res@tiMainString = "Colorado counties - shapefile"<br> map_shp = create_colorado_map(wks,res,False)<br><br> res@tiMainString = "Colorado counties - NCL (version " + ncl_version + ")"<br> map_ncl = create_colorado_map(wks,res,True)<br><br>;---Add shapefiles to one of the maps<br> lnres = True<br> lnres@gsLineColor = "red"<br><br> plot_line_shp = gsn_add_shapefile_polylines(wks,map_shp,"./usa/gadm40_USA_2.shp",lnres)<br><br>;---Add a slightly transparent marker to both maps to show location of county updates<br> mkres = True<br> mkres@gsMarkerIndex = 16 ; filled dot<br> mkres@gsMarkerOpacityF = 0.5 ; make the marker half transparent<br> mkres@gsMarkerColor = "red"<br> mkres@gsMarkerSizeF = 50.<br><br> counties_lat_center = 39.8<br> counties_lon_center = -104.9<br> <br> plot_marker_ncl = gsn_add_polymarker(wks,map_ncl,counties_lon_center,counties_lat_center,mkres)<br> plot_marker_shp = gsn_add_polymarker(wks,map_shp,counties_lon_center,counties_lat_center,mkres)<br><br>print("Adding polygons to ncl map and shp map...")<br><br>filename = "Perimeter_20180715_SpringCreek_COHUX001313.shp"<br> <br> ;---Set some options for the polygons<br> bscar = True<br> bscar@gsLineColor = "Blue"<br> bscar@gsLineThicknessF = 3.0 ; 3x thickness<br> <br>id1 = gsn_add_shapefile_polygons(wks,map_ncl,filename,bscar)<br>id2 = gsn_add_shapefile_polygons(wks,map_shp,filename,bscar)<br><br>;---Panel both plots. Markers, lines, and polygons will be drawn.<br> pres = True<br> pres@gsnMaximize = True<br> gsn_panel(wks,(/map_ncl,map_shp/),(/1,2/),pres)<br> <br>end</div>-- <br><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font color="#000000">Vanessa Vincente<br>Associate Scientist<br>The COMET® Program<br>University Corporation for Atmospheric Research</font><br><div dir="ltr"></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div></div></blockquote></div></blockquote></div>
</blockquote></div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font color="#000000">Vanessa Vincente<br>Associate Scientist<br>The COMET® Program<br>University Corporation for Atmospheric Research<br></font><br>*My working hours may differ from your own. Please do not feel obligated to reply outside of standard business hours.*<div dir="ltr"></div></div></div></div></div></div></div></div></div></div>
</blockquote></div></div>