Não foi possível enviar o arquivo. Será algum problema com as permissões?

Essa é uma revisão anterior do documento!


Exemplo: Kernel do Splancs

Exemplo: Kernel do Splancs

Example of a spatial point proccess
Data from the splancs package
The example tranfer the data to the DBMS as well a raster with a kernel estimate of the intensity function

1. Getting started: loading required packages and the data <code R> require(aRT) require(splancs) data(bodmin) <code>

getting to know the data <code R> names(bodmin) polymap(bodmin$poly) pointmap(as.points(bodmin), add=TRUE) see the plot! <code>

2. An analysis: kernel intensity estimate

Kernel estimate from the intensity function of the point proccess performed within R using splancs' function <code R> ker ← kernel2d(as.points(bodmin), bodmin$poly, h0=2, nx=100, ny=100)

plot splancs results <code R> image(ker, asp=1, col=rev(heat.colors(21))) polygon(bodmin$poly, lwd=2) pointmap(as.points(bodmin), add=TRUE, pch=19) see the plot <code>



3. Creating a database and storing the results

connecting to the DBMS <code R> con = openConn() con <code>

how to delete an existing database (if already exists) <code R> if(any(showDbs(con)=="bodmin"))

deleteDb(con, "bodmin", force=T)

<code>

creating a new database <code R> bod = createDb(con, "bodmin") bod <code>

aRT uses "sp" representations of spatial objects. So we start converting the data to the "sp" format

a. Preparing and transfering the points <code R> xy ← as.data.frame(bodmin[1:2]) coordinates(xy) ← c("x", "y") ## l_points ← importSpData(bod, xy, "coords") <code>

checking the status of the database <code R> bod <code>

Note: the importSpData() command above encapsulates several steps (which could also be done individually with aRT):

  1. converting to SpatialPointsDataFrame (with ID specification).
  2. creating a layers, addpoints() and creating a table

b. Preparing and transfering the polygon <code R> pol ← SpatialPolygons(list(Polygons(list(Polygon(bodmin$poly)),"1")),1) l_pol ← createLayer(bod, "contorno") addPolygons(l_pol, pol) createTable(l_pol, "t_pol") <code>

c. Preparing and transfering the image (raster) general approach: converting the kernel to "sp" format <code R> g ← cbind(expand.grid(x = ker$x, y = ker$y), as.vector(ker$z)) coordinates(g) ← c("x", "y") gridded(g) ← TRUE

l_kernel ← createLayer(bod, "kernel") addRaster(l_kernel, g) <code>

alternativelly, splancs kernel objects are also directly accepted <code R> l_splancs ← createLayer(bod, "kernelsplancs") addRaster(l_splancs, ker) <code>

checking the status of the data base <code R> bod <code>

open and inspect the database in terraView!!!



4. visualisation of results in R a. plot from the "sp" objects <code R> image(g, col=rev(heat.colors(21))) contour(ker, add = T) fullgrid(g)=TRUE plot(pol, add=T, lwd=2) <code>

Ploting the DB layers – plot from aRT <code R> plot(l_kernel, col=rev(heat.colors(21))) plot(l_points, add=T, pch=19) plot(l_pol, add=T, lwd=2) <code>



5. (Optional) Setting visualisations for terraView <code R> thp ← createTheme(l_points, "points", view="vbod1") th ← createTheme(l_pol, "borders", view="vbod1") th ← createTheme(l_kernel, "raster", view="vbod1") setVisual(th, visualRaster(color=rev(heat.colors(21))), mode="r") <code>

other view using the alternative splancs layer <code R> thp ← createTheme(l_points, "points", view="vbod2") th ← createTheme(l_pol, "borders", view="vbod2")

th ← createTheme(l_splancs, "kernelsplancs", view="vbod2") setVisual(th, visualRaster(color=rev(heat.colors(21))), mode="r") <code>

checking the sattus of the data base <code R> bod <code>

open and visualise the database in terraView!!!


QR Code
QR Code software:art:curso:bodmin (generated for current page)