Reputation: 265
I have downloaded some global climate model data from an opensource website. But, these data are in .asc file format. How could I read/extract these data using Python? Anything in Numpy?
Upvotes: 3
Views: 31740
Reputation: 984
.asc means you likely chose the ASCII Grid download option from CCAFS. These are simple text files with a 6 line header containing the geographic information.
If you just want to load the data into a numpy array you can use the loadtxt
function. You just have to skip the first 6 rows which contain the header.
import numpy as np
ascii_grid = np.loadtxt("bio_1.asc", skiprows=6)
If you want to preserve the geographic information in the ASCII Grid while working in Python there is a tutorial by Joel Lawhead over at Geospatial Python.
Upvotes: 21