wiki:Run R program 2014

Version 21 (modified by cedric, 11 years ago) (diff)

--

back to first page..

Running EDA2 again

re -installing everything with R

The program should help you load the necessary packages. If not you can copy everything from your previous R version library to the new and use update.packages(checkBuilt=TRUE, ask=FALSE)

source("EDACCM/init.r")
#########################"
# chargement des données###loading data
############################
ccm=new("BaseEdaCCMriversegments",
		baseODBC="baseODBCccm",
		schema="ccm21",
		table="riversegments",
		prkey="gid",
		zonegeo="Ireland")
ccm<-loaddb(ccm)# C14 8644 lines

Here I have a crash, ODBC connexion fails. I have to edit the xlm file in EDA/EDAload.xml.

  • In this file, my ODBC link is called eda2local. I need to check if it's in system/administration tools/odbc there you might see the 64 bit link if you are running in R 64 bit. If you are running R 32 bits on a 64 bits system you need to place a shortcut that will point to C:\Windows\SysWOW64\odbcad32.exe.
  • I'm recreating the link so I'm using a postgres unicode driver for 64 bit. Data source eda2local dbname eda server my IP of the server of localhost, usernames and password. I've changed my password also so I need to change it in my xml file If you have to redo all, you need to rerun init.r

saving stuff before trying again

H:\base>pg_dump -U postgres -f "ccm21.riversegments2014_beforeelevira.sql" --tab
le ccm21.riversegments -h 192.168.1.104 eda2
#########################"
# calculation of distance to the sea
############################
ccm1<-distance_sea_fromnodes(ccm)
# C14 In my case I don't want to drop the content of my column
import_column(ccm1,newcolumn="cum_len_sea",newcolumntype="numeric",display=TRUE)

OK this one does an update on distance sea. Checking into Qgis, Im loading ccm21.riversegments and then selecting only Ireland using

wso_id in (select wso_id from europe.wso where area= 'Ireland')

as said in saving and loading the database with elvira?
source:data/Docs/trac/Ireland/distance.jpg

#########################"
# Calculation dams
############################
roeccm<-new("BaseEdaCCMriversegmentsROE",
		baseODBC="baseODBCccm",
		schema="ccm21",
		table="riversegments",
		prkey="wso1_id",
		zonegeo="Ireland",
		joinschema="ireland",
		jointable="salmonbarriers_ccm_300",
		traveled_segments=vector())
roeccm<-loaddb(roeccm)
roeccm<-cumulated_dam_impact(roeccm)
col=colnames(roeccm@dataroe)[ colnames(roeccm@dataroe)!="wso1_id"]
stopifnot(all(roeccm@data[,"wso1_id"]==roeccm@dataroe[,"wso1_id"]))
roeccm@data[,col]<-roeccm@dataroe[,col]
for (i in c(3,5)){
	import_column(roeccm,col[i],newcolumntype="numeric",display=TRUE,askbeforeforefill=FALSE)
}

Note : three windows appear there and you need to confirm that you want to write the values. Checking that the values are correct.

  • number of dams
  • cumulated number of dams cs_nbdams
  • cumulated heights

source:data/Docs/trac/Ireland/cs_nbdams.jpg

Now this is really a low number !

table(roeccm@dataroe$cs_nbdams)

   0    1    2    3 
6429 2181   27    7 

I cannot run the script for clc as I have no gid I'm changing stuff there CCM2 download and load
Also changing BaseEdaCCMriversegmentsclc.r