ええと、私はあなたのデータをダウンロードしていませんが、ほとんどすべてのラテンアメリカのopenstreetmapsデータがデータベースにロードされています。
これは都市の最も近い州の例です:
select distinct on (a.name)
a.name as city,
b.name as state,
min(St_Distance(b.way, a.way)) as d
from planet_osm_point as a,
(SELECT name, way, place from planet_osm_point WHERE place='state') as b
where a.place='city' group by 1,2 order by 1 asc;
しかし、これは正確ではありません。ポリゴン テーブルを使用してより適切に推測できると考えられます。
select a.name as city,b.name as state,b.place
from planet_osm_point as a, planet_osm_polygon as b
where St_Contains(b.way, a.way)
and a.place='city'; -- and b.place='state' -- my polys table aren't tagged properly so I ignored polys.place
それがうまくいくことを願っています:)。