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.1.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.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: get_external_data2-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 30c976efe66e72ca4be4efb6e8feb2731f44e04fe181f7e8a28fc9ae52cccb76
MD5 9ee62e0963bf54a20207ebd858efaf1f
BLAKE2b-256 0cbeb218ba0ef298a26293f6cbf0726cdfe7161d49c9b894a59b699a2be3237f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for get_external_data2-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f207948373f99b46c17515b053a77251d3224975508235b8720c4592be7cb20
MD5 371662cfd90644fd67343ebf923b4251
BLAKE2b-256 6d7dd22c98a108269f6b5856261e295ae343d760749082f5005901a35a309832

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