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.
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.
- π 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
- Identifies your home using the predefined home activity ID
- Applies global shift - Moves all coordinates by 1-10km randomly
- Adds targeted noise - Extra randomization within configurable radius of home
- Preserves relationships - Maintains relative distances and movement patterns
- Generates visualization - Shows before/after comparison for verification
- Python 3.11 or higher
- matplotlib
- numpy
# 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 --helppython location_anonymizer.py input.json output.json "19ac8d10-e85e-11ea-9c89-eb597145d8d6"python location_anonymizer.py input.json output.json "19ac8d10-e85e-11ea-9c89-eb597145d8d6" --radius 0.8 --noise 0.4 --viz demo.pngpython location_anonymizer.py input.json output.json "19ac8d10-e85e-11ea-9c89-eb597145d8d6" --no-viz| 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 |
# 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.pngJSON 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)
}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}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
- β 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
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
- Ensure your JSON file contains the expected places structure
- Verify the home activity ID exists in your data
pip install matplotlib numpy# Make sure you have write permissions in the output directory
chmod 755 output_directory/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 is a research team specializing in mobility data analytics and sustainable transportation solutions.
This project is licensed under the MIT License - see the LICENSE file for details.
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