Skip to main content

Tools to handle data from indianopenmaps

Project description

Indianopenmaps PyPI - Latest Version

This project provides command-line tools and a PyQt UI for processing geographical data from Indianopenmaps. It supports extracting data from remote geoparquet files as well as filtering local 7z archives containing geojsonl files.

Installation

The iomaps package is available on PyPI. You can install it using pip or uv.

  1. Using pip:

    pip install iomaps
    
  2. Using uv (Recommended): If you have uv installed, you can use it to install iomaps and manage its dependencies.

    a. Install uv: https://docs.astral.sh/uv/getting-started/installation/

    b. Install iomaps: bash uv pip install iomaps Note: This step is not needed if you are using uvx to run commands, as uvx handles dependency management automatically.

Usage

The iomaps package provides a command-line interface (CLI) with several subcommands.

Running with uvx (Recommended)

uvx is the easiest and recommended way to run the indianopenmaps CLI. It automatically manages virtual environments for you, ensuring that the correct dependencies are installed and activated without manual intervention. This means you don't need to explicitly create or activate a virtual environment.

To run commands using uvx:

uvx iomaps <command>

For example:

uvx iomaps cli extract -s "SOI States" -o states.gpkg -b "70,10,90,30"

Running with pip

If you prefer to use pip and manage your virtual environments manually, follow these steps:

  1. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate
    
  2. Install dependencies:

    pip install -e .
    
  3. Run commands: Once the virtual environment is activated and dependencies are installed, you can run the iomaps CLI directly:

    iomaps cli extract -s "SOI States" -o states.gpkg -b "70,10,90,30"
    

    Remember to activate the virtual environment (source .venv/bin/activate) each time you open a new terminal session before running iomaps commands.


Extracting from Remote Geoparquet Files

These commands allow you to extract and filter data directly from remote geoparquet sources hosted on the indianopenmaps server without downloading the entire files.

1. iomaps cli extract

Extract and filter data from a remote geoparquet source.

Sources are resolved by fetching the list from the indianopenmaps API. The command fetches geoparquet files and applies spatial filters.

Sources can be specified by:

  • Name (e.g., "SOI States")
  • Route starting with / (e.g., "/states/soi/")
  • Number from 'iomaps cli sources' list (e.g., "1", "2")

Options:

  • -s, --source <source> (Required): Source to extract from. Can be a name, route (starting with /), or number from 'iomaps cli sources'.
  • -o, --output-file <path> (Required): Path for the output file where processed data will be saved.
  • -d, --output-driver <driver>: Specify output driver (choices: csv, esri shapefile, flatgeobuf, geojson, geojsonseq, gpkg, parquet). If not specified, it will be inferred from the output file extension.
  • -l, --log-level <level>: Set the logging level (choices: DEBUG, INFO, WARNING, ERROR, CRITICAL; default: INFO).
  • -f, --filter-file <path>: Path to an input filter file (e.g., a shapefile) for spatial filtering.
  • --filter-file-driver <driver>: Specify the OGR driver for the filter file. If not specified, it will be inferred from the filter file extension.
  • -b, --bounds <min_lon,min_lat,max_lon,max_lat>: Rectangular bounds for spatial filtering. You can get bounding box coordinates from http://bboxfinder.com/.
  • --pick-filter-feature-id <id>: Select a specific polygon feature by its 0-based index.
  • --pick-filter-feature-kv <key=value>: Select a specific polygon feature by a key-value pair (e.g., 'key=value') from its properties.
  • --routes-file <path>: Path to local JSON file with routes. Cannot be used with --routes-url.
  • --routes-url <url>: URL to fetch routes from. Cannot be used with --routes-file. Default: https://indianopenmaps.fly.dev/api/routes

Example:

uvx iomaps cli extract -s "SOI States" -o states.gpkg -b "70,10,90,30"

2. iomaps cli sources

List available data sources for the extract command.

Sources can be referenced by number, route, or name when using the extract command's --source flag.

Options:

  • -c, --category <category>: Filter by category (can be specified multiple times).
  • -s, --search <text>: Search sources by name or route (fuzzy matching with typo tolerance).
  • --json: Output as JSON.
  • -l, --log-level <level>: Set the logging level.
  • --routes-file <path>: Path to local JSON file with routes.
  • --routes-url <url>: URL to fetch routes from.

