This Python script reads addresses from a CSV file, processes them using geocoding services (ArcGIS and Komoot), and saves the results with latitude and longitude coordinates.
- Reads addresses from a CSV file
- Uses ArcGIS and Komoot geocoding services
- Implements retry logic for failed requests
- Saves output CSV files at defined intervals
- Handles missing data and errors gracefully
Ensure you have the following installed:
-
Python 3.x
-
Required Python libraries: sh pip install pandas requests geocoder
Modify the following parameters in the script to suit your needs:
input_file_path: Path to the input CSV file containing addressesoutput_dir: Directory where the results will be savedaddress_column_name,city_column_name,plz_column_name: Define column namesstart_index: Start processing from a specific row (useful for resuming after a crash)status_rate: Print progress after processing every N addresseswrite_data_rate: Write intermediate results to a file after every N processed addressesattempts_to_geocode: Number of retries before giving up on an addresswait_time: Initial delay before retrying failed requests
-
Prepare your CSV file with columns for address, city, and optionally postal codes.
-
Run the script: sh python geo_calc.py
-
Results will be saved in the
output_test_coorddirectory.
The script generates CSV files containing:
- Address
- Latitude
- Longitude
- Geocoding Provider
- If an address cannot be geocoded, it is marked as "not geocoded".
- Errors are logged, and failed attempts are retried with a delay.
Contributions are welcome!
Distributed under the GNU Affero General Public License v3.0 License. See LICENSE for more information.