wiki:Run R program 2014

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:eda/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:eda/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
I've created two functions called ccm21.upstream_segments2 and ccm21.mycatchment2(wso1_id_ numeric) that work with wso1_id instead of gid. Also changing BaseEdaCCMriversegmentsclc.r

Seems to be working, calculates stuff, up indicates that it skips the calculation as it is already up character(0) indicates that it has written the data but the query insert returns nothing.

upstream_area(clc,silent=TRUE,from=1,to=8644)
up
(52.54,0.368533745117188,0,0,0,11.2410174003906,2.77272357910156,0,19.4419770146484,35.898882796875,0.76630683203125,0) 
character(0)
up
up
up
(13.25,0.0759232529296875,0,0.860067575195314,0,4.9431863203125,0.31636262890625,0,4.40190552050782,1.56904166601563,1.55029045312501,0.635486859375) 
character(0)
(36.79,0.113623603515625,0,0,0,8.46795550097657,1.98621957714844,0,10.4979759501953,29.9158370332032,0.76630683203125,0) 
character(0)
up
(65.85,0,0,0,0,24.9664220478515,8.07787291699219,0.276497768554688,3.88312135351563,57.2921717128906,0,0) 
character(0)
up
up
Last modified 7 years ago Last modified on Jun 1, 2018 7:04:02 PM