[R-sig-Geo] Beginners question: From text-raster to grid / map

Crowe, Andrew a.crowe at lancaster.ac.uk
Fri Sep 17 13:49:28 CEST 2010


You could add a header to the ascii file to give it the ESRI format which can then be read into R using the readAsciiGrid function from the maptools package and viewed with the image function
 
The file should look something like this:
ncols         4
nrows         3
xllcorner     2.0
yllcorner     8.0
cellsize      2.0
NODATA_value  -9999
3 6 7 4
2 3 4 5
4 5 5 6

R commands:
library(maptools)
ingrid <- readAsciiGrid("full_file_path")
image(ingrid)
 
HTH
 
Andrew
 
Dr Andrew Crowe
 
Lancaster Environment Centre
Lancaster University
Lancaster    LA1 4YQ
UK
 

________________________________

From: r-sig-geo-bounces at stat.math.ethz.ch on behalf of PEP Serra Diaz
Sent: Fri 17/09/2010 12:24 PM
To: r-sig-geo at stat.math.ethz.ch
Subject: Re: [R-sig-Geo] Beginners question: From text-raster to grid / map



Sorry, the inteded data.frame is to be like this:

X  Y  VALUE
2  8  4
4  8  5
6  8  5
8  8  6
2 10 2
4 10 3
6 10 4
8 10 5
2 12 3
4 12 6
6 12 7
8 12 4



----- Missatge original -----
De: PEP Serra Diaz <Josep.Serra at uab.cat>
Data: Divendres, Setembre 17, 2010 1:16 pm
Assumpte: Beginners question: From text-raster to grid / map

>
> Dear R-SIGers,
>
> I would like to know which function to use in order to plot a map.
>
> I know my origin of coordinates (x=2,y=8), and my resolution (2)
>
> And I have an ASCII/txt file as an output matrix
>
> 3 6 7 4
> 2 3 4 5
> 4 5 5 6
>
> I would like to plot a map for these values and/or alternatively
> get a table like that (in other words, assign coordinates to each
> value of the text.file (matrix))
>

>
> Thanks,
>
> Pep
>

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list