Metadata-Version: 2.4
Name: pynspd
Version: 1.1.6
Summary: Python-библиотека для работы с https://nspd.gov.ru (ex-ПКК)
Project-URL: Homepage, https://yazmolod.github.io/pynspd/
Project-URL: Repository, https://github.com/yazmolod/pynspd
Project-URL: Issues, https://github.com/yazmolod/pynspd/issues
Project-URL: Changelog, https://github.com/yazmolod/pynspd/releases
Author-email: Aleksandr Litovchenko <yazmolod@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Aleksandr Litovchenko
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: geojson-pydantic>=1.2.0
Requires-Dist: hishel<1.0.0,>=0.1.1
Requires-Dist: httpx>=0.28.1
Requires-Dist: mercantile>=1.2.1
Requires-Dist: numpy>1.24.4
Requires-Dist: pydantic>=2.10.4
Requires-Dist: pyproj>=3.7
Requires-Dist: shapely>=2.0.6
Requires-Dist: ua-generator>=2.0.10
Provides-Extra: cli
Requires-Dist: geopandas>=1.0.1; extra == 'cli'
Requires-Dist: openpyxl>=3.1.5; extra == 'cli'
Requires-Dist: questionary>=2.1.0; extra == 'cli'
Requires-Dist: typer>=0.15.2; extra == 'cli'
Provides-Extra: redis
Requires-Dist: redis==6.0.0; extra == 'redis'
Provides-Extra: socks
Requires-Dist: socksio>=1.0.0; extra == 'socks'
Provides-Extra: sqlite
Requires-Dist: anysqlite>=0.0.5; extra == 'sqlite'
Description-Content-Type: text/markdown

# pynspd

<p align="center">
  <em> Python-библиотека для работы с <a href="https://nspd.gov.ru" target="_blank">НСПД - Национальной системой пространственных данных</a> (ex-ПКК)</em>
</p>
<p align="center">
  <a href="https://pypi.org/project/pynspd/" target="_blank">
      <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/pynspd">
  </a>
  <a href='https://coveralls.io/github/yazmolod/pynspd?branch=main'>
    <img src='https://coveralls.io/repos/github/yazmolod/pynspd/badge.svg?branch=main' alt='Coverage Status' />
  </a>
</p>

---

> ⚠️ **Важно**
>
> Данная библиотека является неофициальным проектом и создана исключительно в образовательных целях

## Особенности
- **Синхронное и асинхронное API**: полностью идентичные API позволяют одинаково удобно работать в разных проектах.
- **Полная типизации проекта**: автозаполнения в IDE, статический анализ и прочие удобства современного Python.
- **Автогенерация схем**: данные о перечне слоев, их полях и их типах подтягиваются напрямую с НСПД.
- **Валидации данных от [Pydantic](https://github.com/pydantic/pydantic)**: гарантия, что библиотека соответствует сайту.
- **Поддержка работы с геометрией от [Shapely](https://github.com/shapely/shapely)**: удобная аналитика полученной геометрии.
- **Кэширование из коробки от [Hishel](https://hishel.com)**: сохранение данных в Redis, SQLite и других форматах.

## Быстрый старт

Установите `pynspd`:

``` shell
$ pip install pynspd
```

Найдите нужный вам объект:

```python
from pynspd import Nspd

with Nspd() as nspd:
    feat = nspd.find("77:05:0001005:19")
```

Доступен полный список аттрибутов (в том числе скрытых):
```python
    print(feat.properties.options.model_dump())
    #> {'readable_address': 'г Москва, ул Серпуховская Б., вл 58',
    #>  'land_record_subtype': 'Землепользование', ...}
```

Который можно конвертировать в человекочитаемый формат:

```python
    print(feat.properties.cast().options.model_dump_human_readable())
    #> {'Адрес': 'г Москва, ул Серпуховская Б., вл 58',
    #>  'Вид земельного участка': 'Землепользование', ...}
```

Для доступа к дополнительным аттрибутам делаем запрос по вкладке:

```python
    print(nspd.tab_objects_list(feat))
    #> {'Объект недвижимости: ': ['77:05:0001005:1012']}
```

Геометрию можно сразу конвертировать в `shapely`-формат (например, для работы с `geopandas`):

```python
    print(feat.geometry.to_shape().bounds)
    #> (37.62575417009177, 55.719792499833524, 37.626451149629915, 55.72046606889391)
```

---

С более детальным описанием библиотеки можно ознакомиться в [руководстве пользователя](https://yazmolod.github.io/pynspd/userguide/).

## Работа из консоли (CLI)

Установка:
``` shell
$ pip install pynspd[cli]
$ pynspd --version
1.0.0
```

Для поиска по к/н:
``` shell
$ pynspd find "77:05:0001005:19"
```

Для поиска по геометрии:
``` shell
$ pynspd geo "55.605, 37.562" 
```

Подробный обзор можно найти в [этой статье](https://yazmolod.github.io/pynspd/advanced/cli/).

## Поддержка проекта

Самый простой способ - это оставить ⭐ проекту на [GitHub](https://github.com/yazmolod/pynspd) и отправить его своим коллегам. 
Если же вы хотите принять участие в его развитии, ознакомьтесь со статьей ["Как поддержать проект?"](https://yazmolod.github.io/pynspd/contributing/).