[R-sig-Geo] Reading ESRI-GRID format data
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Mon Aug 24 23:07:48 CEST 2009
On Mon, Aug 24, 2009 at 9:50 PM, <BRWIN338 at aol.com> wrote:
>
> Good Afternoon
> Does R have the ability to let me have access to the gridded data values
> for the following data?
> We downloaded the zipped file containing the data sets but are not familiar
> with how to read the data in R.
>
> Thanks
> Joe
> ######################################################################
> Description on data web page:
> Travel time to major cities: A global map of Accessibility
> The data are in geographic projection with a resolution of 30 arc seconds.
> The format is integer ESRITM GRID format with pixel values representing
> minutes of travel time. The files are stored in a zip archive. The archive
> also contains an ESRITM Shapefile of the populated places. Other files
> include Metadata (XML), and ArcView 3 Projects and Legends (APR and AVL).
> ############################################################################
> ##############
Short Answer: Quite probably...
Medium Answer: Get the rgdal package from CRAN and use the readGDAL function.
Step-by-step and long answer:
install.packages("rgdal")
library(rgdal)
GDALinfo("filename.asc") # prints out info about the raster
map = readGDAL("filename.asc") # reads in the whole raster
image(map) # does a plot
# look at the first five points - locations:
coordinates(map)[1:5,]
x y
[1,] 3366825 5814624
[2,] 3366835 5814624
[3,] 3366845 5814624
[4,] 3366855 5814624
[5,] 3366865 5814624
# values:
map at data[1:5,]
[1] 1 1 4 1 2
If your raster is too big for your PC then you'll have to read parts
of it using other options to readGDAL.
Barry
More information about the R-sig-Geo
mailing list