carbr 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- carbr-0.1.0/.github/workflows/ci.yml +35 -0
- carbr-0.1.0/.github/workflows/docs.yml +24 -0
- carbr-0.1.0/.github/workflows/pypi.yml +51 -0
- carbr-0.1.0/.gitignore +11 -0
- carbr-0.1.0/LICENSE +21 -0
- carbr-0.1.0/NEWS.md +10 -0
- carbr-0.1.0/PKG-INFO +129 -0
- carbr-0.1.0/README.md +66 -0
- carbr-0.1.0/docs/api.md +37 -0
- carbr-0.1.0/docs/assets/analise-anos.png +0 -0
- carbr-0.1.0/docs/assets/anos.png +0 -0
- carbr-0.1.0/docs/assets/estados.png +0 -0
- carbr-0.1.0/docs/assets/etapas.png +0 -0
- carbr-0.1.0/docs/assets/extra.css +12 -0
- carbr-0.1.0/docs/assets/fora.png +0 -0
- carbr-0.1.0/docs/assets/logo.svg +18 -0
- carbr-0.1.0/docs/assets/mapa-petrolina.png +0 -0
- carbr-0.1.0/docs/assets/para.png +0 -0
- carbr-0.1.0/docs/assets/razao.png +0 -0
- carbr-0.1.0/docs/fila-da-analise.md +204 -0
- carbr-0.1.0/docs/inconsistencias.md +260 -0
- carbr-0.1.0/docs/index.md +65 -0
- carbr-0.1.0/docs/news.md +10 -0
- carbr-0.1.0/docs/precompile.py +743 -0
- carbr-0.1.0/docs/primeiros-passos.md +418 -0
- carbr-0.1.0/mkdocs.yml +63 -0
- carbr-0.1.0/pyproject.toml +63 -0
- carbr-0.1.0/src/carbr/__init__.py +63 -0
- carbr-0.1.0/src/carbr/_client.py +246 -0
- carbr-0.1.0/src/carbr/_msg.py +26 -0
- carbr-0.1.0/src/carbr/cite.py +26 -0
- carbr-0.1.0/src/carbr/data.py +361 -0
- carbr-0.1.0/tests/conftest.py +88 -0
- carbr-0.1.0/tests/test_carbr.py +141 -0
- carbr-0.1.0/tests/test_live.py +11 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ${{ matrix.os }}
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
os: [ubuntu-latest, windows-latest]
|
|
16
|
+
python: ["3.10", "3.13"]
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python }}
|
|
22
|
+
- run: pip install -e ".[dev]"
|
|
23
|
+
- run: ruff check .
|
|
24
|
+
- run: pytest -q
|
|
25
|
+
|
|
26
|
+
# From a runner outside Brazil, the package must read the public bucket.
|
|
27
|
+
live:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
- uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version: "3.13"
|
|
34
|
+
- run: pip install -e ".[dev]"
|
|
35
|
+
- run: pytest -q -m live
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Builds the site from the precompiled pages (no network needed) and
|
|
2
|
+
# publishes it to the gh-pages branch.
|
|
3
|
+
name: docs
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
docs:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.13"
|
|
21
|
+
- run: pip install -e ".[docs]"
|
|
22
|
+
# docs/news.md is a copy of NEWS.md; refresh it so the page never drifts.
|
|
23
|
+
- run: cp NEWS.md docs/news.md
|
|
24
|
+
- run: mkdocs gh-deploy --force --strict
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Publishes carbr to PyPI via trusted publishing (OIDC, no token).
|
|
2
|
+
# Runs on tags v* (e.g. v0.1.0) or manually. Register once on pypi.org
|
|
3
|
+
# (Publishing -> pending publisher): owner StrategicProjects, repository
|
|
4
|
+
# carbr-py, workflow pypi.yml, environment pypi. Do not rename this file.
|
|
5
|
+
name: pypi
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags: ["v*"]
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.12"
|
|
23
|
+
- name: Tag matches the declared version
|
|
24
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
25
|
+
run: |
|
|
26
|
+
declared=$(grep -m1 '^version' pyproject.toml | cut -d'"' -f2)
|
|
27
|
+
test "v$declared" = "$GITHUB_REF_NAME" || { echo "tag $GITHUB_REF_NAME, pyproject $declared"; exit 1; }
|
|
28
|
+
- run: pip install build twine
|
|
29
|
+
- run: python -m build
|
|
30
|
+
- run: twine check dist/*
|
|
31
|
+
- run: pip install dist/*.whl && python -I -c "import carbr; print(carbr.__version__)"
|
|
32
|
+
- uses: actions/upload-artifact@v4
|
|
33
|
+
with:
|
|
34
|
+
name: dist
|
|
35
|
+
path: dist/
|
|
36
|
+
|
|
37
|
+
publish:
|
|
38
|
+
needs: build
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
environment: pypi
|
|
41
|
+
permissions:
|
|
42
|
+
id-token: write
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/download-artifact@v4
|
|
45
|
+
with:
|
|
46
|
+
name: dist
|
|
47
|
+
path: dist/
|
|
48
|
+
# A Docker action: pin the release tag, not a commit SHA.
|
|
49
|
+
- uses: pypa/gh-action-pypi-publish@v1.14.2
|
|
50
|
+
with:
|
|
51
|
+
skip-existing: true
|
carbr-0.1.0/.gitignore
ADDED
carbr-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 carbr authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
carbr-0.1.0/NEWS.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Novidades
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
- Primeira versão no PyPI: `car_catalog()`, `car_dictionary()`, `car_summary()`,
|
|
6
|
+
`car_municipalities()`, `car_properties()`, `car_property()`, `car_at()`,
|
|
7
|
+
`car_tbl()` e `car_cite()`.
|
|
8
|
+
- Dados das 27 UFs (8.578.061 imóveis), posição de 24 e 25/11/2026.
|
|
9
|
+
- `car_summary()` lê um resumo pré-calculado: totais nacionais em segundos.
|
|
10
|
+
- Guias novos: "Inconsistências do cadastro" e "Onde a análise está parada".
|
carbr-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: carbr
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Imóveis do Cadastro Ambiental Rural (CAR) no Python, sem baixar a base inteira
|
|
5
|
+
Project-URL: Homepage, https://strategicprojects.github.io/carbr-py/
|
|
6
|
+
Project-URL: Documentation, https://strategicprojects.github.io/carbr-py/
|
|
7
|
+
Project-URL: Repository, https://github.com/StrategicProjects/carbr-py
|
|
8
|
+
Project-URL: Issues, https://github.com/StrategicProjects/carbr-py/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/StrategicProjects/carbr-py/blob/main/NEWS.md
|
|
10
|
+
Author-email: André Leite <leite@castlab.org>, Marcos Wasiliew <marcos.wasiliew@gmail.com>, Hugo Vasconcelos <hugo.vasconcelos@ufpe.br>, Carlos Amorim <carlos.agaf@ufpe.br>, Diogo Bezerra <diogo.bezerra@ufpe.br>, Hortênsia Nunes Braz de Oliveira <hortensia.nunes@condepefidem.pe.gov.br>
|
|
11
|
+
License: MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2026 carbr authors
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Keywords: Brazil,CAR,Sicar,environment,geoparquet,open-data,rural
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Intended Audience :: Science/Research
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Natural Language :: Portuguese (Brazilian)
|
|
38
|
+
Classifier: Operating System :: OS Independent
|
|
39
|
+
Classifier: Programming Language :: Python :: 3
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
41
|
+
Requires-Python: >=3.10
|
|
42
|
+
Requires-Dist: duckdb>=1.1
|
|
43
|
+
Requires-Dist: pandas>=1.3
|
|
44
|
+
Requires-Dist: platformdirs>=3
|
|
45
|
+
Requires-Dist: requests>=2.25
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
48
|
+
Requires-Dist: geopandas>=1.0; extra == 'dev'
|
|
49
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
50
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
51
|
+
Provides-Extra: docs
|
|
52
|
+
Requires-Dist: contextily>=1.5; extra == 'docs'
|
|
53
|
+
Requires-Dist: geopandas>=1.0; extra == 'docs'
|
|
54
|
+
Requires-Dist: matplotlib>=3.5; extra == 'docs'
|
|
55
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
56
|
+
Requires-Dist: mkdocstrings[python]>=0.26; extra == 'docs'
|
|
57
|
+
Provides-Extra: geo
|
|
58
|
+
Requires-Dist: geopandas>=1.0; extra == 'geo'
|
|
59
|
+
Provides-Extra: test
|
|
60
|
+
Requires-Dist: geopandas>=1.0; extra == 'test'
|
|
61
|
+
Requires-Dist: pytest>=7; extra == 'test'
|
|
62
|
+
Description-Content-Type: text/markdown
|
|
63
|
+
|
|
64
|
+
# carbr <img src="https://raw.githubusercontent.com/StrategicProjects/carbr-py/main/docs/assets/logo.svg" align="right" height="139" alt="" />
|
|
65
|
+
|
|
66
|
+
[](https://github.com/StrategicProjects/carbr-py/actions/workflows/ci.yml)
|
|
67
|
+
[](LICENSE)
|
|
68
|
+
|
|
69
|
+
Os imóveis rurais declarados no **Cadastro Ambiental Rural (CAR)** no Python, sem
|
|
70
|
+
baixar a base inteira.
|
|
71
|
+
|
|
72
|
+
O `carbr` lê uma republicação dos dados públicos do Sicar em GeoParquet. Cada
|
|
73
|
+
consulta — por UF, município, situação, porte, retângulo, ponto ou código do
|
|
74
|
+
imóvel — transfere só os trechos do arquivo de que precisa, e não passa pelos
|
|
75
|
+
servidores do Sicar.
|
|
76
|
+
|
|
77
|
+
**Documentação:** <https://strategicprojects.github.io/carbr-py/>
|
|
78
|
+
|
|
79
|
+
## Instalação
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install "carbr[geo]"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Sem o extra `geo`, a geometria vem em WKB e `car_at()` não está disponível.
|
|
86
|
+
|
|
87
|
+
## Uso
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
import carbr
|
|
91
|
+
|
|
92
|
+
carbr.car_catalog() # UFs publicadas, versão e qualidade da carga
|
|
93
|
+
carbr.car_summary(["state", "size_class"]) # totais do país, sem ler os imóveis
|
|
94
|
+
carbr.car_municipalities("PE") # resumo por município
|
|
95
|
+
|
|
96
|
+
# Imóveis grandes de Petrolina, como GeoDataFrame
|
|
97
|
+
carbr.car_properties("PE", municipality="Petrolina", size_class="large")
|
|
98
|
+
|
|
99
|
+
# Cadastros pendentes do estado, sem transferir a geometria
|
|
100
|
+
carbr.car_properties("PE", status="pending", geometry=False)
|
|
101
|
+
|
|
102
|
+
carbr.car_at(lon=-40.5, lat=-9.2) # que imóveis estão declarados neste ponto?
|
|
103
|
+
carbr.car_property("PE-2611101-588BC484570D440484F527F07DF5AFFA")
|
|
104
|
+
|
|
105
|
+
# Qualquer outra consulta, direto no arquivo remoto
|
|
106
|
+
carbr.car_tbl("PE").aggregate("status, size_class, count(*) AS n").df()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Guias
|
|
110
|
+
|
|
111
|
+
- [Primeiros passos](https://strategicprojects.github.io/carbr-py/primeiros-passos/)
|
|
112
|
+
- [Inconsistências do cadastro](https://strategicprojects.github.io/carbr-py/inconsistencias/): sobreposições, imóveis fora do município, área declarada maior que o território.
|
|
113
|
+
- [Onde a análise está parada](https://strategicprojects.github.io/carbr-py/fila-da-analise/): as etapas da análise por UF e quem aguarda resposta à notificação.
|
|
114
|
+
|
|
115
|
+
## Os dados
|
|
116
|
+
|
|
117
|
+
- **Origem:** serviço público do Sicar, do Serviço Florestal Brasileiro. O cadastro é
|
|
118
|
+
autodeclarado: há sobreposições entre imóveis, e a presença no CAR não comprova domínio.
|
|
119
|
+
- **Conteúdo:** o perímetro declarado e dez atributos de cada imóvel. Não há dado pessoal.
|
|
120
|
+
- **Cobertura:** as 27 UFs, cerca de 8,6 milhões de imóveis. `car_catalog()` mostra o que está
|
|
121
|
+
publicado e a data.
|
|
122
|
+
- **Endereço:** o padrão é um bucket público; `carbr.set_base_url()` ou a variável `CAR_URL`
|
|
123
|
+
apontam para um espelho compatível com S3 ou para uma pasta local.
|
|
124
|
+
|
|
125
|
+
As mesmas funções existem em R: [carbr-r](https://github.com/StrategicProjects/carbr-r).
|
|
126
|
+
|
|
127
|
+
## Licença
|
|
128
|
+
|
|
129
|
+
Código sob licença MIT. Os dados são do Sicar; use `car_cite()` para citá-los.
|
carbr-0.1.0/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# carbr <img src="https://raw.githubusercontent.com/StrategicProjects/carbr-py/main/docs/assets/logo.svg" align="right" height="139" alt="" />
|
|
2
|
+
|
|
3
|
+
[](https://github.com/StrategicProjects/carbr-py/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Os imóveis rurais declarados no **Cadastro Ambiental Rural (CAR)** no Python, sem
|
|
7
|
+
baixar a base inteira.
|
|
8
|
+
|
|
9
|
+
O `carbr` lê uma republicação dos dados públicos do Sicar em GeoParquet. Cada
|
|
10
|
+
consulta — por UF, município, situação, porte, retângulo, ponto ou código do
|
|
11
|
+
imóvel — transfere só os trechos do arquivo de que precisa, e não passa pelos
|
|
12
|
+
servidores do Sicar.
|
|
13
|
+
|
|
14
|
+
**Documentação:** <https://strategicprojects.github.io/carbr-py/>
|
|
15
|
+
|
|
16
|
+
## Instalação
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install "carbr[geo]"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Sem o extra `geo`, a geometria vem em WKB e `car_at()` não está disponível.
|
|
23
|
+
|
|
24
|
+
## Uso
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import carbr
|
|
28
|
+
|
|
29
|
+
carbr.car_catalog() # UFs publicadas, versão e qualidade da carga
|
|
30
|
+
carbr.car_summary(["state", "size_class"]) # totais do país, sem ler os imóveis
|
|
31
|
+
carbr.car_municipalities("PE") # resumo por município
|
|
32
|
+
|
|
33
|
+
# Imóveis grandes de Petrolina, como GeoDataFrame
|
|
34
|
+
carbr.car_properties("PE", municipality="Petrolina", size_class="large")
|
|
35
|
+
|
|
36
|
+
# Cadastros pendentes do estado, sem transferir a geometria
|
|
37
|
+
carbr.car_properties("PE", status="pending", geometry=False)
|
|
38
|
+
|
|
39
|
+
carbr.car_at(lon=-40.5, lat=-9.2) # que imóveis estão declarados neste ponto?
|
|
40
|
+
carbr.car_property("PE-2611101-588BC484570D440484F527F07DF5AFFA")
|
|
41
|
+
|
|
42
|
+
# Qualquer outra consulta, direto no arquivo remoto
|
|
43
|
+
carbr.car_tbl("PE").aggregate("status, size_class, count(*) AS n").df()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Guias
|
|
47
|
+
|
|
48
|
+
- [Primeiros passos](https://strategicprojects.github.io/carbr-py/primeiros-passos/)
|
|
49
|
+
- [Inconsistências do cadastro](https://strategicprojects.github.io/carbr-py/inconsistencias/): sobreposições, imóveis fora do município, área declarada maior que o território.
|
|
50
|
+
- [Onde a análise está parada](https://strategicprojects.github.io/carbr-py/fila-da-analise/): as etapas da análise por UF e quem aguarda resposta à notificação.
|
|
51
|
+
|
|
52
|
+
## Os dados
|
|
53
|
+
|
|
54
|
+
- **Origem:** serviço público do Sicar, do Serviço Florestal Brasileiro. O cadastro é
|
|
55
|
+
autodeclarado: há sobreposições entre imóveis, e a presença no CAR não comprova domínio.
|
|
56
|
+
- **Conteúdo:** o perímetro declarado e dez atributos de cada imóvel. Não há dado pessoal.
|
|
57
|
+
- **Cobertura:** as 27 UFs, cerca de 8,6 milhões de imóveis. `car_catalog()` mostra o que está
|
|
58
|
+
publicado e a data.
|
|
59
|
+
- **Endereço:** o padrão é um bucket público; `carbr.set_base_url()` ou a variável `CAR_URL`
|
|
60
|
+
apontam para um espelho compatível com S3 ou para uma pasta local.
|
|
61
|
+
|
|
62
|
+
As mesmas funções existem em R: [carbr-r](https://github.com/StrategicProjects/carbr-r).
|
|
63
|
+
|
|
64
|
+
## Licença
|
|
65
|
+
|
|
66
|
+
Código sob licença MIT. Os dados são do Sicar; use `car_cite()` para citá-los.
|
carbr-0.1.0/docs/api.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Referência das funções
|
|
2
|
+
|
|
3
|
+
## Descobrir
|
|
4
|
+
|
|
5
|
+
::: carbr.car_catalog
|
|
6
|
+
|
|
7
|
+
::: carbr.car_dictionary
|
|
8
|
+
|
|
9
|
+
::: carbr.car_summary
|
|
10
|
+
|
|
11
|
+
::: carbr.car_municipalities
|
|
12
|
+
|
|
13
|
+
## Obter os imóveis
|
|
14
|
+
|
|
15
|
+
::: carbr.car_properties
|
|
16
|
+
|
|
17
|
+
::: carbr.car_property
|
|
18
|
+
|
|
19
|
+
::: carbr.car_at
|
|
20
|
+
|
|
21
|
+
::: carbr.car_tbl
|
|
22
|
+
|
|
23
|
+
## Citar
|
|
24
|
+
|
|
25
|
+
::: carbr.car_cite
|
|
26
|
+
|
|
27
|
+
## Endereço, cache e opções
|
|
28
|
+
|
|
29
|
+
::: carbr.set_base_url
|
|
30
|
+
|
|
31
|
+
::: carbr.car_cache_dir
|
|
32
|
+
|
|
33
|
+
::: carbr.car_cache_clear
|
|
34
|
+
|
|
35
|
+
::: carbr.set_timeout
|
|
36
|
+
|
|
37
|
+
::: carbr.set_verbose
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* Same green as the R package site. */
|
|
2
|
+
:root {
|
|
3
|
+
--md-primary-fg-color: #1f5f3a;
|
|
4
|
+
--md-primary-fg-color--light: #3d8a5c;
|
|
5
|
+
--md-primary-fg-color--dark: #123a23;
|
|
6
|
+
--md-accent-fg-color: #2e8b57;
|
|
7
|
+
}
|
|
8
|
+
[data-md-color-scheme="slate"] {
|
|
9
|
+
--md-primary-fg-color: #1f5f3a;
|
|
10
|
+
--md-accent-fg-color: #8fbf9f;
|
|
11
|
+
}
|
|
12
|
+
.md-typeset table:not([class]) { font-size: .72rem; }
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 278" width="240" height="278" role="img" aria-label="carbr">
|
|
2
|
+
<title>carbr</title>
|
|
3
|
+
<defs>
|
|
4
|
+
<clipPath id="hex"><polygon points="120,6 234,72 234,206 120,272 6,206 6,72"/></clipPath>
|
|
5
|
+
</defs>
|
|
6
|
+
<polygon points="120,6 234,72 234,206 120,272 6,206 6,72" fill="#1f5f3a"/>
|
|
7
|
+
<g clip-path="url(#hex)" stroke="#f4f8f1" stroke-width="3" stroke-linejoin="round">
|
|
8
|
+
<polygon points="36,78 94,54 110,102 48,118" fill="#3d8a5c"/>
|
|
9
|
+
<polygon points="94,54 160,46 166,96 110,102" fill="#2e7449"/>
|
|
10
|
+
<polygon points="160,46 208,80 202,122 166,96" fill="#57a374"/>
|
|
11
|
+
<polygon points="48,118 110,102 122,152 42,162" fill="#2e7449"/>
|
|
12
|
+
<polygon points="110,102 166,96 202,122 188,162 122,152" fill="#d9ecb4"/>
|
|
13
|
+
</g>
|
|
14
|
+
<circle cx="156" cy="128" r="9" fill="#1f5f3a"/>
|
|
15
|
+
<circle cx="156" cy="128" r="3.5" fill="#f4f8f1"/>
|
|
16
|
+
<text x="120" y="226" text-anchor="middle" font-family="'Helvetica Neue', Helvetica, Arial, sans-serif" font-size="46" font-weight="700" letter-spacing="1" fill="#f4f8f1">carbr</text>
|
|
17
|
+
<polygon points="120,6 234,72 234,206 120,272 6,206 6,72" fill="none" stroke="#123a23" stroke-width="8" stroke-linejoin="round"/>
|
|
18
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Onde a análise está parada
|
|
2
|
+
|
|
3
|
+
Cadastrar foi a parte rápida: o país tem mais de 8,5 milhões de imóveis no CAR. A
|
|
4
|
+
regularização depende do passo seguinte — o órgão estadual analisar o cadastro e o
|
|
5
|
+
produtor responder ao que a análise pede. Este guia usa a coluna `condition`, a etapa
|
|
6
|
+
da análise informada pelo Sicar, para mostrar onde cada UF está e quem espera por quem.
|
|
7
|
+
|
|
8
|
+
Tudo aqui sai do resumo pré-calculado (`car_summary()`), em segundos, menos o mapa do
|
|
9
|
+
fim, que lê duas colunas de um estado.
|
|
10
|
+
|
|
11
|
+
## As etapas
|
|
12
|
+
|
|
13
|
+
O Sicar informa quinze situações de análise. Agrupadas em seis etapas:
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import carbr
|
|
17
|
+
|
|
18
|
+
STAGES = ["Aguardando análise", "Em análise", "Notificado, sem resposta",
|
|
19
|
+
"Respondeu, aguarda reanálise", "Analisado", "Cancelado"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def stage(condition):
|
|
23
|
+
if condition.startswith("Cancelado"):
|
|
24
|
+
return "Cancelado"
|
|
25
|
+
if condition == "Aguardando análise":
|
|
26
|
+
return "Aguardando análise"
|
|
27
|
+
if condition == "Em análise":
|
|
28
|
+
return "Em análise"
|
|
29
|
+
if "aguardando atendimento a notificação" in condition:
|
|
30
|
+
return "Notificado, sem resposta"
|
|
31
|
+
if "após revisão" in condition:
|
|
32
|
+
return "Respondeu, aguarda reanálise"
|
|
33
|
+
return "Analisado"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def by_stage(*by):
|
|
37
|
+
df = carbr.car_summary(["condition", *by])
|
|
38
|
+
df["stage"] = pd.Categorical(df["condition"].map(stage), STAGES)
|
|
39
|
+
return df.groupby([*by, "stage"], observed=False)["properties"].sum().reset_index()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
national = by_stage()
|
|
43
|
+
national["share"] = (100 * national["properties"] / national["properties"].sum()).round(1)
|
|
44
|
+
|
|
45
|
+
national
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
stage properties share
|
|
50
|
+
0 Aguardando análise 5978543 69.7
|
|
51
|
+
1 Em análise 109335 1.3
|
|
52
|
+
2 Notificado, sem resposta 1309315 15.3
|
|
53
|
+
3 Respondeu, aguarda reanálise 134338 1.6
|
|
54
|
+
4 Analisado 874463 10.2
|
|
55
|
+
5 Cancelado 172067 2.0
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Sete em cada dez cadastros ainda não foram analisados. Dos que foram, a maior parte
|
|
59
|
+
parou no passo seguinte: há mais imóveis notificados à espera de resposta do
|
|
60
|
+
declarante do que imóveis com análise concluída.
|
|
61
|
+
|
|
62
|
+
## A fila não é a mesma em cada UF
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
palette = {"Aguardando análise": "#d9d9d9", "Em análise": "#9ecae1",
|
|
66
|
+
"Notificado, sem resposta": "#e8590c", "Respondeu, aguarda reanálise": "#fcc419",
|
|
67
|
+
"Analisado": "#2b8a3e", "Cancelado": "#868e96"}
|
|
68
|
+
states = by_stage("state").pivot(index="state", columns="stage", values="properties")
|
|
69
|
+
shares = states.div(states.sum(axis=1), axis=0).sort_values("Aguardando análise")
|
|
70
|
+
|
|
71
|
+
ax = (100 * shares).plot.barh(stacked=True, figsize=(7, 6.8), width=0.8,
|
|
72
|
+
color=[palette[s] for s in shares.columns])
|
|
73
|
+
ax.set_title("Em que etapa da análise estão os imóveis de cada UF (%)", loc="left")
|
|
74
|
+
ax.set_xlim(0, 100)
|
|
75
|
+
ax.set_ylabel("")
|
|
76
|
+
ax.legend(ncol=2, frameon=False, loc="upper center", bbox_to_anchor=(0.5, -0.05), fontsize=8)
|
|
77
|
+
|
|
78
|
+
fig("etapas")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
Há três situações bem diferentes. Em parte dos estados quase nada foi analisado
|
|
84
|
+
(cinza). Em alguns a análise andou e concluiu (verde). E em outros a análise andou,
|
|
85
|
+
mas parou na notificação (laranja): o órgão fez a sua parte e a resposta não veio.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
notified = states["Notificado, sem resposta"].sort_values(ascending=False).to_frame("properties")
|
|
89
|
+
notified["share_of_state"] = (100 * shares["Notificado, sem resposta"]).round(1)
|
|
90
|
+
top5 = 100 * notified["properties"].head(5).sum() / notified["properties"].sum()
|
|
91
|
+
print(f"As cinco primeiras UFs concentram {top5:.0f}% das notificações sem resposta")
|
|
92
|
+
|
|
93
|
+
notified.head(8)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
As cinco primeiras UFs concentram 71% das notificações sem resposta
|
|
98
|
+
properties share_of_state
|
|
99
|
+
state
|
|
100
|
+
PA 265238 67.5
|
|
101
|
+
CE 203419 49.5
|
|
102
|
+
MG 161094 13.6
|
|
103
|
+
PI 153090 45.3
|
|
104
|
+
SP 144251 30.4
|
|
105
|
+
AL 97264 67.6
|
|
106
|
+
RO 53743 27.1
|
|
107
|
+
MS 37014 40.9
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Quem está sem responder
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
waiting = by_stage("size_class")
|
|
114
|
+
waiting = waiting[waiting["stage"] == "Notificado, sem resposta"].drop(columns="stage")
|
|
115
|
+
waiting["share"] = (100 * waiting["properties"] / waiting["properties"].sum()).round(1)
|
|
116
|
+
|
|
117
|
+
waiting
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
size_class properties share
|
|
122
|
+
2 large 27771 2.1
|
|
123
|
+
8 medium 86308 6.6
|
|
124
|
+
14 small 1195236 91.3
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Nove em cada dez são imóveis de até quatro módulos fiscais. É o público que menos tem
|
|
128
|
+
acesso a técnico, a ferramenta de geoprocessamento e a quem explique o relatório da
|
|
129
|
+
análise — e para quem a pendência no CAR pesa no crédito rural.
|
|
130
|
+
|
|
131
|
+
## A notificação envelhece
|
|
132
|
+
|
|
133
|
+
Pelo ano de criação do cadastro, a resposta não chega com o tempo: de cada ano desde
|
|
134
|
+
2015, entre um oitavo e um quinto dos cadastros está parado na notificação, e os mais
|
|
135
|
+
antigos não estão em situação melhor.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
years = by_stage("created_year").pivot(index="created_year", columns="stage", values="properties")
|
|
139
|
+
|
|
140
|
+
ax = (years / 1e3).plot.bar(stacked=True, figsize=(7, 4), width=0.85, rot=0,
|
|
141
|
+
color=[palette[s] for s in years.columns])
|
|
142
|
+
ax.set_title("Etapa atual da análise, por ano de criação do cadastro", loc="left")
|
|
143
|
+
ax.set_xlabel("")
|
|
144
|
+
ax.set_ylabel("Milhares de imóveis")
|
|
145
|
+
ax.legend(ncol=2, frameon=False, fontsize=8)
|
|
146
|
+
|
|
147
|
+
fig("analise-anos")
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+

|
|
151
|
+
|
|
152
|
+
## Onde, dentro de um estado
|
|
153
|
+
|
|
154
|
+
O resumo vai até a UF. Para descer ao município, `car_tbl()` lê só as duas colunas
|
|
155
|
+
necessárias do arquivo do estado. No Pará, a UF com mais notificações sem resposta:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
para = carbr.car_tbl("PA").aggregate(
|
|
159
|
+
"municipality_code, municipality, condition, count(*) AS n"
|
|
160
|
+
).df()
|
|
161
|
+
para["notified"] = para["n"].where(para["condition"].map(stage) == "Notificado, sem resposta", 0)
|
|
162
|
+
para = para.groupby(["municipality_code", "municipality"], as_index=False)[["n", "notified"]].sum()
|
|
163
|
+
para = para.rename(columns={"n": "properties"})
|
|
164
|
+
para["share"] = (100 * para["notified"] / para["properties"]).round(1)
|
|
165
|
+
|
|
166
|
+
para.sort_values("notified", ascending=False).head(6)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
municipality_code municipality properties notified share
|
|
171
|
+
80 1505064 Novo Repartimento 12492 8782 70.3
|
|
172
|
+
65 1504208 Marabá 12935 8043 62.2
|
|
173
|
+
2 1500206 Acará 9267 7836 84.6
|
|
174
|
+
72 1504703 Moju 12009 7305 60.8
|
|
175
|
+
86 1505486 Pacajá 11170 7169 64.2
|
|
176
|
+
119 1507300 São Félix do Xingu 13174 6971 52.9
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
import geopandas as gpd
|
|
181
|
+
|
|
182
|
+
mesh = gpd.read_file(
|
|
183
|
+
"https://servicodados.ibge.gov.br/api/v3/malhas/estados/PA?intrarregiao=municipio"
|
|
184
|
+
"&formato=application/vnd.geo%2Bjson&qualidade=intermediaria"
|
|
185
|
+
)
|
|
186
|
+
mesh["municipality_code"] = mesh["codarea"].astype(int)
|
|
187
|
+
mesh = mesh.merge(para, on="municipality_code", how="left")
|
|
188
|
+
|
|
189
|
+
ax = mesh.plot(column="share", cmap="Oranges", edgecolor="white", linewidth=0.2,
|
|
190
|
+
figsize=(7, 6.4), legend=True,
|
|
191
|
+
legend_kwds={"shrink": 0.5, "label": "Notificados, sem resposta (%)"},
|
|
192
|
+
missing_kwds={"color": "#d9d9d9"})
|
|
193
|
+
ax.set_title("Pará: imóveis notificados que aguardam resposta do declarante\n"
|
|
194
|
+
"Parcela dos imóveis de cada município", loc="left", fontsize=10)
|
|
195
|
+
ax.set_axis_off()
|
|
196
|
+
|
|
197
|
+
fig("para")
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+

|
|
201
|
+
|
|
202
|
+
É uma lista de onde um mutirão, um sindicato ou um serviço de atendimento ao produtor
|
|
203
|
+
rende mais: municípios com muitos imóveis já analisados à espera de uma resposta que
|
|
204
|
+
depende só de o declarante entender o que foi pedido.
|