Provincia de Tucumán
departamentos vecinos
SELECT
st_x(st_transform(st_centroid(a.geom),4326)) as X,
st_y(st_transform(st_centroid(a.geom),4326)) as Y,
a.nomdep as fuente,
b.nomdep as destino
FROM
(SELECT * FROM paisxdpto2010 WHERE nomprov = 'TUCUMAN' ) as a,
(SELECT * FROM paisxdpto2010 WHERE nomprov = 'TUCUMAN' ) as b
WHERE st_relate(a.geom, b.geom) = 'FF2F11212';
# es equivalente a este otro query
SELECT
st_x(st_transform(st_centroid(a.geom),4326)) as X,
st_y(st_transform(st_centroid(a.geom),4326)) as Y,
a.nomdep as fuente,
b.nomdep as destino
FROM
(SELECT * FROM paisxdpto2010 WHERE nomprov = 'TUCUMAN' ) as a,
(SELECT * FROM paisxdpto2010 WHERE nomprov = 'TUCUMAN' ) as b
WHERE st_intersects(a.geom, b.geom) and not st_equals(a.geom, b.geom);