Searching for ways by administrative unit?

Hi all-

Forgive me if this question was already asked - I can’t seem to find it via search.

I am trying to find all ways in a certain administrative unit, e.g., U.S. state, Canadian province, etc. It’s not clear to me how to do this with planet_osm_line or planet_osm_roads tables. Any help on how to set up this query would be most appreciated :slight_smile:

Thanks!
-Amanda


CatSynth
http://www.catsynth.com

You can do this with the area query feature in Overpass & Overpass turbo: although entire states or provinces may be a push in terms of both server time & volume of data. Here’s a sample of a query which I use in Overpass-turbo to look for highway=residential which may need changing to unclassified:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“place=* and population~=“[0-9]{7,}” in “United States of America””
/
[out:json][timeout:2500];
// fetch area “United States of America” to search in
{{geocodeArea:Butler County PA}}->.searchArea;
// gather results
(
// query part for: “place=
and population~/[0-9]{7,}/”
way"highway"=“residential”;
);
// print results
out body;

;
out skel qt;

Awesome, thanks for the Overpass query!

I have my own postgres DB with OSM data from North America, so I’d like to run the query against that…
Will look at running the overpass server locally, but wondering if there is a lighter-weight method to run these queries locally?

Thanks!
-Amanda


CatSynth
http://www.catsynth.com

BTW: Checking population numbers via regexp is pretty much outdated these days. Better use (if: … ) instead.