PythonDataScienceHandbook icon indicating copy to clipboard operation
PythonDataScienceHandbook copied to clipboard

how to read asc file in python

Open haritha1022 opened this issue 3 years ago • 2 comments

hello sir I have couple of asc files in each file there is a some meteorological data (temperature,humidity)

previous, I worked with netcdf ,grib data now my data extension is asc format plain text how can i read this .asc format file

haritha1022 avatar Feb 16 '22 09:02 haritha1022

You can simply load this type of file using numpy. EX: import numpy as np ascii_grid = np.loadtxt("filename.asc")

UditSharma9999 avatar Jul 10 '22 07:07 UditSharma9999

@haritha1022: .asc files are simple text files with 6 line headers. These lines contains the geographic information. You can use the loadtxt function in numpy, however, you need to skip the first 6 lines. Here's an example:

import numpy as np
ascii_grid = np.loadtxt("bio_1.asc", skiprows=6)

rajtilakjee avatar Nov 11 '22 06:11 rajtilakjee