[R] Problems generating image from tiff file
Mehdi Khan
mwkhan at ucdavis.edu
Fri Jul 17 01:02:43 CEST 2009
I imported the attached tiff file and converted the coordinate system to
long lat and graphed it:
californiatiff<- readGDAL("california1.tif")
proj4string(californiatiff)
> rasterprojection <- spTransform(californiatiff, CRS("+proj=longlat")
however, when using the plot command for rasterprojection, I get a blob. I
can see the outline of the state of california and nevada, but rather than
being able to see the geographic features, it is just a monocolor blob. My
suspicion is that since it is a list of coordinates and another column that
contains attributes, I need to turn it into a polygon. I've tried the
following codes but none work:
> rasterprojection2<-SpatialPolygons(rasterprojection)
Error in is.vector(X) :
trying to get slot "Polygons" from an object of a basic class ("integer")
with no slots
rasterprojection2<- Polygons(rasterprojection)
Error in as.vector(x, "list") :
cannot coerce type 'S4' to vector of type 'list'
Essentially, all I need to do is to connect the coordinates into polygons.
What am I doing wrong?
Thank you!
More information about the R-help
mailing list