• Nenhum resultado encontrado

A Process and Environment for Embedding The R Software into TerraLib

N/A
N/A
Protected

Academic year: 2022

Share "A Process and Environment for Embedding The R Software into TerraLib"

Copied!
24
0
0

Texto

(1)

A Process and Environment for Embedding The R Software into

TerraLib

Pedro Ribeiro de Andrade Neto Paulo Justiniano Ribeiro Junior

GeoInfo 2005

(2)

Outline

Introduction

Related Works

aRT

Process for Integration

Conclusions

(3)

TerraLib

Library for building customized GIS

For programmers

Needs specialized statistics analysis

DBMS

TerraLib

Jfddfjh gfsdfgdfssf fsdf fsdfsd sdfsdf Jfddfjh gfsdfgdfssf fsdf fsdfsd sdfsdf Jfddfjh gfsdfgdfssf fsdf fsdfsd sdfsdf

(4)

R Project for Statistical Computing

Free software

Point pattern analysis: spatstat, splancs

Geostatistics: gstat, geoR, geoRglm

Areal data analysis: DCluster, spdep

32 packages currently available in the Spatial Task View on the CRAN repository

Shared library (.dll, .so)

(5)

Integration

Coupling R inside TerraLib

Can benefit from specialized spatial statistical methods:

Point pattern analysis

Geostatistics

Areal data analysis

(6)

Objective

Propose an efficient way to incorporate R analysis scripts into TerraLib

Use R as an evolving library for building personalized TerraLib based GIS

Meet the needs of three agents:

Statisticians

TerraLib users (programmers)

GIS users

(7)

Related Works for R Users

R packages to access GIS data/functionalities:

GRASS (Bivand and Netler 2000)

RArcInfo (Gómes-Rubio 2005)

rgdal (Keith and Bivand 2004)

aRT (Andrade Neto et. al. 2005) Problem:

They require R knowledge, and then the target is statisticians/R users

(8)

Example of an R Script

conn = openConn(user="pedro") db = openDb(conn, "dbname")

thpoints = openTheme(db, "themepoints") thborder = openTheme(db, "themeborder") points = getPoints(thpoints)

border = getPolygons(thborder) data = getData(thpoints)

raster = krige(points, border, data) l = createLayer(db, "lraster")

addRaster(l, raster)

thraster = createTheme(l, "themeraster")

(9)

Related Works for GIS Users

Graphic interfaces to R:

Ono et. al. 2003

Tait et. al. 2004

Problems:

They describe the functionality, but not the proccess to aggregate new functionalities

They exchange information with R using files

(10)

Related Works for GIS Programmers

No works...

(11)

The aRT package: R-TerraLib API

R package that can connect to TerraLib databases

Scripts for statistical analysis of data

Rule for aRT scripts: all data using database

(12)

aRT script

conn = openConn(user="pedro") db = openDb(conn, "dbname")

thpoints = openTheme(db, "themepoints") thborder = openTheme(db, "themeborder") points = getPoints(thpoints)

border = getPolygons(thborder) data = getData(thpoints)

raster = krige(points, border, data) l = createLayer(db, "lraster")

addRaster(l, raster)

thraster = createTheme(l, "themeraster")

(13)

aRT results

(14)

How to integrate

Option 1

Execute R from the GIS and run the entire script

Problem: two connections to the database, and after that the GIS must reconnect to read metadata

Option 2

Use aRT internal functions to read from the database and build R objects to be used

Problem: TerraLib programmers must know R and aRT internally.

(15)

TeDatabase*

How to integrate: Option 3

Share a database

connection (TeDatabase)

Require little changes in the original script

(16)

Example of an aRT Script

conn = openConn(user="pedro") db = openDb(conn, "dbname")

thpoints = openTheme(db, "themepoints") thborder = openTheme(db, "themeborder") points = getPoints(thpoints)

border = getPolygons(thborder) data = getData(thpoints)

raster = krige(points, border, data) l = createLayer(db, "lraster")

addRaster(l, raster)

thraster = createTheme(l, "themeraster")

(17)

Wrapping an R code

tlKriege = function(db, tpointsname,

tcontourname, lrastername, trastername){

thpoints = openTheme(db, tpointsname) thborder = openTheme(db, tbordername) points = getPoints(thpoints)

border = getPolygons(thborder) data = getData(thpoints)

raster = krige(points, border, data) l = createLayer(db, lrastername)

addRaster(l,raster)

thraster = createTheme(l, trastername) return(invisible())

}

(18)

TeRwrapper

Uses MyR library

Operations:

Initialize the environment

Declare a TeDatabase

Execute an R command

(19)

TerraLib code

TeDatabase* db; char* str;

TeRwrapper* Rwrapper; string error;

...

Rwrapper = new TeRwrapper();

Rwrapper->declareDatabase(db, "db");

asprintf(&str, "tlKrige(db,%s,%s,%s,%s)", themepoints.c_str(),

themeborder.c_str(), layerraster.c_str(), themeraster.c_str());

error = Rwrapper->execute(str);

if(error != "") ...

OnPaint();

(20)

Integration Diagram

(21)

Results

Note that aRT alone could do that, but the focus now is how to use this functionality without any R knowledge.

(22)

Conclusions

Powerful analysis environment for statistics professionals

Follows TerraLib project purposes

Enables each agent to focus on his/her environment and skills

(23)

Future Work

TerraCitrus, developing friendly interfaces

Define a language for documentation of the

functions, and try to generate part of the graphic interface for the programmers

Ideas??

(24)

A Process and Environment for Embedding The R Software into

TerraLib

Pedro Ribeiro de Andrade Neto Paulo Justiniano Ribeiro Junior

GeoInfo 2005

Referências

Documentos relacionados

De fato, no que se refere aos adultos e aos jovens, embora os sujeitos com nível fundamental de escolaridade pouco se diferen- ciem quanto à atribuição da origem do Regime Militar a

A inspeção técnica obrigatória aos motociclos foi, pela primeira vez, anunciada no Plano Nacional de Prevenção Rodoviária de 2003, onde se estabeleceu a necessidade de alargar

O objetivo deste trabalho foi avaliar os efeitos da estocagem em baixas temperaturas (7,5 ± 1 ºC) sobre a eclodibilidade, perda de peso dos ovos, peso ao nascer e a

Valores médios das variáveis de desempenho e da concentração sérica de ácido úrico de codornas japonesas na fase de 1 a 21 dias de idade em função das

Práticas de Letramento com crianças de 36 a. 48 meses e

A necessidade absoluta não caracteriza uma causalidade linear na qual os acidentes são irredutivelmente rebaixados em relação à causa originária, mas Hegel a

6.404, de 15 de dezembro de 1976, em reunião realizada às 10h de hoje, examinaram o Relatório da Administração; a Declaração dos Diretores sobre as

Os precursores cognitivos da leitura e da escrita são elementos essenciais no desenvolvimento da criança, de forma que na contemporaneidade nas práticas cotidianas familiares