48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
"""Diagnóstico: leer BARRANQUILLA.000 con pyogrio/GDAL."""
|
|
import traceback
|
|
from pathlib import Path
|
|
|
|
enc = Path(r"C:\AidsMonitoring\charts\BARRANQUILLA\BARRANQUILLA.000")
|
|
print(f"File: {enc}")
|
|
print(f"Size: {enc.stat().st_size:,} bytes")
|
|
print()
|
|
|
|
# 1. List layers via fiona or pyogrio
|
|
try:
|
|
import pyogrio
|
|
layers = pyogrio.list_layers(str(enc))
|
|
print(f"pyogrio layers ({len(layers)}):")
|
|
for L in layers:
|
|
print(f" {L}")
|
|
except Exception as e:
|
|
print(f"pyogrio.list_layers ERROR: {e}")
|
|
|
|
print()
|
|
|
|
# 2. Try reading LIGHTS layer
|
|
try:
|
|
import geopandas as gpd
|
|
gdf = gpd.read_file(str(enc), layer="LIGHTS", engine="pyogrio")
|
|
print(f"LIGHTS: {len(gdf)} rows")
|
|
except Exception as e:
|
|
print(f"LIGHTS read ERROR:")
|
|
traceback.print_exc()
|
|
|
|
print()
|
|
|
|
# 3. Try GDAL direct
|
|
try:
|
|
from osgeo import gdal, ogr
|
|
gdal.UseExceptions()
|
|
ds = ogr.Open(str(enc))
|
|
if ds:
|
|
print(f"OGR layers ({ds.GetLayerCount()}):")
|
|
for i in range(ds.GetLayerCount()):
|
|
lyr = ds.GetLayerByIndex(i)
|
|
print(f" {lyr.GetName():20s} {lyr.GetFeatureCount()} features")
|
|
else:
|
|
print("OGR: could not open file")
|
|
except Exception as e:
|
|
print(f"OGR ERROR:")
|
|
traceback.print_exc()
|