Datasets:
license: apache-2.0
task_categories:
- feature-extraction
size_categories:
- 100M<n<1B
tags:
- geospatial
Foursquare OS Places 100M
Full Foursquare OS Places dump from https://opensource.foursquare.com/os-places/. This is a single (geo-)parquet file based on the 81 individual parquet files from fused.io on https://source.coop/fused/fsq-os-places/2024-11-19/places.
As it's just 10Gb, it's fairly easy to handle as a single file and can easily be queried over modern technologies like httpfs.
Ways to query the file & visualize the results
If you just want to poke around in the data to get an idea of kind of places to expect, I'd recommend DuckDB. Huggingface has a DuckDB WASM console integrated but it's too slow (or runs out of memory) when run over the entire file. You can try it here
A better way is to run DuckDB locally and query it over httpfs (you do not need to download the whole file but thanks to modern range requests DuckDB just pulls the entries that match the query) as such, e.g. in Python or in the CLI. Here I use Jupyter and convert the results to a pandas view for displaying convenience.
Example 1: Queried over httpfs with DuckDB
import duckdb
duckdb.sql("INSTALL httpfs;LOAD httpfs;") # required extension
duckdb.sql(f"SELECT * FROM 'hf://datasets/do-me/foursquare_places_100M/foursquare_places.parquet' WHERE name ILIKE '%bakery%' ").df()
This command takes roughly 70 seconds on my system/network (M3 Max) and yields 104985 entries:
Example 2: Queried fully locally with DuckDB
This method is much faster, but you need to download the file once. Just download the file directly clicking this link. You could also use Huggingface datasets library.
import duckdb
duckdb.sql("SELECT * FROM 'foursquare_places.parquet' WHERE name ILIKE '%bakery%' ").df()
It yields precisely the same results but takes only 4.5 seconds!
Example 3: Queried fully locally with Geopandas
In case you'd like to do some easy geoprocessing, just stick to Geopandas. It's of course a bit slower and loads everything in memory but gets the job done nicely.
import geopandas as gpd
gdf = gpd.read_parquet("foursquare_places.parquet")
Loading the gdf once takes 2 - 3 mins in my case.
Then you can make use of good old pandas query operators and geospatial tools.
E.g. looking for bakeries again.
gdf[gdf["name"].str.contains("bakery")]
I was actually surprised that the string operator in pandas is that efficient! It only takes 11 seconds, so fairly fast for 100M rows!
But to be fair, the actual equivalent to ILIKE in pandas would be this query:
gdf[gdf["name"].str.contains("bakery", case=False, na=False)]
It yields exactly the same number of rows like the SQL command but takes 19 seconds, so - as expected - indeed much slower than DuckDB (especially considering that we just count the query time, not the loading time)
Example 4: Queried fully locally with Geopandas and visualized with Lonboard
If you quickly want to visulize the data, Lonboard is a super convenient Jupyter wrapper for deck.gl.
Install it with pip install lonboard
and you're ready to go.
import geopandas as gpd
from lonboard import viz
gdf = gpd.read_parquet("foursquare_places.parquet")
bakeries = gdf[gdf["name"].str.contains("bakery", case=False, na=False)]
viz(bakeries)
It created a nice interactive map with tooltips.