1

I'm trying to make a street map of New York City (and only New York City). I've downloaded OSM data for the area (from here), but it contains lots of data from the suburbs.

Currently, I've loaded this data into PostGIS (with osm2pgsql), but there's nothing obvious which would let me distinguish roads in the city from those in the suburbs. What's the best way to get streets only within the city?

  • 1
    Do you have a boundary (in OSM) that represents whatever you consider to be the jurisdiction? – BradHards Apr 20 '14 at 2:36
  • I do have these, but again, I'm not sure how to isolate the boundaries that I want, as they don't seem to have any identifying data apart from being tagged as administrative boundaries. – futuraprime Apr 20 '14 at 11:40
  • 1
    I take that back—I found the NYC boundaries as polygons in another table. – futuraprime Apr 20 '14 at 11:49
  • OK, are you familiar with PostGIS operations? If not, can you do basic SQL queries? – BradHards Apr 21 '14 at 0:21
  • I'm reasonably good with SQL, pretty iffy on PostGIS. – futuraprime Apr 21 '14 at 1:40
1

I think that ST_intersection is one of the possible answers, and here you can find a good point to start if you have the NYC boundaries.

0

Besides Micky's way, you could modify your osm2pgsql database to only contain OSM data that is only within that boundary.

To do this, you need to identify the boundary (in OSM) that you wish to be the outlying filter. Then, use Osmosis to take your input OSM data and output only the data that is within a polygon (that is generated by the boundary).

I wrote a tutorial on this couple years ago and just updated it over the weekend covering this in more detail and should guide you without any problems.

Once you filter your data through Osmosis, you can run osm2pgsql again (i don't recall the specific argument off hand, check the man page or the osm2pgsql github page ) and it will overwrite your previous database so your database will only consist of the data you just loaded in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.