Skip to content

Commit 73f26b1

Browse files
committed
post recording
1 parent 9a3c9aa commit 73f26b1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

061_chatgpt_osmdata_api/061_chatgpt_osmdata.R

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# **** -----
88

9-
# GOAL: Demonstrate how to get lat/long and map for ANY
9+
# GOAL: Demonstrate how to get & map lat/long for ANY business type
1010

1111
# 1.0 CHATGPT + OSMDATA LESSON -----
1212

@@ -18,20 +18,24 @@ Pittsburgh. Then use mapview to visualize the pharmacies on a map.
1818

1919
# * FINAL RESPONSE ----
2020

21-
# load necessary packages
21+
# Load required libraries
2222
library(osmdata)
2323
library(mapview)
2424

25-
# define the bounding box for Pittsburgh
26-
bbox <- getbb("Pittsburgh")
25+
# Get the bounding box for Pittsburgh
26+
pittsburgh_bbox <- getbb("Pittsburgh, Pennsylvania, USA")
27+
28+
# Create an Overpass query for pharmacies in Pittsburgh
29+
query <- opq(bbox = pittsburgh_bbox) %>%
30+
add_osm_feature(key = "amenity", value = "pharmacy")
31+
32+
# Extract the data as an sf object
33+
pharmacies_sf <- osmdata_sf(query)
34+
35+
# Visualize the pharmacies on a map
36+
mapview(pharmacies_sf$osm_points, zcol = "name")
2737

28-
# search for pharmacies within the bounding box
29-
pharmacies <- opq(bbox) %>%
30-
add_osm_feature(key = "amenity", value = "pharmacy") %>%
31-
osmdata_sp()
3238

33-
# visualize the pharmacies on a map
34-
mapview(pharmacies$osm_points)
3539

3640

3741
# 2.0 PREVIEW LEARNING LAB 83 ----

0 commit comments

Comments
 (0)