I want to work with raster data in R, but I have problems exporting my raster dataset from ArcMap. By "export data"/GRID I get a file with an *.aux extension. What I need is *.grd.
Can anybody help me out?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
The answer is do not export, because there is no need to. You can directly read Arc* grid data with the raster package (when library rgdal is availabled). And if you export, it is better to avoid ascii (use e.g. GTiff).
library(raster) library(rgdal) #For an arc/grid (albem_s1 is the folder!): r <- raster("G:/USGS/DEM/7_5min/VA/albem_s1") #For a geotiff r <- raster("G:/USGS/DEM/7_5min/VA/albem_s1.tif")
A more convenient solution for reading is provided by @RobertH elsewhere in this thread. You can read the Arc* grid dataset directly using the same approach described here: simply reference the folder in which the grid datafiles lie in the
In Arc*, use the
Raster to ASCII tool (found in
Conversion Tools|From Raster) to export a grid in ASCII format.
R, load the
rgdal packages, then read the raster using the
raster function, as in
r <- raster("G:/USGS/DEM/7_5min/VA/albem_s1.txt") plot(r)
To create the .grd version, use
writeRaster, as in
The console response will describe what's in the .grd part of the output (the data are in a .gri file), as in
class : RasterLayer filename : G:/USGS/DEM/7_5min/VA/albem_s1.grd nrow : 1415 ncol : 1133 ncell : 1603195 min value : 70 max value : 960 projection : +proj=utm +zone=17 +ellps=GRS80 +datum=NAD83 +units=m +no_defs +towgs84=0,0,0 xmin : 686280 xmax : 720270 ymin : 4179990 ymax : 4222440 xres : 30 yres : 30
It doesn't appear that an ESRI GRID file has a single file with a .grd extension. Instead it seems to be a multi-folder/multi-file format that ArcMap sees as one file (akin to how shapefiles and ArcInfo coverages work). In any case the .aux file is a helper file to the GRID format that stores information that can't be stored in the raster itself. Here are some links that talks about it:
About auxiliary files http://webhelp.esri.com/arcgiSDEsktop/9.3/index.cfm?TopicName=About_auxiliary_files
When is an .aux file created? http://support.esri.com/en/knowledgebase/techarticles/detail/29821
convert your raster data to ascii and save in any of your directory. then n R
library(rgdal) libray(sp) data<-readGDAL("C:/filepath/file")
this will read your ascii grided file you can also chech your data by varioud commands such as
alernatively save your raster data as TIFF then using the same package (rgdal) it reads the tiff files you will read as