Could not plot geometric point

Hi all,

I am trying to plot a geometric point on Vietnam map. However, I can not do it.
I download the level 1 sp map from GADM. Then I try to coordinate the place with the longitude and latitude. Finally, I try to use geom_point to plot the place but it's not happened. Below is my code

add data information

df = = 1, ncol = 3))
colnames(df) = c("lat", "lon", "id")

df$lon = c(21.023397)
df$lat = c(105.806228)
df$id = c(1)

adding plot destination to the map

plot(gadm36_VNM_1_sp) +
geom_point(data = df, aes(x = lon, y = lat), color = "red")

Hi @tung134679,

without having your map data, I notice that you are "mixing" base R plot with ggplot::geom_point - that might be the issue. Also, could you provide the error message you are getting? For plotting maps with ggplot there are many resources among others


Consider this code:


borders <- readRDS(url(""))

points <- data.frame(name = c("here!"),
                     x = c(105.806228),
                     y = c(21.023397)) %>% 
  sf::st_as_sf(coords = c("x","y"), crs=4326)

ggplot() +
  geom_sf(data = borders, fill = NA) +
  geom_sf(data = points, pch = 4, color = "red")

It is built on workflow of {sf} package, and does 3 things:

  • dowloads the Vietnam borders from in {sf} format
  • prepares a data frame of coordinates & transforms it to a {sf} format
  • drawing a chart via ggplot; note the use of geom_sf()


Hi @tung134679!

Welcome to the RStudio Community!

Here is an example using ggplot and geom_sf,
with the rnaturalearth package and rnaturalearthdata,
to help you get started.

#> Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
#> Loading required package: sp
#> rgeos version: 0.5-2, (SVN revision 621)
#>  GEOS runtime version: 3.7.2-CAPI-1.11.2 
#>  Linking to sp version: 1.3-1 
#>  Polygon checking: TRUE

viet <- ne_countries(country = 'vietnam', type = 'countries', returnclass = 'sf', scale = 'medium')

ggplot(data = viet) + 
  geom_sf() +
  geom_point(aes(x=105, y =22), size =2, shape =23,
             fill = "blue") +
  labs(x = "Longitude East", y = "Latitude North",
       title = "Map of Vietnam", subtitle = "with arbitrary point",
       caption = "data from rnaturalearth mapped with ggplot2 and sf")

Created on 2019-10-18 by the reprex package (v0.3.0)

I found this web post helpful in making maps with sf.

It will help you to get answers to your R questions if you can learn to make a reprex.
A reprex is a reproducible example. This is a nice guide to making your own reprex. This will help you for future questions.

Click the heart to like if this reply was helpful.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.