GE_SpatialGrid

0th

Percentile

Create SpatialGrid for PNG output to GE

The function sets up metadata in the form of a SpatialGrid object for defining the size and placing of a PNG image overlay in Google Earth.

Keywords
spatial
Usage
GE_SpatialGrid(obj, asp = NA, maxPixels = 600)
Arguments
obj
a Spatial* object
asp
if NA, will be set to the latitude corrected value
maxPixels
the maximum dimension of the output PNG
Details

The function is used together with kmlOverlay to wrap around the opening of a PNG graphics device, plotting code, and the closing of the device. The computed values take account of the adjustment of the actual data bounding box to an integer number of rows and columns in the image file.

The approach may be used as an alternative to writing PNG files from SpatialGrid and SpatialPixel objects in rgdal using writeGDAL, and to writing KML files using writeOGR for vector data objects. The output PNG files are likely to be very much smaller than large vector data KML files, and hinder the retrieval of exact positional information.

Value

  • returns an S3 object of class GE_SG with components:
  • heightInteger raster height for png call
  • widthInteger raster width for png call
  • SGa SpatialGrid object with the grid topology of the output PNG
  • aspthe aspect value used
  • xlimxlim taken from SG
  • ylimylim taken from SG

See Also

kmlOverlay

Aliases
  • GE_SpatialGrid
Examples
opt_exask <- options(example.ask=FALSE)
qk <- SpatialPointsDataFrame(quakes[, c(2:1)], quakes)
proj4string(qk) <- CRS("+proj=longlat")
tf <- tempfile()
SGqk <- GE_SpatialGrid(qk)
png(file=paste(tf, ".png", sep=""), width=SGqk$width, height=SGqk$height,
  bg="transparent")
par(mar=c(0,0,0,0), xaxs="i", yaxs="i")
plot(qk, xlim=SGqk$xlim, ylim=SGqk$ylim, setParUsrBB=TRUE)
dev.off()
kmlOverlay(SGqk, paste(tf, ".kml", sep=""), paste(tf, ".png", sep=""))
qk0 <- quakes
qk0$long <- ifelse(qk0$long <= 180, qk0$long, qk0$long-360)
qk0a <- SpatialPointsDataFrame(qk0[, c(2:1)], qk0)
proj4string(qk0a) <- CRS("+proj=longlat")
writeOGR(qk0a, paste(tf, "v.kml", sep=""), "Quakes", "KML")
system(paste("googleearth ", tf, ".kml", sep=""))
options(example.ask=opt_exask)
Documentation reproduced from package maptools, version 0.6-15, License: GPL version 2 or later (R and interface code), MIT (shapelib code)

Community examples

Looks like there are no examples yet.