title: How can I put a scalebar and a north arrow on the map (ggplot)?
body: <p>I'm trying to put a scalebar and a north arrow using the package 'ggsn'.
  But I recive a error message: </p>
  
  <p>Error: annotation_custom only works with Cartesian coordinates</p>
  
  <p>In addition: Warning messages:</p>
  
  <p>1: In min(data$long) : no non-missing arguments to min; returning Inf</p>
  
  <p>2: In max(data$long) : no non-missing arguments to max; returning -Inf </p>
  
  <p>3: In min(data$lat) : no non-missing arguments to min; returning Inf</p>
  
  <p>4: In max(data$lat) : no non-missing arguments to max; returning -Inf </p>
  
  <p>5: Removed 1374840 rows containing non-finite values (stat_contour). </p>
  
  <p>My code is like this:</p>
  
  <pre><code>#loading the map
  world &lt;- maps::map("world2", fill=TRUE, plot=FALSE) # world2 is the Pacific centered map with longitude [0,360]
  
  IDs &lt;- sapply(strsplit(world$names, ":"), function(x) x[1])
  world &lt;- map2SpatialPolygons(world, IDs=IDs, proj4string=CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
  
  world_map &lt;- fortify(world)
  
  #load the bathymetry 
  bat &lt;- marmap::getNOAA.bathy(lon1 = -5.0000, lon2 = -80.0000, lat1 = 14, lat2 = -70.61, keep=T) 
  
  #converting the bathymetry in data.frame
  bat2 = marmap::fortify.bathy(bat) 
  
  g &lt;- ggplot(AR, aes(x = lon, y = lat)) + #(old: Longitude #Latitude)
   geom_path(aes(group = sex, col = sex), size = 0.8, alpha = 0.5) +
   geom_map(data = world_map, map=world_map, aes(x = long, y = lat, map_id = id), fill = "darkgray") +
    geom_contour(data = bat2, 
                 aes(x=x, y=y, z=z),
                 breaks=c(-200),
                 size=c(0.3),
                 colour="blue")+
    xlim(extendrange(AR$lon, f = 0.1)) + #(old: Longitude)
    ylim(extendrange(AR$lat, f = 0.1)) + #(old: Latitude)
    coord_map("ortho", orientation = c(-40, -40, 0))
  
  g +
    ggsn::scalebar(world_map, dist = 100,location = "bottomright", transform = TRUE, #Adicione uma barra de escala
                   dist_unit = "km", st.dist = 0.03, st.size = 2, model = 'WGS84') +
    ggsn::north(world_map, scale = .1)
  </code></pre>
  
  <p>Part of my data:</p>
  
  <pre><code>structure(list(lon = c(-38.8745, -38.8676, -38.9445, -38.9811, 
  -38.9322, -38.9386), lat = c(-14.09437, -14.25664, -14.34518, 
  -14.51857, -14.95994, -15.41684), bmode = c(1.396, 1.375, 1.346, 
  1.248, 1.074, 1.289), bmode.5 = c(1, 1, 1, 1, 1, 1), ID = structure(c(53L, 
  53L, 53L, 53L, 53L, 53L), .Label = c("10946.05", "20162.03", 
  "21792.03", "21800.03", "21810.03", "24640.03", "24641.05", "24642.03", 
  "27258.05", "27259.03", "27261.03", "27261.05", "27261.07", "33000.05", 
  "37231.07", "37234.05", "37288.07", "42521.07", "50682.07", "50687.07", 
  "60004.07", "81122.09", "81123.09", "81124.09", "81125.09", "81126.09", 
  "84497.1", "87632.12", "87759.08", "87761.08", "87762.08", "87763.08", 
  "87764.08", "87765.08", "87766.08", "87768.08", "87768.11", "87769.11", 
  "87770.08", "87773.08", "87773.1", "87773.11", "87774.09", "87774.11", 
  "87775.08", "87776.08", "87776.11", "87777.1", "87778.08", "87783.09", 
  "88724.1", "88727.09", "111868.11", "111871.12", "112702.12", 
  "112712.12", "112714.12", "120947.12", "121189.12", "121192.12", 
  "121196.12", "1211931.12"), class = "factor"), sex = structure(c(3L, 
  3L, 3L, 3L, 3L, 3L), .Label = c("F", "Fc", "M"), class = "factor"), 
      speed = c(0.921691675, 2.990097297, 2.137609076, 3.259383146, 
      8.173674567, 8.413534172), area = structure(c(3L, 3L, 3L, 
      3L, 3L, 3L), .Label = c("AA", "AM", "AR"), class = "factor"), 
      angulo = c(41.027, -43.41, 29.056, 18.241, -7.125, -4.702
      ), angle_rel = c(0.7160619, -0.7576522, 0.5071251, 0.3183724, 
      -0.1243479, -0.08206201), bat.depth = c(-45L, -397L, -32L, 
      -29L, -21L, -3L), dist = c(5.53015005, 17.94058378, 12.82565446, 
      19.55629887, 49.0420474, 50.48120503), angulo_modulo = c(41.027, 
      43.41, 29.056, 18.241, 7.125, 4.702), curva = structure(c(1L, 
      1L, 1L, 1L, 1L, 1L), .Label = c("curva", "reta"), class = "factor")), row.names = 2:7, class = "data.frame")
  </code></pre>
  
  <p>how can i solve this problem?</p>
  
  <p><strong>####EDIT 1</strong></p>
  
  <p>I already edited my post and now the object 'world_map' is available.</p>
  
  <p>I'm having trouble using ggspatial.
  I loaded all the packages you mentioned and ran the command and was unable to execute the function.
  I went to add the package 'ggspatial', but the following message appears:</p>
  
  <pre><code>"* installing * source * package 'ggspatial' ...
  ** package 'ggspatial' successfully unpacked and MD5 sums checked
  ** R
  ** inst
  ** byte-compile and prepare package for lazy loading
  Error: .onLoad failed in loadNamespace () for 'sf', details:
    call: get (genname, envir = envir)
    error: object 'group_split' not found
  ERROR: lazy loading failed for package 'ggspatial'
  * removing 'C: /Users/annel/OneDrive/Documentos/R/win-library/3.5/ggspatial'
  In R CMD INSTALL
  Warning in install.packages:
    installation of package ‘ggspatial’ had non-zero exit status
  
  The downloaded source packages are in
  ‘C: \ Users \ annel \ AppData \ Local \ Temp \ RtmpKueyQV \ downloaded_packages’ "
  </code></pre>
  
  <p>When I execute the command you requested I get the message:</p>
  
  <pre><code>Error in loadNamespace (name): there is no package called ‘ggspatial’
  </code></pre>