@@ -41,25 +41,17 @@ neighborhoods <-
41
41
select(neighborhood , polygon , index ) %> %
42
42
sdf_persist()
43
43
44
+ # Download and transform locations of New York City museums
45
+ # (https://catalog.data.gov/dataset/new-york-city-museums)
44
46
museums.data <-
45
47
read.csv(" https://data.cityofnewyork.us/api/views/fn6f-htvy/rows.csv?accessType=DOWNLOAD" , stringsAsFactors = FALSE ) %> %
46
48
mutate(name = NAME , coordinates = sub(" POINT \\ ((.+) (.+)\\ )$" , " \\ 1,\\ 2" , the_geom )) %> %
47
49
select(name , coordinates )
48
-
49
50
museums.coordinates <- data.frame (do.call(' rbind' , strsplit(museums.data $ coordinates , split = " ," , fixed = TRUE )))
50
51
names(museums.coordinates ) <- c(" longitude" , " latitude" )
51
-
52
52
museums.df <- cbind(museums.data , museums.coordinates ) %> % select(name , latitude , longitude )
53
53
54
- # Coordinates of some places in NYC
55
- places.df <- data.frame (
56
- name = c(" Statue of Liberty" , " Columbia University" , " The Metropolitan Museum of Art" ),
57
- latitude = c(40.6892474 , 40.814856 , 40.77944365 ),
58
- longitude = c(- 74.0445405280149 , - 73.9610162365099 ,- 73.9633641138519 ),
59
- stringsAsFactors = FALSE )
60
-
61
54
# Create Spark DataFrame from local R data.frame
62
- # places <- copy_to(sc, places.df, "places")
63
55
museums <- copy_to(sc , museums.df , " museums" )
64
56
65
57
# Perform a spatial join to associate museum coordinates to
0 commit comments