Problem with as.kask function and ASC files

Hello,

I would like to make an ENFA with R using 4 variables: DTM exposure (=MNT Exposition), DTM slope (=MNT pente), distance to pond (=Dist_mares) and land use (OSC Theia).
Before processing my data with R, I formatted the 4 variable layers in GIS so that they have the same coverage and resolution.
Then I converted these layers into ASCII files (*.asc) to be able to enter them in R.

In R, I imported the 4 layers with the import.asc function of the adehabitat package:

carte1 <- import.asc("MNT_Exposition_arcgid_3_ASCII.asc")
carte1

carte2 <- import.asc("MNT_pente_ASCII.asc")
carte2

carte3 <- import.asc("oso_theia_ASCII_Int16.asc")
carte3

carte4 <- import.asc("Dist_mares_ASCII_Int16.asc")
carte4

Then, I would like to gather the files in a "kasc" object using the function as.kasc :

cartetot <- as.kasc(list(expo = carte1,
                           + pente = carte2,
                           + osotheia = carte3,
                           + distmare = carte4))

The problem is that when I enter these last lines of code, the software indicates an error and I don't understand where this can come from.

> cartetot <- as.kasc(list(expo = carte1,
+                            + pente = carte2,
Erreur : '=' inattendu(e) in:
"cartetot <- as.kasc(list(expo = carte1,
                           + pente ="
>                            + osotheia = carte3,
Erreur : ',' inattendu(e) in "                           + osotheia = carte3,"
>                            + distmare = carte4))
Erreur : ')' inattendu(e) in "                           + distmare = carte4)"
> 

Would you have an answer to help me ?
Thanks a lot !

Hello @Anna3 ,

I think the problem is only in your specification of the list where you have 'those plusses' .
It is not related to the as.kask function.
Compare the two specifications of a list in

carte1 = 1
carte2 = 2
carte3 = 3
carte4 = 4

mylist1 <- list(expo = carte1,
                           + pente = carte2,
                           + osotheia = carte3,
                           + distmare = carte4)


mylist2 <- list(expo = carte1,
                            pente = carte2,
                            osotheia = carte3,
                            distmare = carte4)

Thank you !! It worked !!

> cartetot <- as.kasc(list(expo = carte1,
+                             pente = carte2,
+                             osotheia = carte3,
+                             distmare = carte4))
> cartetot
Raster map of class "kasc":
Cell size:  5 
Number of rows:  227 
Number of columns:  361 

Variables measured:
1. expo: numeric
2. pente: numeric
3. osotheia: numeric
4. distmare: numeric

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.