Re: question about plots in marine areas

37 views
Skip to first unread message
Message has been deleted

Alexandre Courtiol

unread,
Apr 14, 2022, 8:23:20 AM4/14/22
to IsoriX
Sorry Samatha,
All the new emails of this mailing list somehow were in my spaMM box and I just noticed it.
(I will try to solve this recurring issue!)
Did you manage or shall I show you how?
Best,
Alex


On Thursday, 14 April 2022 at 14:21:14 UTC+2 sami....@gmail.com wrote:
Hi All,
I am trying to build an isoscapes with d13C and d15N of zooplankton data from marines areas in the Souther Ocean. But when I plotted it, I have isoscape on land. Is it possible that the isoscape avoids the land and the lad has a single color?
I tried adding a mask2 with an earth raster, but I couldn't get it.

Now my command is:
plot(CopeIsoscape, which = "mean", mask = list(mask = NULL),
     mask2 = list(mask = World3  , col = "black", fill = "black"),
     y_title = list(which = TRUE, title = bquote(delta^13 * C)),
     borders = list(database = "world", fill= "black", lwd = 0.5, col = "black"),
     palette = list(range = c(-31, -13), step = 1, fn = NULL))

World3 <- raster("C:/Users/dodin/Desktop/Martillo etapas/isoriX/OB_50M/OB_50M.tif")

At the moment I could only get the borders of the land. Also, when I plotted the geographic assigments for one individual of penguin, the p-value are assigment on land and that it's not possible for penguins. 

This is my command for the assigment:

plot(AssignedPM, who = "FPL_1", mask = list(mask = NULL),
     sources = list(draw = FALSE))

I attach the plots as example. I hope you can help me to solve this.

Thank you so much in advace!
Best,
Samanta






sami dodino

