Reputation: 11
I am new to spatial analysis and so I might have a silly question.
My problem is that I am using read.asciigrid()
to read in a large ascii file.
When I try the function fails because it says object 'cellsize' not found
.
My problem is that I know that there is a cellsize object in the files header, as it has the layout:
ncols
nrows
xllcorner
yllcorner
cellsize
NODATA_value
I am not sure what the problem is, is there a way of getting around this 'missing' object or could possibly narrow down where the problem might be on my end?
Upvotes: 1
Views: 683
Reputation: 1
I had the same problem and found that the .asc files I was trying to use had a leading space before all the header object names like:
cellsize xxxx
NODATA_value xxxx
instead of
cellsize xxxx
NODATA_value xxxx
Hopefully this is your problem, as you can simply delete the spaces in the asc file using a text editor.
Upvotes: 0
Reputation: 2417
I would recommend either using readGDAL() in the rgdal package or raster() in the raster package. The readGDAL funciton will return an sp object whereas raster will return a raster object. For the most part if you are wanting to conduct raster analysis in R you want to use the raster package because it is memory safe and has many useful functions for overlay and focal analysis.
Upvotes: 1