Examples:

uvx iomaps cli sources                      # List all sources
uvx iomaps cli sources -c buildings         # Filter by category
uvx iomaps cli sources -s districts         # Search for "districts"
uvx iomaps cli sources -c states -s soi     # Combine filters

3. iomaps cli source-categories

List available source categories.

Shows all categories with the number of sources in each. Use with 'iomaps cli sources -c ' to filter sources.

Options:

  • --json: Output as JSON.
  • -l, --log-level <level>: Set the logging level.
  • --routes-file <path>: Path to local JSON file with routes.
  • --routes-url <url>: URL to fetch routes from.

Example:

uvx iomaps cli source-categories

Filtering/Extracting from Local geojsonl.7z Files

These commands work with 7z archives containing geojsonl files that have been downloaded to your local machine.

Note: These commands require the 7z files to be fully downloaded to the local machine first. For multi-part 7z files (e.g., data.7z.001, data.7z.002, etc.), all parts must be downloaded locally. When running the command, provide the path to the first part (e.g., data.7z.001) and the remaining parts will be located automatically if they are present in the same directory.

1. iomaps cli filter-7z

Processes a 7z archive containing a single geojsonl file by streaming.

Options:

  • -i, --input-7z <path> (Required): Path to the input 7z archive file.
  • -o, --output-file <path> (Required): Path for the output file where processed data will be saved.
  • -d, --output-driver <driver>: Specify output driver (choices: csv, esri shapefile, flatgeobuf, geojson, geojsonseq, gpkg). If not specified, it will be inferred from the output file extension.
  • -s, --schema <path>: Path to a schema file (JSON format). If not provided, the schema will be inferred from the input archive. This requires an extra pass over the data. So, if required you can use the infer-schema command first to generate the schema file and then provide it here.
  • -l, --log-level <level>: Set the logging level (choices: DEBUG, INFO, WARNING, ERROR, CRITICAL; default: INFO).
  • -f, --filter-file <path>: Path to an input filter file (e.g., a shapefile) for spatial filtering.
  • --filter-file-driver <driver>: Specify the OGR driver for the filter file. If not specified, it will be inferred from the filter file extension.
  • -b, --bounds <min_lon,min_lat,max_lon,max_lat>: Rectangular bounds for spatial filtering. You can get bounding box coordinates from http://bboxfinder.com/.
  • --pick-filter-feature-id <id>: Select a specific polygon feature by its 0-based index.
  • --pick-filter-feature-kv <key=value>: Select a specific polygon feature by a key-value pair (e.g., 'key=value') from its properties.

Example:

uvx iomaps cli filter-7z -i data.7z -o filtered_data.geojsonl -b "70,10,90,30"

2. iomaps cli infer-schema

Infers the schema from a 7z archive containing a single geojsonl file and saves it to a JSON file.

Options:

  • -i, --input-7z <path> (Required): Path to the input 7z archive file.
  • -o, --output-file <path>: Path for the output file where the inferred schema will be saved.
  • -l, --log-level <level>: Set the logging level (choices: DEBUG, INFO, WARNING, ERROR, CRITICAL; default: INFO).

Example:

uvx iomaps cli infer-schema -i data.7z -o data_schema.json

3. iomaps ui

Launches a PyQt-based graphical user interface for processing local 7z archives.

Example:

uvx iomaps ui

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

iomaps-0.2.2.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

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

iomaps-0.2.2-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

Details for the file iomaps-0.2.2.tar.gz.

File metadata

  • Download URL: iomaps-0.2.2.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for iomaps-0.2.2.tar.gz
Algorithm Hash digest
SHA256 00a1e54d0620745cc87de3b7305f2cd4403c7cf610e3ee49d1d3331dbe27a2d0
MD5 3f78a911dca7a52dabd8bedcf40704b2
BLAKE2b-256 64aca1d01f454efe57dc8875d3499730f364a1dc4e2f45fb54c1415c85f1ec37

See more details on using hashes here.

File details

Details for the file iomaps-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: iomaps-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 38.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for iomaps-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a728028d371612f3be442e18b78e2225230aa0d173ce2ceac9273008d99c7f32
MD5 43058b994b753de1a7f5d2afcbc227e0
BLAKE2b-256 dabd33dad1ed92533927637dc4f3cb82fa60d73487172210bab2ae1b21920082

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