Skip to content

Plotting world maps with locations.

5 messages · Jibrin Alhassan, David Winsemius, Romanus Ejike

#
Please, I need help from anyone that can solve this problem.
I wanted to plot a world map with locations and names of the locations but
could not. The codes I have tried are as shown below.
ugwoke at ugwoke-HP-ENVY-Laptop-13-aq0xxx:~/Desktop$ R

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
read.table("NM1989.txt",col.names=c("SNAME","FNAME","NMTYPE","LAT","LON","ALTI"))
Linking to GEOS 3.9.0, GDAL 3.2.0, PROJ 7.2.0
+ coord_sf(xlim = c(-180.00, 180.00), ylim = c(-90.00, 90.00), expand =
FALSE) + ggtitle("World map") + points(NMdata$LON,Nmdata$LAT,col = "red",
cex = 0.01)
Error in xy.coords(x, y) : object 'Nmdata' not found
+ coord_sf(xlim = c(-180.00, 180.00), ylim = c(-90.00, 90.00), expand =
FALSE) + ggtitle("World map") + points(NMdata$LON,NMdata$LAT,col = "red",
cex = 0.01)
Error in plot.xy(xy.coords(x, y), type = type, ...) :
  plot.new has not been called yet
In addition: Warning messages:
1: In xy.coords(x, y) : NAs introduced by coercion
2: In xy.coords(x, y) : NAs introduced by coercion
3: In (function (display = "", width, height, pointsize, gamma, bg,  :
  locale not supported by Xlib: some X ops will operate in C locale
4: In (function (display = "", width, height, pointsize, gamma, bg,  :
  X cannot set locale modifiers
+ coord_sf(xlim = c(-180.00, 180.00), ylim = c(-90.00, 90.00), expand =
FALSE) + ggtitle("World map") + points(NMdata$LON,NMdata$LAT,col = "red",
cex = 0.01, pch = 20)
Error in plot.xy(xy.coords(x, y), type = type, ...) :
  plot.new has not been called yet
In addition: Warning messages:
1: In xy.coords(x, y) : NAs introduced by coercion
2: In xy.coords(x, y) : NAs introduced by coercion.
I have also tried the codes below but it did not show the locations.
ugwoke at ugwoke-HP-ENVY-Laptop-13-aq0xxx:~/Desktop$ R

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Linking to GEOS 3.9.0, GDAL 3.2.0, PROJ 7.2.0
[1] "sf"         "data.frame"
+
+ + ggtitle("World map") + coord_sf(crs = "+proj=laea +lat_0=52 +lon_0=10
+x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs ")
Error in +ggtitle("World map") : invalid argument to unary operator
+ ggtitle("World map") + coord_sf(crs = "+proj=laea + lat_0=52 + lon_0=10 +
x_0=4321000 + y_0=3210000 + ellps=GRS80 + units=m + no_defs ")
Warning messages:
1: In (function (display = "", width, height, pointsize, gamma, bg,  :
  locale not supported by Xlib: some X ops will operate in C locale
2: In (function (display = "", width, height, pointsize, gamma, bg,  :
  X cannot set locale modifiers.
I really appreciate any help rendered. Thanks
#
Hello Romanus,
You are to post only the code and the error messages and not all the
information from your terminal in R session.

On Fri, Feb 12, 2021, 4:35 PM Romanus Ejike <romanusejike1971 at gmail.com>
wrote:

  
  
#
Sent from my iPhone
That?s not actually the best practice for rhelp questions. More info is better than less. What?s missing, however, is the data. 

? 
David
#
Sent from my iPhone
Here the file is named NMdata.
But the error says Nmdata not found. SPELLING!!!!

? 
David
#
Awesome, thanks! I will make corrections and see if it will work.

On Sat, Feb 13, 2021 at 6:04 AM David Winsemius <dwinsemius at comcast.net>
wrote: