https://github.com/1ec5/openstreetmap-urban-areas
Demonstration of OpenStreetMap place classification reform in the United States based on census urban areas
https://github.com/1ec5/openstreetmap-urban-areas
Last synced: 6 months ago
JSON representation
Demonstration of OpenStreetMap place classification reform in the United States based on census urban areas
- Host: GitHub
- URL: https://github.com/1ec5/openstreetmap-urban-areas
- Owner: 1ec5
- License: other
- Created: 2024-05-24T03:24:02.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-28T04:36:55.000Z (11 months ago)
- Last Synced: 2025-09-28T06:18:39.448Z (11 months ago)
- Homepage: https://community.openstreetmap.org/t/toward-a-national-system-for-functionally-classifying-populated-places/113674
- Size: 2.4 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Urban areas in OpenStreetMap
A demonstration of OpenStreetMap place classification reform in the United States based on census urban areas.
## Reproduction
1. Download [_Natural Earth I_ with Shaded Relief, Water, and Drainages](https://www.naturalearthdata.com/downloads/10m-raster-data/10m-natural-earth-1/) (large size), [Admin 0 – Countries](https://www.naturalearthdata.com/downloads/10m-cultural-vectors/10m-admin-0-countries/), and [Admin 1 – States, Provinces](https://www.naturalearthdata.com/downloads/10m-cultural-vectors/10m-admin-1-states-provinces/) from the Natural Earth project.
1. Download a shapefile of [2020 urban areas](https://www2.census.gov/geo/tiger/TIGER2025/UAC20/) from the Census Bureau. Add it to the QGIS project as “tl_2025_us_uac20”.
1. Query Sophox for [urban areas and their namesakes](https://sophox.org/#SELECT%20DISTINCT%0A%20%20%28SAMPLE%28%3FurbanArea%29%20AS%20%3F_urbanArea%29%0A%20%20%28SAMPLE%28%3Fuace%29%20AS%20%3F_uace%29%0A%20%20%28SAMPLE%28%3Fname%29%20AS%20%3F_name%29%0A%20%20%28SAMPLE%28%3Fpopulation%29%20AS%20%3F_population%29%0A%20%20%28SAMPLE%28%3Fqid%29%20AS%20%3F_qid%29%0A%20%20%28SAMPLE%28%3FqidLabel%29%20AS%20%3F_qidLabel%29%0A%20%20%3Fnode%0A%20%20%28SAMPLE%28%3Fboundary%29%20AS%20%3F_boundary%29%0A%20%20%28SAMPLE%28%3Fcoordinates%29%20AS%20%3F_coordinates%29%0AWHERE%20%7B%0A%20%20hint%3AQuery%20hint%3Aoptimizer%20%22None%22%20.%0A%20%20%0A%20%20SERVICE%20%3Chttps%3A%2F%2Fquery.wikidata.org%2Fsparql%3E%20%7B%0A%20%20%20%20SELECT%20DISTINCT%0A%20%20%20%20%20%20%3FurbanArea%20%3Fuace%20%3Fname%20%3Fpopulation%0A%20%20%20%20%20%20%3Fqid%20%3FqidLabel%0A%20%20%20%20WHERE%20%7B%0A%20%20%20%20%20%20%23%20Median%20population%20of%20an%20urban%20area%20as%20of%202020%0A%20%20%20%20%20%20BIND%28101536%20AS%20%3FminMajorPop%29%0A%0A%20%20%20%20%20%20%3FurbanArea%20wdt%3AP31%20wd%3AQ5951278%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP12704%20%3Fuace%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP1448%20%3Fname%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP1082%20%3Fpopulation.%0A%0A%20%20%20%20%20%20%3FurbanArea%20wdt%3AP7153%20%3Fqid.%0A%20%20%20%20%20%20FILTER%20NOT%20EXISTS%20%7B%0A%20%20%20%20%20%20%20%20%3Fqid%20wdt%3AP31%2Fwdt%3AP279%2a%20wd%3AQ1394476.%0A%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22.%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20ORDER%20BY%20%3Fname%0A%20%20%7D%0A%20%20%0A%20%20%7B%0A%20%20%20%20%3Fnode%20osmt%3Awikidata%20%3Fqid.%0A%20%20%7D%20UNION%20%7B%0A%20%20%20%20%3Fboundary%20osmt%3Awikidata%20%3Fqid%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20osmm%3Ahas%20%3Fnode%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Fnode%20%22label%22.%0A%20%20%7D%0A%20%20%3Fnode%20osmm%3Atype%20%22n%22%3B%0A%20%20%20%20%20%20%20%20osmm%3Aloc%20%3Fcoordinates.%0A%7D%0AGROUP%20BY%20%3Fnode%0A). Click the Download button and click “TSV file” to download ua-namesake.tsv.
1. Run `sed -i 's/https:\/\/www\.openstreetmap\.org\/node\///g' ua-namesake.tsv`. Add the TSV file to the QGIS project.
1. Query the Wikidata Query Service for [urban areas classified as major and minor by population](https://query.wikidata.org/#%23defaultView%3AMap%0ASELECT%20DISTINCT%0A%20%20%3FurbanArea%20%3Fuace%20%3Fpopulation%20%3Fname%0A%20%20%3Fplace1%20%3Fplace1Label%20%3Fplace1coords%0A%20%20%3Fplace2%20%3Fplace2Label%20%3Fplace2coords%0A%20%20%3Fplace3%20%3Fplace3Label%20%3Fplace3coords%0A%20%20%28IF%28BOUND%28%3Fplace3%29%2C%203%2C%20IF%28BOUND%28%3Fplace2%29%2C%202%2C%201%29%29%20AS%20%3Fplaces%29%0A%20%20%28%28%3Fpopulation%20%2F%20%3Fplaces%29%20AS%20%3FpopPerPlace%29%0A%20%20%28IF%28%3FpopPerPlace%20%3E%3D%20%3FminMajorPop%2C%20%22major%22%2C%20%22minor%22%29%20AS%20%3Frank%29%0AWHERE%20%7B%0A%20%20%23%20Median%20population%20of%20an%20urban%20area%20as%20of%202020%0A%20%20BIND%28101536%20AS%20%3FminMajorPop%29%0A%20%20%0A%20%20%3FurbanArea%20wdt%3AP31%20wd%3AQ5951278%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP1448%20%3Fname%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP1082%20%3Fpopulation%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP12704%20%3Fuace.%0A%20%20%0A%20%20OPTIONAL%20%7B%0A%20%20%20%20%3FurbanArea%20p%3AP7153%20%5Bps%3AP7153%20%3Fplace1%3B%20pq%3AP3831%20wd%3AQ125800169%5D.%0A%20%20%20%20%3Fplace1%20wdt%3AP625%20%3Fplace1coords.%0A%20%20%20%20FILTER%20NOT%20EXISTS%20%7B%0A%20%20%20%20%20%20%3Fplace1%20wdt%3AP31%2Fwdt%3AP279%2a%20wd%3AQ1394476.%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20OPTIONAL%20%7B%0A%20%20%20%20%3FurbanArea%20p%3AP7153%20%5Bps%3AP7153%20%3Fplace2%3B%20pq%3AP3831%20wd%3AQ125800193%5D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p%3AP138%20%5Bps%3AP138%20%3Fplace2%3B%20pq%3AP1545%20%222%22%5D.%0A%20%20%20%20%3Fplace2%20wdt%3AP625%20%3Fplace2coords.%0A%20%20%20%20FILTER%20NOT%20EXISTS%20%7B%0A%20%20%20%20%20%20%3Fplace2%20wdt%3AP31%2Fwdt%3AP279%2a%20wd%3AQ1394476.%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20OPTIONAL%20%7B%0A%20%20%20%20%3FurbanArea%20p%3AP7153%20%5Bps%3AP7153%20%3Fplace3%3B%20pq%3AP3831%20wd%3AQ125800193%5D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20p%3AP138%20%5Bps%3AP138%20%3Fplace3%3B%20pq%3AP1545%20%223%22%5D.%0A%20%20%20%20%3Fplace3%20wdt%3AP625%20%3Fplace3coords.%0A%20%20%20%20FILTER%20NOT%20EXISTS%20%7B%0A%20%20%20%20%20%20%3Fplace3%20wdt%3AP31%2Fwdt%3AP279%2a%20wd%3AQ1394476.%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22.%20%7D%0A%7D%0AORDER%20BY%20%3Fname). Click the Download button and click “TSV file” to download ua.tsv. Add the TSV file to the QGIS project.
1. In QGIS, use the Join Attributes by Field Value tool in the Processing Toolbox to join “tl_2025_us_uac20” to ua.tsv on the `UACE20` and `uace` fields, respectively. Name the layer “ua”.
1. Query QLever for [place points in the United States](https://qlever.cs.uni-freiburg.de/osm-planet/0DMKQh) (“osm-planet”). Click the Download button and click “Download results as TSV” to export osm-planet_0DMKQh.tsv.
1. Run `sed '1 s/?//g' osm-planet_0DMKQh.tsv | csvjson --quoting 1 --lat 'latitude' --lon 'longitude' --no-bbox > osm-planet.geojson`. Add this GeoJSON file to the project as a point layer called “osm-planet”.
1. Use the Reproject Layer tool to reproject “osm-planet” to ESRI:102039 Contiguous Albers Equal Area Conic USGS. Name the layer “places aeac”.
1. Use the Buffer tool to buffer “places aeac” by 1 kilometer. Name the layer “places buffered”.
1. Use the Join Attributes by Location tool to join “places buffered” to features that _intersect_ in “ua”. Name the layer “places ua”.
1. Use the Join Attributes by Location tool to join “osm-planet” to features that they _are within_ in “places ua”. Name the layer “places ua points”.
1. Use the Join Attributes by Field Value tool to join “places ua points” to ua-namesake.tsv. Name the layer “places ua ranked”.