See a sample of the file below. The file appears to be in an ArcGIS ascii format, but reads as all zeros if you import it as a raster to either ArcGIS or R. I would like to convert each of the text classes (16 total) to numeric form while keeping nodata as -9999. The file is 15 mb. Any help is appreciated.
cols 1520
nrows 1550
xllcorner 7517937.93364
yllcorner -3188304.43924
cellsize 25
NODATA_value -9999
"-9999" "SE" "SW" "N" "N"
"-9999" "-9999" "N" "SE" "N"
"-9999" "-9999" "N" "SW" "N"
You can do something like:
x <- readLines('file.asc')
x <- gsub("N", 0, x)
x <- gsub("S", 180, x)
# etc.
writeLines(x, 'newfile.asc')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.