This project explores and visualizes publicly available Airbnb listing data for Barcelona, Spain, using Python's geospatial libraries. By mapping listings onto neighborhood boundaries, we analyze and visualize key metrics like listing density and median prices to uncover spatial patterns and trends.
Note: Listings come from publicly available Airbnb archives.
This notebook visualizes locations, densities, and neighborhood-level median prices (for Entire home/apt) across multiple listing snapshots.
This repository contains a Jupyter Notebook (airbnb_barcelona.ipynb) that guides you through a geospatial analysis of Airbnb listings. The process involves:
- Data Preparation: Loading and cleaning Airbnb listings and geospatial data for Barcelona's neighborhoods and districts.
- Geospatial Joins: Merging listing data with neighborhood geometries to enable spatial analysis.
- Metric Calculation: Computing the count, density, and median price of "Entire home/apt" listings for each neighborhood.
- Visualization: Creating choropleth maps to visually represent these metrics across Barcelona, revealing how listings are distributed.
The analysis focuses on creating compelling choropleth maps to answer key questions about Barcelona's Airbnb market.
-
Listing Count & Density We calculate the raw number of "Entire home/apt" listings per neighborhood, as well as the listing density (listings per square kilometer). The maps reveal a clear concentration of listings in the central districts, particularly in the Ciutat Vella area.
-
Median Price Distribution By plotting the median price of listings, we observe a distinct spatial pattern. Neighborhoods with higher listing densities in the city center often correlate with higher median prices, though some outlying areas also command premium rates.
Core: Python 3.7+ and Jupyter Notebook for interactive analysis.
- Data Handling: Pandas and NumPy for data manipulation and calculations.
- Geospatial: GeoPandas (geometries/joins), Contextily (web basemaps)
- Visualization: Matplotlib for creating the maps and plots.
Using a virtual environment is recommended.
# (optional) Create and activate a virtual environment
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate
python -m pip install --upgrade pip
pip install pandas numpy geopandas matplotlib contextily** Using conda (recommended for Geopandas)
conda create -n airbnb-geo python=3.9 -y
conda activate airbnb-geo
conda install -c conda-forge geopandas contextily matplotlib pandas numpy -y- Clone this repository.
- Activate your virtual environment (pip or conda).
- Launch Jupyter Notebook from the project directory.
jupyter notebook
# open notebooks/airbnb_barcelona.ipynb and run cells top-to-bottom- Open airbnb_barcelona.ipynb and run the cells from top to bottom.
Data/
ββ barris.geojson # neighborhoods (polygons, includes AREA)
ββ districts.geojson # districts (polygons)
ββ listings_24.csv
ββ listings_30.csv
ββ listings_33.csv
ββ listings_45.csv
airbnb_barcelona.ipynb
README.md
- Count: number of Entire home/apt listings per neighborhood
- Density: count / AREA (AREA from barris.geojson)
- Median price: median price per neighborhood These are merged onto the neighborhoods GeoDataFrame and visualized as choropleths (single and four-panel). Use a consistent CRS (e.g., EPSG:3857) before adding Contextily basemaps.
This project is for educational and analytical purposes only. The Airbnb data used is publicly available.