[R] Incorporate a shapefile with an package animation

Steve_Friedman at nps.gov Steve_Friedman at nps.gov
Thu May 31 20:07:56 CEST 2012


Hello

I'm working with NetCDF files in an animation and am trying to superimpose
a shapefile on the image as it is generates the html pages.

If I take out the lines for the shapefile, it works correctly, however I'm
having difficultly including the shapefile.

If anyone has any ideas I would greatly appreciate the assistance.


R Version  2.15.0 (2012-03-30)
Platform i386-pc-mingw32/i386 (32-bit

----------------------------------------------------------------------------------------------------------------------------------------------------------
### Animation of EDEN real time uncorrected data.

library(animation)
library(ncdf)
library(fields)
library(maptools)



ENP_WCA <-
readShapePoly(system.file("U:\\GIS_Data\\GISlayers\\Boundaries_Lines\\EVERareas_Dissolve.shp",
      package="maptools")[1], proj4String=CRS("+proj=utm  +zone17
+datum=WGS84"))

 # here an error is reported.
 (Error in getinfo.shape(filen) :  Error opening SHP file


#  change to the working directory where the NetCDF file is stored

setwd("A:\\Work_Area\\Steve\\EDEN")

eden <- open.ncdf("Jan_9-28_2011_q1_rt.nc")
print(eden)


Stage <- get.var.ncdf(nc=eden, varid = "stage")

 saveHTML({
        for (i in 1:90) {
          image.plot(Stage[, , i], zlim=c(-20,500), main = "EDEN Jan 10 -
28 2011\n  Uncorrected Real Time Stage")
          plot(ENP_WCA, col="black")
         }
        }, img.name = "Stage.img", imgdir = "EDEN_dir", htmlfile =
"Eden_stage.html",
           autobrowse = FALSE, title = "TIME SALINITY PREDICTIONS",
        description = c("EDEN Real Time Uncorrected Data")
      )


Thanks for your attention.


Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

Steve_Friedman at nps.gov
Office (305) 224 - 4282
Fax     (305) 224 - 4147



More information about the R-help mailing list