Geospatial software can typically display these data sets; however, traditional image software and libraries usually do not.
For simplicity in this chapter, we'll stick to the ASCIIGRID format for data, which is both human and machine readable, as well as being widely supported.
The following lines are a sample of a grid header: Line 1 contains the number of columns in the grid, which is synonymous with the x axis.
Line 2 represents the y axis described as a number of rows.
In some examples, we'll use the number zero; however, zero can often also be a valid data value.The numpy.loadtxt() method includes an argument called skiprows , which allows you to specify a number of lines in the file to be skipped before reading array values.To try this technique out you can download a sample grid file called my at the following URL: https://geospatialpython.googlecode.com/files/my So for my we would use the following code: This line results in the variable my Array containing a numpy array derived from the ASCIIGRID file my The only catch is, we must build and add the six lines of header information before we dump the array to the file.This process is slightly different depending on if you are using Num Py versions before 1.7 or after.