Agência Nacional de Energia Elétrica (ANEEL)¶
O site da ANEEL apresenta uma sessão de Informações Geográficas. Analisando o material, costata-se que eles utilizam a estrutura do ArcGIS Server, em um portal denominado Sistema de Informações Georreferenciadas do Setor Elétrico (SIGEL).
Siglas¶
A instituição tem várias siglas que estão apresentadas nos dados do ArcGIS.
Superintendências
- SRM: Superintendência de Regulação Econômica e Estudos de Mercado
- SMA: Superintendência de Mediação Administrativa, Ouvidoria Setorial e Participação Pública
- SFE: Superintendência de Fiscalização dos Serviços de Eletricidade
- SFG: Superintendência de Fiscalização dos Serviços de Geração
Outras
- SIPH: Sistema de Informações do Potencial Hidroelétrico
- GGT: Gestão Geoespacializada da Transmissão
- SGO: Sistema de Gestão de Ouvidoria
- IASC: Índice ANEEL de Satisfação do Consumidor
- UFV: Centrais Geradoras Fotovoltaicas
- EOL: Usinas Eólicas
- UTN: Usina Eletronuclear
- UTE: Usinas Termelétricas
- PCH: Pequenas Centrais Hidrelétricas
- AHE: Aproveitamentos Hidrelétricos
- UHE: Usinas Hidrelétricas
- SKATE
Download de Dados¶
Por meio do acesso ao site de download dos dados, é possível observar a interface e layers disponíveis. Observou-se que são os mesmos layers disponíveis na pasta "Portal" do webservice.

Para os pacotes que usam python, é necessário
#!pip3 install arcgis
Definir a variável de ambiente RESTAPI_USE_ARCPY como FALSE é necessário para evitar que a biblioteca restapi mande mensagens de erro ou tente usar o ArcPy, que só está disponível para quem tem licença da ESRI.
import os
os.environ['RESTAPI_USE_ARCPY'] = 'FALSE'
import tempfile
import warnings
from pathlib import Path
import geopandas as gpd
import requests
import restapi
import json
import pprint
from restapi import NAME, SERVICES, TYPE, ArcServer
import open_geodata as geo
#from arcgis.raster.functions import *
Suprimimos os warnings
warnings.filterwarnings('ignore')
session = requests.Session()
client = restapi.RequestClient(session)
restapi.set_request_client(client)
# Connect to restapi.ArcServer instance
url = 'https://sigel.aneel.gov.br/arcgis/rest/services'
ags = restapi.ArcServer(url=url)
ags
Com o uso do rest
for x in ags.list_services():
print(x, type(x))
Pasta temporária onde os arquivos serão depositados.
# Crio pasta temporária
temp_path = Path(tempfile.gettempdir()) / 'open_geodata' / 'aneel'
temp_path.mkdir(exist_ok=True, parents=True)
temp_path
list_services = ags.mapServices
list_services
list_services = ags.mapServices
for service_url in list_services:
#
path_gis = Path(service_url).relative_to(url)
path_gis = path_gis.parts[0:-1]
path_gis = Path('/'.join(path_gis))
print(path_gis)
# Create Directory
path_gis = temp_path / path_gis
path_gis.mkdir(exist_ok=True)
# List Layers
service = ags.getService(service_url)
list_lyrs = service.list_layers()
# Para
for lyr in list_lyrs:
# Selec Layer
lyr = service.layer(lyr)
# Get Name
lyr_name = lyr.name
lyr_name = lyr_name.lower()
lyr_name = lyr_name.replace(' ', '_')
print(f'>> {lyr_name}')
# Adjust Filepath
shp_filepath = path_gis / f'{lyr_name}.shp'
try:
# Query
lyr_filter = lyr.query(exceed_limit=True)
# Export Results
restapi.exportFeatureSet(lyr_filter, str(shp_filepath))
except Exception as e:
print(e)
print(f'\n{100 * "-"}')
# Fim
print(f'Fim!')
for root, services in ags.walk(ignore_folder_auth=True):
print(f'Pasta: {root}')
# print('\n'.join(f'- {item}' for item in services))
for service in services:
print(f'- {service}')
print(f'-' * 60)
Obtem detalhes do serviço
# Listas de Tipos de Serviço
ags.featureServices
service = ags.getService(name_or_wildcard='SP')
service.name
type(service)
# Shapefile
print(service.name)
print(service.description)
# URL
print(service.url)
# Representação
print(repr(service))
# Formatos
print(service.supportedQueryFormats)
# Path
print(service.servicePath)
# documentInfo
print(service.documentInfo)
# Descrição
print(service.description)
# Informações do datum
print(service.initialExtent)
print(service.spatialReference)
lyr = service.get_layer_url(name='ZEE')
type(lyr)
# Seleciona Layer no Serviço
lyr = service.layer(name_or_id=19)
type(lyr)
lyr_query = lyr.query(
where='1=1',
# Se exceed_limit=True, retorna todos os registros
# Se exceed_limit=False, retorna apenas os primeiros 1000 registros
exceed_limit=True,
# ------------------------------------
# Número de registros a serem retornados
# Se records=None, retorna todos os registros
# records=10,
# ------------------------------------
# Option to return a generator with a FeatureSet in chunks of each query group.
# Use this to avoid memory errors when fetching many features. Defaults to False
fetch_in_chunks=True,
)
lyr_query.geometryType
# shp_file
#temp_dir = tempfile.TemporaryDirectory()
# # Cria o caminho temporário em formato Path
# temp_path = Path(temp_dir.name)
# temp_path
# Crio pasta temporária
temp_path = Path(tempfile.gettempdir()) / 'open_geodata' / 'aneel'
temp_path.mkdir(exist_ok=True, parents=True)
temp_path
lyr_query
# ddd
restapi.exportFeatureSet(
feature_set=lyr_query,
#
out_fc=str(temp_path / 'temp.shp'),
)
# Read Data
gdf = gpd.read_file(filename=temp_path / 'temp.shp')
# Results
gdf.info()
gdf.head()
from arcgis import geometry
from arcgis.geocoding import geocode
from arcgis.gis import GIS
#url = "https://mapas.agenciapcj.org.br/arcgis/rest/services"
url = service.url
# Connect to the portal
gis = GIS(url)
# Search for all feature services and feature collections in the portal
items = gis.content.search(query='type: "Feature Service" OR type: "Feature Collection"', max_items=5000)
items