creating interactive map with csv file

I have been asked to create an interactive file with this Pharmacies GISC101 - Google Sheets csv file.

I am currently having trouble as I am new to R.

My current code is :

pharmacies <- read.csv("Pharmacies_Chch.csv") # read csv file

geocode_OSM(pharmacies$Address) # geocoding addresses

pharmacies_ee <- geocode_OSM(pharmacies$Address, projection = 2193, as.sf = T)

pharmacies_sf <- st_as_sf(pharmacies_ee, coords = c("Lon", "Lat"), crs = 4326)

tmap_mode("view") # setting the environment for interactive plots

I am currently having trouble initating the map as I amunsure what to , any help would be greatly appreciated.

Hi @scumbagsurfer (what a name lol) and welcome to the RStudio Community :partying_face: :partying_face: :partying_face: :partying_face: :partying_face: :partying_face:

Actually, the reason why you have not seen any map is simply because you have not written code to produce a map. tmap_mode("view") basically says that you want to make interactive maps, but you have not really made any.

The code below will help:

# Load packages ----

library(tmap) # for making maps
library(tmaptools) # for the geocoding function
library(readr) # for reading in the csv file


# Import data ----

pharmacies <- read_csv("Pharmacies GISC101 - Sheet1.csv")


# Geocoding addresses ----

coords <- geocode_OSM(q = pharmacies$Address, projection = 4326, as.sf = TRUE)


# Make map ----

tmap_mode("view")

tm_shape(shp = coords) +
  tm_dots()

Thank you so much, helped alot :slight_smile:

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.