[ncl-talk] help reading ascii

Rick Brownrigg brownrig at ucar.edu
Wed Aug 13 09:26:18 MDT 2014


Hi John,

I think your latitude dimension might indeed be flipped.  The header gives
the lon/lat for the lower-left corner, but the first row in the file --
which will be the zero-ith row in NCL -- is the northern-most row of the
raster:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=ESRI%20ASCII%20Raster%20format

Hope that helps...
Rick


On Tue, Aug 12, 2014 at 5:31 PM, john koudelka <john.koudelka at gmail.com>
wrote:

> I need help sorting out reading in an ArcGIS ascii raster file. The
> values I pull for lat/lon locations don't match up with the values I
> am showing in ArcGIS.
>
> The result of line 8 below should be 22.47, which is the value I get
> in ArcGIS for this Lat/Lon. It's not a matter of a slight shift due to
> the center of the pixel, since the values surrounding 22.47 range from
> 21-23. I'm thinking that something's flipped in the way the ascii file
> is read. Can someone shed some light on this for me? Hopefully this is
> an easy answer that I'm missing. I wasn't able to figure this out
> searching the ncl-talk archives or reading the reference manual.
> Apologies if I did miss something glaring there.
>
>
> Here is the header of the ascii file:
> ncols 481
> nrows 481
> xllcorner -114.004167
> yllcorner 38.995833
> cellsize 0.008333
>
> Here is my code:
>
> ncl 0> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> ncl 1> tempgrid=readAsciiTable("otgrid_20091001120000.asc",481,"float",5)
> ncl 2> tempgrid!0="lat"
> ncl 3> tempgrid!1="lon"
> ncl 4> endLat=38.995833+(0.008333*481)
> ncl 5> endLon=-114.004167+(0.008333*481)
> ncl 6> lat=fspan(38.995833,endLat,481)
> ncl 7> lon=fspan(-114.004167,endLon,481)
> ncl 8> tempgrid&lat=lat
> ncl 9> tempgrid&lon=lon
> ncl 10> print(tempgrid({41.713438},{-111.71767}))
>
> Variable: tempgrid (subsection)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> Number Of Attributes: 3
>   lon : -111.7162
>   lat : 41.7097
>   _FillValue :  9.96921e+36
> (0)     25.88
> ncl 11> print(lat(1)-lat(0))
> (0)     0.008350372
> ncl 12> print(lon(1)-lon(0))
> (0)     0.008346558
> ncl 13> print(41.713438-41.7097)
> (0)     0.003734589
> ncl 14> print(-111.7167-(-111.7162))
> (0)     -0.0004959106
> ncl 15> print(tempgrid({41.704:41.722},{-111.726:-111.708}))
>
> Variable: tempgrid (subsection)
> Type: float
> Total Size: 16 bytes
>             4 values
> Number of Dimensions: 2
> Dimensions and sizes:   [lat | 2] x [lon | 2]
> Coordinates:
>             lat: [41.7097..41.71805]
>             lon: [-111.7245..-111.7162]
> Number Of Attributes: 1
>   _FillValue :  9.96921e+36
> (0,0)   26.64
> (0,1)   25.88
> (1,0)   26.28
> (1,1)   25.98
> ncl 16>
>
>
> Thanks,
> john
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140813/046d0971/attachment.html 


More information about the ncl-talk mailing list