flatgeobuf


Nameflatgeobuf JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/ozekik/python-flatgeobuf
SummaryPython library for FlatGeobuf
upload_time2024-03-12 18:24:16
maintainer
docs_urlNone
authorKentaro Ozeki
requires_python>=3.9,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-flatgeobuf

[![PyPI](https://img.shields.io/pypi/v/flatgeobuf.svg)](https://pypi.org/project/flatgeobuf/)
[![build](https://github.com/ozekik/python-flatgeobuf/actions/workflows/ci.yaml/badge.svg)](https://github.com/ozekik/python-flatgeobuf/actions/workflows/ci.yaml)

A Python library for [FlatGeobuf](https://flatgeobuf.org/).
Ported from the official [TypeScript implementation](https://github.com/flatgeobuf/flatgeobuf/tree/master/src/ts).

## Installation

```bash
pip install flatgeobuf
```

## Usage

### Loaders

#### `load()`

```python
import flatgeobuf as fgb

# All features
with open("example.fgb", "rb") as f:
    data = fgb.load(f)

# ...or features within a bounding box
with open("example.fgb", "rb") as f:
    data = fgb.load(f, bbox=(-26.5699, 63.1191, -12.1087, 67.0137))

print(data)
# { "type": "FeatureCollection", "features": [...] }
```

#### `load_http()` (Async)

```python
import flatgeobuf as fgb

# All features
data = await fgb.load_http("https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb")

# ...or features within a bounding box
data = await fgb.load_http(
  "https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb",
  bbox=(-26.5699, 63.1191, -12.1087, 67.0137)
)

print(data)
# { "type": "FeatureCollection", "features": [...] }
```

### Readers

#### `Reader`

```python
import flatgeobuf as fgb

# All features
with open("example.fgb", "rb") as f:
    reader = fgb.Reader(f)
    for feature in reader:
        print(feature)
        # { "type": "Feature", "properties": {...}, "geometry": {...} }

# ...or features within a bounding box
with open("example.fgb", "rb") as f:
    reader = fgb.Reader(f, bbox=(-26.5699, 63.1191, -12.1087, 67.0137))
    for feature in reader:
        print(feature)
        # { "type": "Feature", "properties": {...}, "geometry": {...} }
```

#### `HTTPReader` (Async)

```python
import flatgeobuf as fgb

# All features
reader = fgb.HTTPReader("https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb")
  async for feature in reader:
      print(feature)
      # { "type": "Feature", "properties": {...}, "geometry": {...} }

# ...or features within a bounding box
reader = fgb.HTTPReader(
    "https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb",
    bbox=(-26.5699, 63.1191, -12.1087, 67.0137)
)
async for feature in reader:
    print(feature)
    # { "type": "Feature", "properties": {...}, "geometry": {...} }
```

## Roadmap

- [x] Read FlatGeobuf
  - [ ] Read top-level (`FeatureCollection`) properties
- [ ] Write FlatGeobuf
- [ ] Rewrite some parts in Rust (parcked R-tree, geometry intersection)

## License

MIT

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ozekik/python-flatgeobuf",
    "name": "flatgeobuf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Kentaro Ozeki",
    "author_email": "kentaro.ozeki+dev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/24/0c/830c7c5ff2e37ee5c2eeb73607fb141ab1e22abdd0f9201df4e3b1e51e50/flatgeobuf-0.2.0.tar.gz",
    "platform": null,
    "description": "# python-flatgeobuf\n\n[![PyPI](https://img.shields.io/pypi/v/flatgeobuf.svg)](https://pypi.org/project/flatgeobuf/)\n[![build](https://github.com/ozekik/python-flatgeobuf/actions/workflows/ci.yaml/badge.svg)](https://github.com/ozekik/python-flatgeobuf/actions/workflows/ci.yaml)\n\nA Python library for [FlatGeobuf](https://flatgeobuf.org/).\nPorted from the official [TypeScript implementation](https://github.com/flatgeobuf/flatgeobuf/tree/master/src/ts).\n\n## Installation\n\n```bash\npip install flatgeobuf\n```\n\n## Usage\n\n### Loaders\n\n#### `load()`\n\n```python\nimport flatgeobuf as fgb\n\n# All features\nwith open(\"example.fgb\", \"rb\") as f:\n    data = fgb.load(f)\n\n# ...or features within a bounding box\nwith open(\"example.fgb\", \"rb\") as f:\n    data = fgb.load(f, bbox=(-26.5699, 63.1191, -12.1087, 67.0137))\n\nprint(data)\n# { \"type\": \"FeatureCollection\", \"features\": [...] }\n```\n\n#### `load_http()` (Async)\n\n```python\nimport flatgeobuf as fgb\n\n# All features\ndata = await fgb.load_http(\"https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb\")\n\n# ...or features within a bounding box\ndata = await fgb.load_http(\n  \"https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb\",\n  bbox=(-26.5699, 63.1191, -12.1087, 67.0137)\n)\n\nprint(data)\n# { \"type\": \"FeatureCollection\", \"features\": [...] }\n```\n\n### Readers\n\n#### `Reader`\n\n```python\nimport flatgeobuf as fgb\n\n# All features\nwith open(\"example.fgb\", \"rb\") as f:\n    reader = fgb.Reader(f)\n    for feature in reader:\n        print(feature)\n        # { \"type\": \"Feature\", \"properties\": {...}, \"geometry\": {...} }\n\n# ...or features within a bounding box\nwith open(\"example.fgb\", \"rb\") as f:\n    reader = fgb.Reader(f, bbox=(-26.5699, 63.1191, -12.1087, 67.0137))\n    for feature in reader:\n        print(feature)\n        # { \"type\": \"Feature\", \"properties\": {...}, \"geometry\": {...} }\n```\n\n#### `HTTPReader` (Async)\n\n```python\nimport flatgeobuf as fgb\n\n# All features\nreader = fgb.HTTPReader(\"https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb\")\n  async for feature in reader:\n      print(feature)\n      # { \"type\": \"Feature\", \"properties\": {...}, \"geometry\": {...} }\n\n# ...or features within a bounding box\nreader = fgb.HTTPReader(\n    \"https://raw.githubusercontent.com/flatgeobuf/flatgeobuf/master/test/data/countries.fgb\",\n    bbox=(-26.5699, 63.1191, -12.1087, 67.0137)\n)\nasync for feature in reader:\n    print(feature)\n    # { \"type\": \"Feature\", \"properties\": {...}, \"geometry\": {...} }\n```\n\n## Roadmap\n\n- [x] Read FlatGeobuf\n  - [ ] Read top-level (`FeatureCollection`) properties\n- [ ] Write FlatGeobuf\n- [ ] Rewrite some parts in Rust (parcked R-tree, geometry intersection)\n\n## License\n\nMIT\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python library for FlatGeobuf",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/ozekik/python-flatgeobuf"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3be0d3fd6f76598d258d5cbe8f2e1aa0874a23afd0d3373a18f1f1ac0a32ae94",
                "md5": "70bdb6c41b1c2a6855ed0f4727822000",
                "sha256": "e2f2a2bb3eaa979646ee8c834456e0e45ab14782f7055b3d67811d07f51ff54e"
            },
            "downloads": -1,
            "filename": "flatgeobuf-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70bdb6c41b1c2a6855ed0f4727822000",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 31999,
            "upload_time": "2024-03-12T18:23:48",
            "upload_time_iso_8601": "2024-03-12T18:23:48.821533Z",
            "url": "https://files.pythonhosted.org/packages/3b/e0/d3fd6f76598d258d5cbe8f2e1aa0874a23afd0d3373a18f1f1ac0a32ae94/flatgeobuf-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "240c830c7c5ff2e37ee5c2eeb73607fb141ab1e22abdd0f9201df4e3b1e51e50",
                "md5": "af75259087b2fddb0dd2227bcc5fc761",
                "sha256": "b6c331db2f42418c7281e3041087a65196e8572be36177651168cdd8bcaa4ad4"
            },
            "downloads": -1,
            "filename": "flatgeobuf-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "af75259087b2fddb0dd2227bcc5fc761",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 22144,
            "upload_time": "2024-03-12T18:24:16",
            "upload_time_iso_8601": "2024-03-12T18:24:16.741978Z",
            "url": "https://files.pythonhosted.org/packages/24/0c/830c7c5ff2e37ee5c2eeb73607fb141ab1e22abdd0f9201df4e3b1e51e50/flatgeobuf-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-12 18:24:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ozekik",
    "github_project": "python-flatgeobuf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "flatgeobuf"
}
        
Elapsed time: 0.19155s