Skip to main content

Downloads and imports shapefiles into OSM database.

Project description

get-external-data2

A drop-in replacement for the original get-external-data.py script from OpenStreetMap Carto, rewritten with safety, validation, and better user experience in mind.

Overview

get-external-data2 is a full rewrite of the OSM Carto data import utility that downloads and imports shapefiles into a PostGIS database.

It behaves identically to the original script — but is:

  • More reliable (honors HTTP Last-Modified, skips unnecessary re-downloads)
  • Safer (SQL-safe with psycopg3 and type-checked logic)
  • More transparent (shows download progress via tqdm)
  • Configurable and validated (using pydantic with JSON schema generation)

Installation

pip install get-external-data2

Or from source:

git clone https://github.com/insan3d/get-external-data2.git
cd get-external-data2
pip install .

Features

  • Fully backwards-compatible YAML configuration format and CLI interface
  • Built-in --dump-config-schema to generate a JSON Schema for your config
  • --delete-cache flag now actually works
  • Honors HTTP caching (If-Modified-Since / Last-Modified)
  • Clean interruption handling (SIGTERM, KeyboardInterrupt)
  • Progress bars for file downloads
  • Strict validation for schema and table names
  • Safer database logic with transactional DDL via psycopg3

Removed / Changed Behavior

  • file:// protocol is no longer supported for local files — only http(s)://
  • Archive handling is limited to .zip (as in original script, for now)
  • Modern PostgreSQL and GDAL versions are expected (tested with Debian 13 Trixie).

Usage Example

get-external-data2 -c external-data.yml -v

Typical configuration file (external-data.yml):

settings:
  schema: public
  temp_schema: loading
  database: gis
  host: /var/run/postgresql
  username: gis
  metadata_table: external_data

sources:
  simplified_water_polygons:
    url: https://osmdata.openstreetmap.de/download/simplified-water-polygons-complete-3857.zip
    file: simplified-water-polygons-complete-3857/simplified_water_polygons.shp
    archive:
      format: zip
      files:
        - simplified-water-polygons-complete-3857/simplified_water_polygons.shp
        - simplified-water-polygons-complete-3857/simplified_water_polygons.dbf
        - simplified-water-polygons-complete-3857/simplified_water_polygons.prj
        - simplified-water-polygons-complete-3857/simplified_water_polygons.shx

License

MIT License — as the original OSM Carto tools.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

get_external_data2-1.0.2.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

get_external_data2-1.0.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file get_external_data2-1.0.2.tar.gz.

File metadata

  • Download URL: get_external_data2-1.0.2.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for get_external_data2-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2116498ac9031e97311681687d843dcd99385255daa96a9645a09bdc0ea8afc1
MD5 f54b083df9d9921a5ee3d10457c8d626
BLAKE2b-256 b1a1eef09998300f8ae3dfad2c4f333f0522feb85cd2a9d5ad6cb3467dde8e2a

See more details on using hashes here.

File details

Details for the file get_external_data2-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for get_external_data2-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3dc4f93f870ae887a1b9d6f3940555fb85bafd94c04c049a2a63f24ccd2fe1a5
MD5 17910685fd8720b16e2bb4e9b450566e
BLAKE2b-256 04f7b7404f54cfe5225fae1b070705905f35a9943cb5012e2512410615dfb5eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page