Wednesday, February 5, 2014

Workflow For Fixing County Borders

Well, my last post got some requests for workflow and I got another snow day off from work today so why not! Follow along as I fix Wyoming's county borders.

Two things you will need to have open: JOSM with the mirrored_download plugin installed and the Wikipedia page for the list of counties in the state. Do a search on wikipedia for "List of counties in <state>" to find it. Here is the one for Wyoming.

Next you need to download all the county relations and their members. I do this using the Overpass API. JOSM has a "Download from Overpass API" option in the File menu (Update: turns out this is a feature of the mirrored_download plugin, not in JOSM core) but we aren't going to use that one just yet because it always adds a bbox parameter to the query which we don't want in this one. Instead, use the "Open Location" option and paste in the following URL after changing the 56 to the appropriate FIPS code for your state which should be listed on the Wikipedia page.
http://overpass-api.de/api/interpreter?data=relation["nist:state_fips"="56"];>>;out meta;

This tells the Overpass API to return all relations with a nist:state_fips=56 tag plus all of the relation members (>>) and finally to add OSM metadata that is needed to edit and upload (out meta). This includes things like version number, last edit timestamp and last user to touch the object. By default it excludes this metadata to reduce download size.

After that finishes you should have a nice outline of the state and all its counties. Make sure the number of downloaded relations matches the number of counties in the state. If not, it probably means the nist:state_fips tag is missing from some counties. If you can mange to find the relation through another means, download it by ID using the "Download object" option in JOSM. Or... I don't know... Ping me on IRC I guess :)

Next, let's load up all the place nodes in the state. For this I use the "Download from Overpass API" option in JOSM. Start off by drawing a box around the desired state on the map. So far I have only done mostly square states. If your state is an odd shape then you can download the bounding box and then select things outside of your state and use the JOSM "Purge" option in the edit menu to remove them from your dataset. Or just ignore them. Then paste this in this text into the query box:
[timeout:300];node["place"];out meta;
Now the screen will look a little busy so I set up a filter to only show me place=county nodes until I need the other stuff. To do this, create a new filter with the filter string
place=county or type:way or type:relation
This will initially hide the county borders and nodes that you want to see so after the filter is created, make sure all three checkboxes in the filter panel are checked. The far right one will invert the filter so instead of hiding whatever matches the filter string it will hide everything except the things that match the filter string. The second checkbox on the left makes them completely disappear instead of just making them inactive but still visible. The first checkbox can be used to quickly disable the filter when you need to see everything.

At this point my JOSM window looks like this:

Note the "Relations: 23" on the relation toolbox matches the expected number of counties in Wyoming.

At this point I usually remove the is_in tag from all the place=county nodes just to get that out of the way. Do a search (CTRL-F) for "type:node place=county" and it should select all of the county nodes. If you have some for a neighboring state loaded that you don't want to touch you can deselect them by holding CTRL while clicking. Then just delete the is_in tag.

Now for the real meat. I just go down the list of counties in Wikipedia. Bring up the first county's Wikipedia page and copy the page title for use in the wikipedia=* tag and note the name of the county seat.

Now in JOSM hit CTRL-F to bring up the search dialog and search for the county seat. If you are lucky it will find exactly one match. Note that because of the filter, you won't actually see the selected object but it is still selected! This could be considered a bug but in this case it works out. If the search found multiple things then you will have to disable the filter and find the right one.

Now:
  • Hold down shift and select the county node in addition to the city node that is already selected
  • Select the county relation in the relation list and click the "Edit" button
  • Add the two selected nodes to the bottom of the relation member list using the 4th button down on the lower right panel of the window
  • Add the role "admin_centre" to the city node
  • Add the role "label" to the county node
  • Add the alt_name tag to the relation in the top panel
  • Add the wikipedia tag. Remember how you copied the page title from Wikipedia? Just type "en:" and then paste the title.
Here is a shot of Albany county (Wyoming, not New York!) when I'm done with it:



And that's pretty much it. Now just repeat the process through the list of counties.

After I'm done I go back and look for any place=hamlet or place=village county seats and bump them up to place=town. I do this by doing CTRL-A in the relation list, then right clicking and doing a "Select members" which selects all the relation members. Then I use the find dialog to find all place=village and make sure to select the "find in selection" radio button so you are only finding things that are already selected. Otherwise you will promote ALL villages in the whole state to towns! As a sanity check, use the selection toolbox to make sure the number of objects selected matches your expectation. It should be fewer than the number of counties in the state.

I will leave you with a quick video of me editing the next county in Wyoming.

11 comments:

  1. Here's the thing: You do not live in Longview, TX like me, and you need to stop editing over people who are actually making true and accurate edits in Longview, TX. You are in KANSAS. You call ME a vandal? I am actually improving our map system by giving true and accurate edits. Yes, ultimately it is with the semi-selfish goal of making sure Niantic updates its servers and spawns accurately. But regardless of my motivations, all of my Longview, TX edits - where I actually live, walk around, and explore FIRST HAND - are 100% true and accurate. I don't appreciate some out-of-towner jumping to conclusions I am vandalizing OpenStreetMaps. You need to get a life and pay more attention to what's going on in Kansas. Longview, TX maps will be better for my edits. I have already mapped parking lots and footpaths that weren't even on the map. Do not harass me on OpenStreetMaps again.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Moreover, there are two Paddle cradles with shock cords. Talking about the durability of this kayak, it is puncture resistant and the material is made up of high-density Polyethylene (HDPE) construction.

    Lifetime 10 Foot Sit on Top Tandem Fishing Kayak

    ReplyDelete
  4. Looking for jobs in Government of Punjab Lahore then here you got Government of the Punjab jobs on Paperpk.com Government of Punjab jobs advertisements 2020 are provided below with date and city. All Punjab Government jobs are updated daily on Latest Punjab Government Jobs 2020 In Newspaper Online

    ReplyDelete
  5. Thanks for such a lovely and great post. I really appreciate it. If you are into cars then do checkout my blog click here

    ReplyDelete
  6. Explore about the CBD world and know what CBD can provide you. CBD can help you in many ways you just need to know what are kratom greensboro nc
    kratom greensboro nc

    ReplyDelete
  7. Pressure Washing Services in Baltimore and Harford Counties


    Pressure Washing Services in Baltimore and Harford Counties
    Painting
    Deck Restoration
    Auto Dealing
    Commercial Service
    Hardscaping Service
    Landscaping
    Mulching

    ReplyDelete
  8. Best Window Tinting service in Elgin Illinois. if you happen to live in Illinois or at nearby area you can have you car or any window tint by the Cutting Edge Window Tinting. If you are writing on google best window tinting near me then you can visit the best tinting service in Illinois.

    Wnidow tinting near me at Elgin Illinois

    https://www.wboc.com/story/43722582/cutting-edge-is-the-best-legal-window-tinting-service-you-can-have-in-elgin-illinois

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. I love London West End Shows! They are always so entertaining and spectacular. I recently saw The Lion King at the Lyceum Theatre and it was amazing. The costumes, the music, the scenery, everything was perfect. I booked my London Tickets online at LSBO and I got a great deal. I highly recommend it to anyone who loves musicals.

    ReplyDelete