Where can i find the USA State and City polygons?

Hi folks,

i’m not sure if this is the correct place to ask (or if i should be asking on the talk-us mailing list instead) but i’m trying to find some lat/long polygons that define the states of the USA and all the cities/towns, etc in the USA.

I know the the Cenus Bureau release the TIGER lines, etc. … and a lot of that data is available @ OSM … but i’m not sure how i can access this data :frowning:

Can anyone either help me or direct me to some people/places for help?

This data is to be used to data mine some demographic data we have (eg. crime stats, marriages/deaths/births, etc).

thanks folks for any help!

If you want to get only the state boundaries then I guess the OSM XAPI seems the way to go. The Tiger page in the wiki can probably help you determine what parameters you need to feed to the XAPI.

Hi Lambertus and thanks for the answer.

Firstly, is this the correct forum to ask this question or should i be on one of hte mailing lists instead, asking the question
Secondly, i’ve looked at both those pages and i’m completely confused :frowning: I can’t see anything that hints at parameters which i should be using, to find the boundaries for states and cities. I understand API’s and use them a lot … but i’m just can’t seem to pick out the relevant information on both pages :frowning:

To try and show you that i’ve had a look and had a go at trying to understand things, I’m guessing i’m going to want to get a type of relation from Xapi but i need to provide the correct predicates, which is what i’m struggling to locate?

Thanks again for any help :slight_smile:

You may ofcourse use any available mediums to communicate with other users. Using the medium that you like the most is usually the best choice :slight_smile: Having said that, the mailing lists are round much longer then the forum and many OSM oldtimers (who know a lot) prefer the mailinglists, so it is possible that the ml can help you better and faster then the forum. But on the other hand, the forum is more userfriendly to many people… so the choice is yours.

Most boundaries are not constructed using relations (yet), so you will probably want to get some specific (boundary) ways:
boundary=administrative
border_type=state
Example: http://www.openstreetmap.org/edit?lat=36.87175&lon=-117.02483&zoom=15

To get the state data using OSMXAPI you have to create a query like this:

http://www.informationfreeway.org/api/0.5/way[border_type=state][bbox=..,..,..,..]

As border_type is a sub-tag of boundary and maybe others, it would be nice to be able to use both parameters in order to download only the administrative borders, but afaik the api can’t do that (e.g. [boundary=administrative][border_type=state]). But border_type alone will probably do the job just fine.

Thanks for the reply Lambertus :slight_smile:

Ok, so i’m trying to understand the XApi interface to see what data exists, etc. based on your suggestions above.

Questions:

  1. I need to use tag predicates so I’m assuming these can be refrenced here ?
  2. Can i use multiple predicates → like [border_type=state][key=value] ?
  3. can i use the tag predicate place to get the shapes that define the provided key? eg. continent or suburb? Or are these predicates just a single point (node) with some text to list on a map … and not a list of points that form the shape?
  4. Do i have to provide a bounding box or can i provide some type of country predicate? What happens if i provide a box for the USA and it includes some area of Canada inside? Can i make sure i don’t include any canadian results?

cheers folks!

Yes, but that list is not complete. You can safely assume it lists the most used and important tags, but there are many more.

Unfortunately, no. If you really need this then I suggest using Osmosis and filter the information from the planet database dump. This is the advanced stuff :slight_smile:

Yes I think so, using the e.g. way[place=state] argument. But I wonder how much information is available like that. Maybe you just need to try…

No and No :slight_smile: For such complex stuff you need post processing or start using Osmosis.

Hi again.

thanks for the continued help :slight_smile: I’ve got a few more q’s, still :blush:

  1. I’m assuming that the data (states, counties, cities and neighbourhoods) exists in the planet data dump. i just need to query it correctly, using something like Osmosis?
  2. If i don’t want to use the java prog Osmosis then i’ll need to download my own data and create my own import code (such as a .NET winform) into sql2008?
  3. If i need to download the my own data for my own import program, then is there a location where i could download the data by country (eg. USA, UK, Canada and Australia as a start)?
  4. If there are country specific data dumps available, then this will include all the data, which i’ll end up importing but probably never use if i’m after certain tag predicates (eg. boundaries only)?

cheers :slight_smile:

You can’t assume that, they are not complete at all. Openstreetmap doesn’t really aim to have everything complete, we only get that when people want that completeness and make it complete on their own. So all help you can offer is greatly appriciated. E.g. Sweden doesn’t have a complete border. You should look around in Potlatch on the borders you want to have to see if it’s complete.

You want to use Osmosis, it is the the Suisse Army knife of OSM. And it takes ~10-20min to set up, including installation of Java.

Look for “extracts” here, Cloudmade and Geofabrik does what you want:
http://wiki.openstreetmap.org/wiki/Planet

… not sure, but yeah I guess if you only want the borders then downloading everything is kind of “stupid”…

How are these extracts constructed? someone is really nice and figures out the complex bounding polygon-box for a particular country and then generates it for the community?

They use Osmosis and a Polygon/bounding box, these are not exact borders of countries. I think you might find the polygons used for export at some of those sites.