foursquarelabsadmin
commited on
copy over dataset card
Browse files
README.md
CHANGED
@@ -1,3 +1,213 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
# Access FSQ OS Places
|
5 |
+
|
6 |
+
With Foursquare’s Open Source Places, you can access free data to accelerate geospatial innovation and insights. View the [Places OS Data Schemas](https://docs.foursquare.com/data-products/docs/places-os-data-schema) for a full list of available attributes.
|
7 |
+
|
8 |
+
## Prerequisites
|
9 |
+
|
10 |
+
In order to access Foursquare's Open Source Places data, you will need the following files:
|
11 |
+
|
12 |
+
- Parquet Files:
|
13 |
+
- **Places** - [release/dt=2024-11-19/places/parquet](https://huggingface.co/datasets/foursquarelabsadmin/fsq-open-src-places-test/tree/main/release/dt%3D2024-11-19/places/parquet)
|
14 |
+
- **Categories** - [release/dt=2024-11-19/categories/parquet](https://huggingface.co/datasets/foursquarelabsadmin/fsq-open-src-places-test/tree/main/release/dt%3D2024-11-19/categories/parquet)
|
15 |
+
|
16 |
+
|
17 |
+
## Example Queries
|
18 |
+
|
19 |
+
The following are examples on how to query FSQ Open Source Places using Athena and Spark:
|
20 |
+
|
21 |
+
- Filter [Categories](https://docs.foursquare.com/data-products/docs/categories#places-open-source--propremium-flat-file) by the parent level
|
22 |
+
- Filter out [non-commercial venues](#non-commercial-categories-table)
|
23 |
+
- Find open and recently active POI
|
24 |
+
|
25 |
+
### Filter by Parent Level Category
|
26 |
+
|
27 |
+
**Presto/Athena**
|
28 |
+
```sql Presto/Athena
|
29 |
+
WITH places_exploded_categories AS (
|
30 |
+
-- Unnest categories array
|
31 |
+
SELECT fsq_place_id,
|
32 |
+
cid as fsq_category_id
|
33 |
+
FROM places p
|
34 |
+
CROSS JOIN UNNEST(p.fsq_category_ids) AS t(cid)
|
35 |
+
),
|
36 |
+
distinct_places AS (
|
37 |
+
SELECT
|
38 |
+
DISTINCT(fsq_place_id) -- Get distinct ids to reduce duplicates from cross join
|
39 |
+
FROM places_exploded_categories p
|
40 |
+
JOIN fsq.category c -- Join to categories to filter on Level 2 Category
|
41 |
+
ON p.fsq_category_id = c.category_id
|
42 |
+
WHERE c.level2_category_id = '4d4b7105d754a06374d81259' -- Restaurants
|
43 |
+
)
|
44 |
+
SELECT * FROM places
|
45 |
+
WHERE fsq_place_id IN (SELECT fsq_place_id FROM distinct_places)
|
46 |
+
|
47 |
+
```
|
48 |
+
**SparkSQL**
|
49 |
+
```sql SparkSQL
|
50 |
+
WITH places_exploded_categories AS (
|
51 |
+
-- Unnest categories array
|
52 |
+
SELECT fsq_place_id,
|
53 |
+
name,
|
54 |
+
explode(fsq_category_ids) as fsq_category_id
|
55 |
+
FROM places
|
56 |
+
),
|
57 |
+
distinct_places AS (
|
58 |
+
SELECT
|
59 |
+
DISTINCT(fsq_place_id) -- Get distinct ids to reduce duplicates from explode function
|
60 |
+
FROM places_exploded_categories p
|
61 |
+
JOIN fsq.category c -- Join to categories to filter on Level 2 Category
|
62 |
+
ON p.fsq_category_id = c.category_id
|
63 |
+
WHERE c.level2_category_id = '4d4b7105d754a06374d81259' -- Restaurants
|
64 |
+
)
|
65 |
+
SELECT * FROM places
|
66 |
+
WHERE fsq_place_id IN (SELECT fsq_place_id FROM distinct_places)
|
67 |
+
```
|
68 |
+
### Filter out Non-Commercial Categories
|
69 |
+
**Presto/Athena**
|
70 |
+
```sql Presto/Athena
|
71 |
+
SELECT * FROM places
|
72 |
+
WHERE arrays_overlap(fsq_category_ids, ARRAY['4bf58dd8d48988d1f0931735' -- Airport Gate
|
73 |
+
'62d587aeda6648532de2b88c' -- Beer Festival
|
74 |
+
'4bf58dd8d48988d12b951735' -- Bus Line
|
75 |
+
'52f2ab2ebcbc57f1066b8b3b' -- Christmas Market
|
76 |
+
'50aa9e094b90af0d42d5de0d' -- City
|
77 |
+
'5267e4d9e4b0ec79466e48c6' -- Conference
|
78 |
+
'5267e4d9e4b0ec79466e48c9' -- Convention
|
79 |
+
'530e33ccbcbc57f1066bbff7' -- Country
|
80 |
+
'5345731ebcbc57f1066c39b2' -- County
|
81 |
+
'63be6904847c3692a84b9bb7' -- Entertainment Event
|
82 |
+
'4d4b7105d754a06373d81259' -- Event
|
83 |
+
'5267e4d9e4b0ec79466e48c7' -- Festival
|
84 |
+
'4bf58dd8d48988d132951735' -- Hotel Pool
|
85 |
+
'52f2ab2ebcbc57f1066b8b4c' -- Intersection
|
86 |
+
'50aaa4314b90af0d42d5de10' -- Island
|
87 |
+
'58daa1558bbb0b01f18ec1fa' -- Line
|
88 |
+
'63be6904847c3692a84b9bb8' -- Marketplace
|
89 |
+
'4f2a23984b9023bd5841ed2c' -- Moving Target
|
90 |
+
'5267e4d9e4b0ec79466e48d1' -- Music Festival
|
91 |
+
'4f2a25ac4b909258e854f55f' -- Neighborhood
|
92 |
+
'5267e4d9e4b0ec79466e48c8' -- Other Event
|
93 |
+
'52741d85e4b0d5d1e3c6a6d9' -- Parade
|
94 |
+
'4bf58dd8d48988d1f7931735' -- Plane
|
95 |
+
'4f4531504b9074f6e4fb0102' -- Platform
|
96 |
+
'4cae28ecbf23941eb1190695' -- Polling Place
|
97 |
+
'4bf58dd8d48988d1f9931735' -- Road
|
98 |
+
'5bae9231bedf3950379f89c5' -- Sporting Event
|
99 |
+
'530e33ccbcbc57f1066bbff8' -- State
|
100 |
+
'530e33ccbcbc57f1066bbfe4' -- States and Municipalities
|
101 |
+
'52f2ab2ebcbc57f1066b8b54' -- Stoop Sale
|
102 |
+
'5267e4d8e4b0ec79466e48c5' -- Street Fair
|
103 |
+
'53e0feef498e5aac066fd8a9' -- Street Food Gathering
|
104 |
+
'4bf58dd8d48988d130951735' -- Taxi
|
105 |
+
'530e33ccbcbc57f1066bbff3' -- Town
|
106 |
+
'5bae9231bedf3950379f89c3' -- Trade Fair
|
107 |
+
'4bf58dd8d48988d12a951735' -- Train
|
108 |
+
'52e81612bcbc57f1066b7a24' -- Tree
|
109 |
+
'530e33ccbcbc57f1066bbff9' -- Village
|
110 |
+
]) = false
|
111 |
+
```
|
112 |
+
**SparkSQL**
|
113 |
+
```sql SparkSQL
|
114 |
+
SELECT *
|
115 |
+
FROM places
|
116 |
+
WHERE arrays_overlap(fsq_category_ids, array('4bf58dd8d48988d1f0931735' -- Airport Gate
|
117 |
+
'62d587aeda6648532de2b88c' -- Beer Festival
|
118 |
+
'4bf58dd8d48988d12b951735' -- Bus Line
|
119 |
+
'52f2ab2ebcbc57f1066b8b3b' -- Christmas Market
|
120 |
+
'50aa9e094b90af0d42d5de0d' -- City
|
121 |
+
'5267e4d9e4b0ec79466e48c6' -- Conference
|
122 |
+
'5267e4d9e4b0ec79466e48c9' -- Convention
|
123 |
+
'530e33ccbcbc57f1066bbff7' -- Country
|
124 |
+
'5345731ebcbc57f1066c39b2' -- County
|
125 |
+
'63be6904847c3692a84b9bb7' -- Entertainment Event
|
126 |
+
'4d4b7105d754a06373d81259' -- Event
|
127 |
+
'5267e4d9e4b0ec79466e48c7' -- Festival
|
128 |
+
'4bf58dd8d48988d132951735' -- Hotel Pool
|
129 |
+
'52f2ab2ebcbc57f1066b8b4c' -- Intersection
|
130 |
+
'50aaa4314b90af0d42d5de10' -- Island
|
131 |
+
'58daa1558bbb0b01f18ec1fa' -- Line
|
132 |
+
'63be6904847c3692a84b9bb8' -- Marketplace
|
133 |
+
'4f2a23984b9023bd5841ed2c' -- Moving Target
|
134 |
+
'5267e4d9e4b0ec79466e48d1' -- Music Festival
|
135 |
+
'4f2a25ac4b909258e854f55f' -- Neighborhood
|
136 |
+
'5267e4d9e4b0ec79466e48c8' -- Other Event
|
137 |
+
'52741d85e4b0d5d1e3c6a6d9' -- Parade
|
138 |
+
'4bf58dd8d48988d1f7931735' -- Plane
|
139 |
+
'4f4531504b9074f6e4fb0102' -- Platform
|
140 |
+
'4cae28ecbf23941eb1190695' -- Polling Place
|
141 |
+
'4bf58dd8d48988d1f9931735' -- Road
|
142 |
+
'5bae9231bedf3950379f89c5' -- Sporting Event
|
143 |
+
'530e33ccbcbc57f1066bbff8' -- State
|
144 |
+
'530e33ccbcbc57f1066bbfe4' -- States and Municipalities
|
145 |
+
'52f2ab2ebcbc57f1066b8b54' -- Stoop Sale
|
146 |
+
'5267e4d8e4b0ec79466e48c5' -- Street Fair
|
147 |
+
'53e0feef498e5aac066fd8a9' -- Street Food Gathering
|
148 |
+
'4bf58dd8d48988d130951735' -- Taxi
|
149 |
+
'530e33ccbcbc57f1066bbff3' -- Town
|
150 |
+
'5bae9231bedf3950379f89c3' -- Trade Fair
|
151 |
+
'4bf58dd8d48988d12a951735' -- Train
|
152 |
+
'52e81612bcbc57f1066b7a24' -- Tree
|
153 |
+
'530e33ccbcbc57f1066bbff9' -- Village
|
154 |
+
)) = false
|
155 |
+
```
|
156 |
+
|
157 |
+
### Find Open and Recently Active POI
|
158 |
+
**Presto/Athena**
|
159 |
+
```sql Presto/Athena
|
160 |
+
SELECT * FROM places p
|
161 |
+
WHERE p.date_closed IS NULL
|
162 |
+
AND DATE(p.date_refreshed) >= DATE_ADD('day', -365, current_date);
|
163 |
+
```
|
164 |
+
**SparkSQL**
|
165 |
+
```sql SparkSQL
|
166 |
+
SELECT * FROM places p
|
167 |
+
WHERE p.date_closed IS NULL
|
168 |
+
AND p.date_refreshed >= DATE_SUB(current_date(), 365);
|
169 |
+
```
|
170 |
+
|
171 |
+
## Appendix
|
172 |
+
|
173 |
+
### Non-Commercial Categories Table
|
174 |
+
|
175 |
+
| Category Name | Category ID |
|
176 |
+
| :------------------------ | :----------------------- |
|
177 |
+
| Airport Gate | 4bf58dd8d48988d1f0931735 |
|
178 |
+
| Beer Festival | 62d587aeda6648532de2b88c |
|
179 |
+
| Bus Line | 4bf58dd8d48988d12b951735 |
|
180 |
+
| Christmas Market | 52f2ab2ebcbc57f1066b8b3b |
|
181 |
+
| City | 50aa9e094b90af0d42d5de0d |
|
182 |
+
| Conference | 5267e4d9e4b0ec79466e48c6 |
|
183 |
+
| Convention | 5267e4d9e4b0ec79466e48c9 |
|
184 |
+
| Country | 530e33ccbcbc57f1066bbff7 |
|
185 |
+
| County | 5345731ebcbc57f1066c39b2 |
|
186 |
+
| Entertainment Event | 63be6904847c3692a84b9bb7 |
|
187 |
+
| Event | 4d4b7105d754a06373d81259 |
|
188 |
+
| Festival | 5267e4d9e4b0ec79466e48c7 |
|
189 |
+
| Hotel Pool | 4bf58dd8d48988d132951735 |
|
190 |
+
| Intersection | 52f2ab2ebcbc57f1066b8b4c |
|
191 |
+
| Island | 50aaa4314b90af0d42d5de10 |
|
192 |
+
| Line | 58daa1558bbb0b01f18ec1fa |
|
193 |
+
| Marketplace | 63be6904847c3692a84b9bb8 |
|
194 |
+
| Moving Target | 4f2a23984b9023bd5841ed2c |
|
195 |
+
| Music Festival | 5267e4d9e4b0ec79466e48d1 |
|
196 |
+
| Neighborhood | 4f2a25ac4b909258e854f55f |
|
197 |
+
| Other Event | 5267e4d9e4b0ec79466e48c8 |
|
198 |
+
| Parade | 52741d85e4b0d5d1e3c6a6d9 |
|
199 |
+
| Plane | 4bf58dd8d48988d1f7931735 |
|
200 |
+
| Platform | 4f4531504b9074f6e4fb0102 |
|
201 |
+
| Polling Place | 4cae28ecbf23941eb1190695 |
|
202 |
+
| Road | 4bf58dd8d48988d1f9931735 |
|
203 |
+
| State | 530e33ccbcbc57f1066bbff8 |
|
204 |
+
| States and Municipalities | 530e33ccbcbc57f1066bbfe4 |
|
205 |
+
| Stopp Sale | 52f2ab2ebcbc57f1066b8b54 |
|
206 |
+
| Street Fair | 5267e4d8e4b0ec79466e48c5 |
|
207 |
+
| Street Food Gathering | 53e0feef498e5aac066fd8a9 |
|
208 |
+
| Taxi | 4bf58dd8d48988d130951735 |
|
209 |
+
| Town | 530e33ccbcbc57f1066bbff3 |
|
210 |
+
| Trade Fair | 5bae9231bedf3950379f89c3 |
|
211 |
+
| Train | 4bf58dd8d48988d12a951735 |
|
212 |
+
| Tree | 52e81612bcbc57f1066b7a24 |
|
213 |
+
| Village | 530e33ccbcbc57f1066bbff9 |
|