Skip to main content
correção de texto digitado errado
Fonte Link
Rafael Cunha
  • 5mil
  • 2
  • 13
  • 29
library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(
    lapply(xbreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                               paste0(abs(dms(x)$m),expression(~minute)), "*W")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*E")),
                    abs(dms(x))))}))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}

scale_y_latscale_y_latitude <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(
    lapply(ybreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                      paste0(abs(dms(x)$m),expression(~minute)), "*S")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*N")),
                    abs(dms(x))))}))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map +
  scale_x_longitude(-55.0,-54.7,.1) +
  scale_y_latitude(-22.4,-22.1,.1)

Consegui adicionar os valores do minuto, mas não obtive sucesso com a inclusão do símbolo '

library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(
    lapply(xbreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                               paste0(abs(dms(x)$m),expression(~minute)), "*W")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*E")),
                    abs(dms(x))))}))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}

scale_y_lat <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(
    lapply(ybreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                      paste0(abs(dms(x)$m),expression(~minute)), "*S")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*N")),
                    abs(dms(x))))}))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map +
  scale_x_longitude(-55.0,-54.7,.1) +
  scale_y_latitude(-22.4,-22.1,.1)

Consegui adicionar os valores do minuto, mas não obtive sucesso com a inclusão do símbolo '

library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(
    lapply(xbreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                               paste0(abs(dms(x)$m),expression(~minute)), "*W")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*E")),
                    abs(dms(x))))}))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}

scale_y_latitude <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(
    lapply(ybreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                      paste0(abs(dms(x)$m),expression(~minute)), "*S")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*N")),
                    abs(dms(x))))}))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map +
  scale_x_longitude(-55.0,-54.7,.1) +
  scale_y_latitude(-22.4,-22.1,.1)
atualização do código
Fonte Link
Rafael Cunha
  • 5mil
  • 2
  • 13
  • 29
library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(
    lapply(xbreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                               paste0(abs(dms(x)$m),expression(~minute)), "*W")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*E")),
                    abs(dms(x))))}))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}

scale_y_lat <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(
    lapply(ybreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                      paste0(abs(dms(x)$m),expression(~minute)), "*S")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*N")),
                    abs(dms(x))))}))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map +
  scale_x_longitude(-55.0,-54.7,.1) +
  scale_y_latitude(-22.4,-22.1,.1)

mapa http://i.imgur.com/qHsQy1D.jpgImgur

library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(
    lapply(xbreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                               paste0(abs(dms(x)$m)), "*W")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m)),"*E")),
                    abs(dms(x))))}))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}

scale_y_lat <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(
    lapply(ybreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                      paste0(abs(dms(x)$m)), "*S")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m)),"*N")),
                    abs(dms(x))))}))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map +
  scale_x_longitude(-55.0,-54.7,.1) +
  scale_y_latitude(-22.4,-22.1,.1)

mapa http://i.imgur.com/qHsQy1D.jpg

library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(
    lapply(xbreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                               paste0(abs(dms(x)$m),expression(~minute)), "*W")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*E")),
                    abs(dms(x))))}))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}

scale_y_lat <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(
    lapply(ybreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                      paste0(abs(dms(x)$m),expression(~minute)), "*S")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m),expression(~minute)),"*N")),
                    abs(dms(x))))}))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map +
  scale_x_longitude(-55.0,-54.7,.1) +
  scale_y_latitude(-22.4,-22.1,.1)

Imgur

alteração no código
Fonte Link
Rafael Cunha
  • 5mil
  • 2
  • 13
  • 29
library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(
    lapply(xbreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^o""^{o}*"),
                               paste0(abs(dms(x)$m)), "*W")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^o""^{o}*"),
                                             paste0(abs(dms(x)$m)),"*E")),
                    abs(dms(x))))}))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}
scale_y_latitude
scale_y_lat <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(
    lapply(ybreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^o""^{o}*"),
                                      paste0(abs(dms(x)$m)), "*S")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^o""^{o}*"),
                                             paste0(abs(dms(x)$m)),"*N")),
                    abs(dms(x))))}))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map+map +
  scale_x_longitude(-55.0,-54.7,.1) +
  scale_y_latitude(-22.4,-22.1,.1)

O que ainda está faltando é acrescentarConsegui adicionar os valores do minuto, mas não obtive sucesso com a informação dos minutos nos eixos.inclusão do símbolo '

mapa http://i.imgur.com/qHsQy1D.jpg

library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(lapply(xbreaks, function(x) ifelse(x < 0, parse(text=paste0(abs(dms(x)$d),"^o", "*W")), ifelse(x > 0, parse(text=paste0(abs(dms(x)$d),"^o", "*E")),x))))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}
scale_y_latitude <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(lapply(ybreaks, function(x) ifelse(x < 0, parse(text=paste0(abs(dms(x)$d),"^o", "*S")), ifelse(x > 0, parse(text=paste0(abs(dms(x)$d),"^o", "*N")),x))))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map+
  scale_x_longitude(-55.0,-54.7,.1)+
  scale_y_latitude(-22.4,-22.1,.1)

O que ainda está faltando é acrescentar a informação dos minutos nos eixos.

library(ggplot2)
library(ggmap)
library(GEOmap)

#get my map
city<- get_map(location = c(lon= -54.847, lat= -22.25),
               maptype = "satellite",zoom = 11,color="bw")

map<-ggmap(city,extent="normal")+
  xlab("Longitude")+ ylab("Latitude")

scale_x_longitude <- function(xmin=-180, xmax=180, step=1, ...) {
  xbreaks <- seq(xmin,xmax,step)
  xlabels <- unlist(
    lapply(xbreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                               paste0(abs(dms(x)$m)), "*W")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m)),"*E")),
                    abs(dms(x))))}))
  return(scale_x_continuous("Longitude", breaks = xbreaks, labels = xlabels, expand = c(0, 0), ...))
}

scale_y_lat <- function(ymin=-90, ymax=90, step=0.5, ...) {
  ybreaks <- seq(ymin,ymax,step)
  ylabels <- unlist(
    lapply(ybreaks, function(x){
      ifelse(x < 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                      paste0(abs(dms(x)$m)), "*S")), 
             ifelse(x > 0, parse(text=paste0(paste0(abs(dms(x)$d),"^{o}*"),
                                             paste0(abs(dms(x)$m)),"*N")),
                    abs(dms(x))))}))
  return(scale_y_continuous("Latitude", breaks = ybreaks, labels = ylabels, expand = c(0, 0), ...))
} 

map +
  scale_x_longitude(-55.0,-54.7,.1) +
  scale_y_latitude(-22.4,-22.1,.1)

Consegui adicionar os valores do minuto, mas não obtive sucesso com a inclusão do símbolo '

mapa http://i.imgur.com/qHsQy1D.jpg

Fonte Link
Rafael Cunha
  • 5mil
  • 2
  • 13
  • 29
Carregando