I have a .asc climate data file at hand and want to explore it to extract some information.
Based on searching, some general read methods have been tried as, import it as python pandas or numpy structure to see its contents.
Here the result:
if read in using pandas:
df = pd.read_table(path + "\max1951_1.asc")
df
NCOLS 1068
0 NROWS 510
1 XLLCORNER -141.0000
2 YLLCORNER 41.00000
3 CELLSIZE 0.83333330E-01
4 NODATA_VALUE -999.00
5 -999.00
6 -999.00
Using numpy:
ascii_grid = np.loadtxt(path + "\max1951_1.asc", skiprows=6)
ascii_grid
array([[-999., -999., -999., ..., -999., -999., -999.],
[-999., -999., -999., ..., -999., -999., -999.],
[-999., -999., -999., ..., -999., -999., -999.],
...,
[-999., -999., -999., ..., -999., -999., -999.],
[-999., -999., -999., ..., -999., -999., -999.],
[-999., -999., -999., ..., -999., -999., -999.]])
I still doubt what is the best solution or packet working with this kind of ESRI ASCII Raster format, not sure if the above print already shows all the file's content or not. Besides, my question is, if I want to extract any specific gridded cell's lat and lon information, How can I do that?
-
if asc file naturally contain those information so I can simply use certain existed packet to extract that?
-
Or the only method is use coordinate to calculate and convert base on the CELLSIZE and X,YLLCORNER.
Best Answer
You've tagged your question with ESRI-ASCII, why not use ESRI tools?
You can get properties of a raster or individual cell values. If you want to call these tools in python simply scroll to the bottom of these pages to see how to call them?