Return to main page
Introduction
How to use R with Arcgis ?
Contributions
FAQ
How to contribute ?
|
Introduction
- What is R ?
R
is a language and environment for statistical computing and graphics.
It's a free software under the GPL which can be download form CRAN.
It provides a large variety of statistical models for general data
analysis. Several packages are dedicated to the problem of spatial
data. [Read more
about R]
- What is Arcgis ?
ArcGIS
is a Geographical Information System family of software products that
form a complete GIS built on industry standards. ArcGIS is a complete,
single, integrated system for geographic data creation, management,
integration, and analysis.
How to use R with Arcgis ?
It's very simple, just follow this procedure:
- Launch Arcmap.
- Create a new map or import a previous one.
- Name and Save your project (Let's call it "My
Project")
- Launch the Visual Basic editor [screenshot]
- Select all the references corresponding to the R DCOM
server [screenshot1] [screenshot2]
Congratulations, you are now able to use the objects
provided by the server !
To test your installation, you need to:
- Create a VBA form in "My Project.mxd" by inserting a
User Form [screenshot]
- Create a button "CommandButton1"
in the form, double click on it and Copy/Paste the following code in
the callback:
Private Sub CommandButton1_Click()
Dim RLink As StatConnector
Dim mean As Double
Dim n As Long
n = 150
Set RLink = New StatConnector
RLink.Init ("R")
RLink.SetSymbol "n", n
RLink.EvaluateNoReturn ("x <- rnorm(n,5,2)")
' mean = RLink.GetSymbol("mean(x)") Incorrect: mean(x) is not a symbol
RLink.EvaluateNoReturn ("m <- mean(x)")
mean = RLink.GetSymbol("m")
RLink.Close
MsgBox "The mean is " & mean, vbOKOnly, "Powered by R"
End Sub
If you get a message box, everything is probably ok !
Contributions
- The previous demo [link]
- Create a Raster Layer (log (redBand + 1)) from an
existing raster layer in Arcgis [link]
FAQ
How to contribute ?
|