AustralianAntarcticDivision / SOmap

Southern Ocean round maps
https://australianantarcticdivision.github.io/SOmap/
24 stars 6 forks source link

SOauto_crop gotchas #32

Closed raymondben closed 5 years ago

raymondben commented 5 years ago

In some cases autocrop is going to make a component empty, which may cause things to go pear-shaped (e.g. CCAMLR labels have special code for areas 48.1 and 58.4.2 for reasons I don't understand, and if the SOauto_map extent doesn't include these areas, what happens?)

Maschette commented 5 years ago

Yep I think it is a case where SOauto_crop has some safeguards inside so it only works on spatial polygons

Maschette commented 5 years ago

I just had a look to remind myself, 48.1 and 58.4.2 have different objects as the center of their respective polygons means you cant read the labels

Maschette commented 5 years ago
a <- SOauto_map(c(0, 100), c(-70, -60)) 
SOmanagement(CCAMLR = T, CCAMLRlab =T, basemap = a)
 Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘coordinates’ for signature ‘"try-error"’

Weirdly it still puts the labels in the right spots and doesn't plot the other labels from the areas not there.

raymondben commented 5 years ago

I'm guessing that if the feature lies outside of the SOauto_map domain, then the autocrop fails (its operations are wrapped in tryCatch blocks, and one of them is failing and returning the try-error object). This error object is then being stored in the reprojected SOmanagement object, and getting passed to the plot function (which is calling coordinates). So, basically, don't return try-error objects. And if the auto reproj fails, then we need to remove that component from the SOmanagement object.