Ask Your Question

What does the error message "arguments have different crs" mean when attempting to animate with geom_sf and gganimate and how can it be resolved?

asked 2023-05-26 02:19:19 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-05-26 02:49:02 +0000

david gravatar image

The error message "arguments have different crs" in gganimate indicates that the input data have different crs (coordinate reference system). This error occurs because the spatial objects have different geometries and the coordinate systems may not match. The solution is to ensure that all spatial objects used in the gganimate function have the same crs.

To resolve the error, first, check that all your input data with the sf object have the same crs. If not, reproject the data using the sttransform() function. Once this is done, ensure that all layers and animations use the same crs by adding the argument coordsf(crs = "your crs code") in each ggplot object, and set the specific crs code that you have used for your data. By doing this, gganimate will use the same crs for all layers involved in the animation process, and the "arguments have different crs" error will be resolved.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2023-05-26 02:19:19 +0000

Seen: 1 times

Last updated: May 26