unread,
Apr 15, 2022, 11:39:35 AM4/15/22
to iso...@googlegroups.com
Hi Alexandre,
No, I couldn't manage the problem. Please show me how. 
I also have a problem with the function "extract". I receive this issue:
"extract(AssignedPM$sample$pv[[1]], cbind(AssignedPM$long[1], AssignedPM$lat[1]))
Error in (function (classes, fdef, mtable):  unable to find an inherited method for function ‘extract’ for signature ‘"RasterLayer", "NULL"’

Thank you!
Best,
Samanta

--
You received this message because you are subscribed to the Google Groups "IsoriX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isorix+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isorix/213cc569-6fcb-41ec-a40b-594d616671aan%40googlegroups.com.


--
Samanta Dodino
Lab. Ecología y Conservación de Vida Silvestre
Centro Austral de Investigaciones Científicas - CONICET
Bernardo Houssay 200,(9410) Ushuaia, Tierra del Fuego, Argentina.

Alexandre Courtiol

unread,
Apr 15, 2022, 12:01:17 PM4/15/22
to IsoriX
Hi Samatha,

Building on the official IsoriX example (that in ?isoscape):

library(IsoriX)
GNIPDataDEagg <- prepsources(data = GNIPDataDE)
GermanFit <- isofit(data = GNIPDataDEagg, mean_model_fix = list(elev = TRUE, lat_abs = TRUE))
GermanScape <- isoscape(raster = ElevRasterDE, isofit = GermanFit)
plot(GermanScape)

here is how you can hide lands instead of oceans and seas (that requires to install beforehand the R package rgeos):

worldlimit <- as(extent(CountryBorders), "SpatialPolygons")
sp::proj4string(worldlimit) <- raster::crs(CountryBorders)
LandMask <- rgeos::gDifference(worldlimit, OceanMask)

plot(GermanScape, mask = list(mask = LandMask, fill = "yellow", col = "blue", lwd = 4))

I used options for colours to show you what they do:
fill sets the colour used to fill the mask polygon (here the lands), col sets the colour of the line around the mask polygon and lwd sets the thickness of the line.

To use the function extract(), make sure to either use library(raster) beforehand or as I do it above, use the syntax namespace::function, and thus here raster::extract().

Let me know if that solves all your problems or not.

Best,

Alex

sami dodino

unread,
Apr 19, 2022, 12:36:15 PM4/19/22
to iso...@googlegroups.com
Yes! It works! Thanks so much Alexandre!
However, I couldn't solve the problem with the function extract. I keep getting the same issue: Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘extract’ for signature ‘"RasterLayer", "NULL"
I used the library (raster) and also I tried using the syntax raster::extract(). Maybe I have a problem elsewhere that I'm not realizing. Is it possible?

Best,
Samanta

Alexandre Courtiol

unread,
Apr 19, 2022, 12:39:10 PM4/19/22
to IsoriX
Hi Samanta,
I am glad that you managed to mask lands.
With respect to extract(), could you please show me the code you type that trigger the error?
Thanks,
Alex

sami dodino

unread,
Apr 19, 2022, 2:55:17 PM4/19/22
to iso...@googlegroups.com
My code is this:

library(raster)
AssignDataPM <- read.csv("AssignDataPM.csv")
AssignedPM <- isofind(data = AssignDataPM,
                        isoscape = CopeIsoscape)

(In this step, I didn't use the calibration step because I'm working with carbon isotopes. I only adjusted the zooplankton's values to the trophic discrimination factor of penguins' plasma (-0.63).)

AssignedPM$sample$stat$FPE_1
raster::extract(AssignedPM$sample$pv[[1]], cbind(AssignedPM$long[1], AssignedPM$lat[1]))
plot(AssignedPM, who = "FPL_1", mask = list(mask = LandMask, fill = "grey", col = "black", lwd = 4),
     sources = list(draw = FALSE)).

Also, when I plotted the Assigned for one individual I have this problem:
The p-values are in land but now the landMask hides them.
image.png






Alexandre Courtiol

unread,
Apr 19, 2022, 2:57:14 PM4/19/22
to IsoriX
Hi again Samanta,

## about extract

the problem is that you should not use

extract(AssignedPM$sample$pv[[1]], cbind(AssignedPM$long[1], AssignedPM$lat[1]))

but

extract(AssignedPM$sample$pv[[1]], cbind(AssignDataPM$long[1], AssignDataPM$lat[1]))

AssignedPM does not contain a column lat and long, only your AssignDataPM does.

## plot

I don't think you have a problem. If it is grey in the sea, it suggests that it is unlikely that your sample comes from that part of the sea.
This in turn can be true or caused by various problem such as using a wrong trophic discrimination factor, a badly fitted isoscape or an unusual sample to assign.
In general, look at the assignment for the group first if that is an option in your case.

++

sami dodino

unread,
Apr 20, 2022, 2:47:43 AM4/20/22
to iso...@googlegroups.com

Ohh, thanks for the help with the issue in my code!

##plot
Last question about the plot. When avoid the Landmask, this is what happened:
plot(AssignedPM, who = "group", sources = list(draw = FALSE)).
image.png
I think the problem is that the isoscape is built on the land and not on the sea. Consequently, when I run the assignment origin, it is assigned on land too. What do you think? Is there a way to change the isoscape function to avoid the land?

Thanks again for all your help! And sorry for asking you so many questions.

Best,
Samanta




Alexandre Courtiol

unread,
Apr 20, 2022, 2:53:07 AM4/20/22
to IsoriX
Hi again,

I don't think this is the case: IsoriX does not know during the assignment step about whether a location is in the sea or land.
The only difference is that predictor variables may be different and so expected isotopic signatures differ between land and sea.

To be sure, try removing all masks when plotting: plot(AssignedPM, mask = list(mask = NULL))

Also, you can simply check the value stored in the raster AssignedPM$group$pv using extract() at locations in land or in sea.

You can also directly do plot(AssignedPM$group$pv) to plot the raster without using IsoriX.

If it sounds off to you, I will have to review your entire workflow.

++

sami dodino

unread,
Apr 21, 2022, 5:02:51 AM4/21/22
to iso...@googlegroups.com
Hi Alexandre,
I continue having the same problem :(. The AssignedPM is on Tierra del Fuego and not on the sea.

plot(AssignedPM$group$pv)
image.png

I sent you an invitation to my code on github. Let me know if you receive it. 
Many thanks!

Alexandre Courtiol

unread,
Apr 25, 2022, 6:40:13 AM4/25/22
to IsoriX
Hi Samantha,

I had a quick look at your code on GH.

I had forgotten and important detail: by default isofind() masks seas before doing the assignment as indicated in the manual (?isofind).

In your case, you must thus use (recycling your code):

AssignedPM <- isofind(data = AssignDataPM, isoscape = CopeIsoscape, mask = LandMask)

That should solve all your problems.
But let me know if something else comes up.

I will probably add a chapter in the bookdown about how to deal with oceanic data.

Best,
Alex

sami dodino

unread,
Apr 26, 2022, 2:44:31 AM4/26/22
to iso...@googlegroups.com
Yes! It worked! Thank you so much for all your help. It would be great if you add that chapter. 
Many thanks again :)

Cheers,
Sami


You received this message because you are subscribed to a topic in the Google Groups "IsoriX" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/isorix/dVDak1fRWIw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to isorix+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isorix/0350cdaa-25f1-4e41-875a-ced7a2ac86cen%40googlegroups.com.



Reply all
Reply to author
Forward
0 new messages