Skip to content

Repository files navigation

Buenos Aires Real Estate Visualization Pipeline

A production-quality Python pipeline for visualizing real estate listing data from Zonaprop on a neighborhood-level map of Buenos Aires.

Features

  • Data Cleaning: Normalizes prices to USD, validates coordinates, and standardizes neighborhood names
  • Neighborhood Aggregation: Calculates average prices, price per square meter, and listing counts per neighborhood
  • GeoJSON Integration: Joins aggregated data with neighborhood polygon geometries
  • Interactive Mapping: Creates beautiful folium maps with choropleth visualization and optional individual listing points

Installation

pip install -r requirements.txt

Usage

Basic Usage

python pipeline.py --input scraped_data.csv --geojson barrios_caba.geojson

Advanced Options

# Show individual listings as points
python pipeline.py --input scraped_data.csv --geojson barrios_caba.geojson --show-listings

# Use custom exchange rate
python pipeline.py --input scraped_data.csv --geojson barrios_caba.geojson --usd-rate 1200.0

# Use different price column for coloring
python pipeline.py --input scraped_data.csv --geojson barrios_caba.geojson --price-column avg_price_per_sqm_usd

# Custom output file
python pipeline.py --input scraped_data.csv --geojson barrios_caba.geojson --output my_map.html

Command Line Arguments

  • --input: Path to input CSV file (default: scraped_data.csv)
  • --geojson: Path to GeoJSON file with Buenos Aires neighborhoods (optional, will attempt to download if not provided)
  • --output: Path to output HTML map file (default: buenos_aires_map.html)
  • --usd-rate: USD to ARS exchange rate for currency conversion (default: 1000.0)
  • --show-listings: Show individual listings as semi-transparent points on the map
  • --price-column: Column to use for coloring neighborhoods (default: avg_price_usd)

Getting a GeoJSON File

You need a GeoJSON file with Buenos Aires neighborhood polygons. Here are some sources:

  1. Buenos Aires Open Data Portal: https://data.buenosaires.gob.ar/

    • Search for "barrios" or "comunas"
    • Look for datasets with polygon geometries
  2. OpenStreetMap: Extract neighborhood boundaries using Overpass API or download from OSM extracts

  3. GitHub: Search for "buenos aires geojson" or "caba barrios geojson"

  4. Government Sources: Buenos Aires city government may provide official neighborhood boundaries

The GeoJSON should have:

  • A column with neighborhood names (common names: barrio, nombre, name, BARRIO)
  • Polygon geometries in WGS84 (EPSG:4326) coordinate system

Input Data Format

The CSV file should contain at minimum:

  • Price: Column named price_amount, price_value, or price
  • Currency: Column named currency_pri, price_type, or currency (values: USD, $, ARS, etc.)
  • Coordinates: Columns named geo_latitude/geo_longitude, latitude/longitude, or lat/lon
  • Neighborhood: Column named neighborhood_json, neighborhood, or barrio
  • Area (optional): Column named m2_total, total_area, m2_covered, or covered_area

Output

The pipeline generates:

  1. Interactive HTML Map (buenos_aires_map.html by default):
    • Neighborhood polygons colored by average price
    • Hover tooltips with neighborhood statistics
    • Optional individual listing points
    • Color scale legend
    • Multiple base map layers (OpenStreetMap, CartoDB)

Module Structure

The pipeline is organized into modular components:

  • data_cleaning.py: Cleans and normalizes raw listing data
  • aggregation.py: Aggregates listings by neighborhood
  • geojson_handler.py: Loads and joins GeoJSON data
  • mapping.py: Creates interactive folium maps
  • pipeline.py: Main orchestration script

Example Output

The map will show:

  • Neighborhood polygons with colors representing average prices (darker = higher price)
  • Tooltips showing neighborhood name, average price, listing count, and price per square meter
  • Individual listings (if --show-listings is used) as semi-transparent points
  • Legend explaining the color scale

Handling Missing Data

The pipeline gracefully handles:

  • Missing neighborhoods in GeoJSON (reports unmatched neighborhoods)
  • Missing neighborhoods in listings (keeps all GeoJSON neighborhoods)
  • Invalid coordinates (filters out listings outside Buenos Aires bounds)
  • Invalid prices (filters out unrealistic values)
  • Missing area data (aggregates price-only statistics)

Notes

  • The default USD to ARS exchange rate is 1000.0. Update this with --usd-rate for current rates.
  • Neighborhood name matching uses fuzzy normalization (lowercase, no accents) to handle variations.
  • Coordinates are validated to be within Buenos Aires bounds (approximately -34.3 to -34.8 latitude, -58.2 to -58.6 longitude).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages