Skip to content

Instantly share code, notes, and snippets.

@robinkraft
Created February 13, 2012 00:52
Show Gist options
  • Save robinkraft/1812275 to your computer and use it in GitHub Desktop.
Save robinkraft/1812275 to your computer and use it in GitHub Desktop.
Replace Hansen missing values -9999 with 0
# gdal_translate -ot Byte -of GTiff -a_nodata 0 IDN_new.asc IDN.tif
fp = open("IDN.asc", "r")
fout = open("IDN_new.asc", "w")
n = 0
for line in fp:
# replace -9999 with zeros - much smaller file
newline = "0".join(line.split("-9999"))
fout.write(newline)
n += 1
if n % 100 == 0:
print "Line %i" % n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment