Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Privacy-preserving location data anonymization tool with home-based protection to comply with GDPR rules and preserve location anonymity

Notifications You must be signed in to change notification settings

acesonic7/location_anonymizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”’ Location Data Anonymizer

image

Privacy-preserving location data anonymization tool with home-based protection.

Developed by MobyX in the context of the SPINE project for secure location data sharing and privacy protection in research.

πŸ“‹ Overview

This tool anonymizes personal location traces from JSON datasets, mostly coming from Citizen app tracking data, by applying intelligent coordinate scrambling around a user-designated home location. It maintains spatial relationships for data utility while protecting privacy through global coordinate shifting and proximity-based noise injection.

✨ Features

  • 🏠 Home-Based Anonymization - Protection/scramble around home location
  • 🌍 Global Coordinate Shifting - Moves all locations by a random offset
  • πŸ”Š Proximity-Based Noise - More scrambling near sensitive areas
  • πŸ“Š Before/After Visualization - See exactly how your data is protected
  • πŸ”’ Complete Privacy - Original coordinates never retained in output
  • πŸ“ JSON Structure Preserved - Only location coordinates are modified

πŸ”§ How It Works

  1. Identifies your home using the predefined home activity ID
  2. Applies global shift - Moves all coordinates by 1-10km randomly
  3. Adds targeted noise - Extra randomization within configurable radius of home
  4. Preserves relationships - Maintains relative distances and movement patterns
  5. Generates visualization - Shows before/after comparison for verification

πŸ“¦ Installation & Setup

Requirements

  • Python 3.11 or higher
  • matplotlib
  • numpy

Installation

# 1. Clone the repository
git clone https://github.com/acesonic7/location_anonymizer.git
cd location_anonymizer

# 2. Install dependencies
pip install matplotlib numpy

# 3. Verify installation
python location_anonymizer.py --help

πŸš€ Usage

Basic Usage

python location_anonymizer.py input.json output.json "19ac8d10-e85e-11ea-9c89-eb597145d8d6"

With Custom Settings

python location_anonymizer.py input.json output.json "19ac8d10-e85e-11ea-9c89-eb597145d8d6" --radius 0.8 --noise 0.4 --viz demo.png

Skip Visualization (Faster Processing)

python location_anonymizer.py input.json output.json "19ac8d10-e85e-11ea-9c89-eb597145d8d6" --no-viz

Parameters

Parameter Description Default Range
--radius Anonymization radius around home (km) 0.5 0.1-5.0
--noise Noise intensity factor 0.3 0.1-1.0
--viz Save visualization to specific file auto-generated any path
--no-viz Skip visualization creation false flag

πŸ“Š Complete Example

# Anonymize with high privacy settings and save visualization
python location_anonymizer.py MyLocationData.json MyLocationData_anonymized.json "19ac8d10-e85e-11ea-9c89-eb597145d8d6" --radius 0.8 --noise 0.6 --viz privacy_demo.png

# Output:
# βœ“ Found home location: 40.712776, -74.005974
# βœ“ Applying global coordinate offset: 0.045123Β°, -0.078456Β°
# βœ“ Processed 2847 valid location points
# βœ“ 156 points within anonymization radius received extra noise
# βœ“ VERIFICATION PASSED: All 2847 coordinates successfully anonymized
# βœ“ Anonymized data saved successfully!
# βœ“ Visualization saved to: privacy_demo.png

πŸ“Š Input/Output

Input Format

JSON file with this structure:

{
  "locations": [...],      // Location records with lat/lon coordinates
  "places": [...],         // Places including home location
  "geoFence": [...],       // Geofence events (unchanged)
  "userMobilities": [...], // User mobility data (unchanged)  
  "predictions": [...]     // Predictions (unchanged)
}

Output Format

Identical JSON structure with anonymized coordinates in the locations array. All other data remains unchanged.

Original location:

{"latitude": 40.712776, "longitude": -74.005974}

Anonymized location:

{"latitude": 40.698234, "longitude": -73.991847}

πŸ“ Project Structure

location-anonymizer/
β”œβ”€β”€ location_anonymizer.py    # Main anonymization script
β”œβ”€β”€ find_home_id.py          # Helper script (for development)
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ README.md               # This file
└── examples/               # Example files and outputs

πŸ”’ Privacy Guarantees

  • βœ… No original coordinates in output - Completely replaced with anonymized versions
  • βœ… Irreversible transformation - Cannot recover original locations from output
  • βœ… Global coordinate shift - Entire dataset moved 1-10km randomly
  • βœ… Home-area protection - Extra noise within configurable radius of home
  • βœ… Verification system - Confirms no original coordinates remain

πŸ“Š Visualization

The tool generates before/after visualizations showing:

  • Left panel: Original location data centered on actual home
  • Right panel: Anonymized data with coordinate shifts and noise
  • Statistics: Details about anonymization parameters and affected points
  • Visual indicators: Home location, anonymization radius, and data points

πŸ› Troubleshooting

"Home location not found"

  • Ensure your JSON file contains the expected places structure
  • Verify the home activity ID exists in your data

"matplotlib not available"

pip install matplotlib numpy

Permission issues

# Make sure you have write permissions in the output directory
chmod 755 output_directory/

πŸ“„ About

SPINE Project

This tool was developed as part of the SPINE (Sustainable Personal Indoor and Outdoor Navigation Experience) project, which focuses on advancing public transport and sustainable transportation .

MobyX

MobyX is a research team specializing in mobility data analytics and sustainable transportation solutions.

License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Contact

For questions, issues, or collaboration opportunities related to the SPINE project or location data anonymization:

  • Open an issue on GitHub
  • Contact the MobyX development team
  • Check the troubleshooting section above

⚠️ Important: Always verify your anonymized data meets your privacy requirements before sharing. This tool provides technical anonymization but cannot guarantee complete privacy in all scenarios. Use responsibly.

About

Privacy-preserving location data anonymization tool with home-based protection to comply with GDPR rules and preserve location anonymity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published