OSM get all roads for a given US county as a shapefile - openstreetmap

I am working on a project where I need to get a shapefile of all roads in a given US county from open streetmap data, add some information to the county roads, then merge the individual county road shape files into a larger single shapefile using qgis.
My current process is to download the state roads map from the OSM repsitory that has my desired counties, and clip the larger state map to my desired county set of roads using qgis. I use the census bureau's county boundary shapefile to determine the boundary of the clip. The problem is that qgis seems to delete small sections of roads at the county boundary and I am unable to merge the "fabric" of the map together because there are gaps in road lines at the county boundary.
As an alternative approach, I have stared to research using the OSM overpass api to query for a set of county roads. If I can query OSM for all roads within a given county and download as a shapefile, should I then be able to merge the individual county road maps into a larger map without gaps and avoid the problem I have with clipping?
Are there any articles that describe the overpass api query for getting roads within a known administrative boundary, like a US county?

Related

How to compute bounding boxes of specific roads from Overpass api

I have a high volume dataset with keys like this:
lat:6.897585,
long:52.785805,
speed:12,
bearing:144
Basically it is a dataset of records of various trips on cars. The data was stored every few seconds during each trip. The main goal of this project is to be able to visualize only u-turns (turn arounds) on a map. But for now, I am trying to at least show the data on specifc roads. For that, I am using Overpass API
With the help of Overpass Turbo, I can get a dataset with all the roads I need.
However, in the dataset, the road's geometry is represented with LineString type.
My question is, How can I get a bounding box(es) of the roads from Overpass API, so later on, I can display events that happened only on the given roads? Or maybe you have a better solution on how to achieve this?
A bounding box wouldn't be very helpful here, as using it to filter your points would show everything that falls within the box (which could include other nearby roads)
It sounds like getting a buffer around a linestring might get you closer, but could still include points that are within the buffer but not on the road you are inspecting.
The smarter way to do this would be to assign each event to a road segment using some logic based on their attributes/properties, so you don't have to depend on a spatial filter.

Tableau - Given longitude and latitude how can I count how many points fall under a certain zip code for New York?

I'm trying to count how many subway stations each zip code in NYC has. I have the longitudes and latitudes of each station but am wondering how I can relate this to zip codes? Thank you for your help!
Subway Stations on default map
You'll need some spatial data source that contains the boundaries of each zip code, such as a ESRI shapefile, GeoJSON file, KML etc. Tableau's built-in geocoding can display zip code boundaries visually, but they are not accessible for computation (unless you find a way to hack the geocoding files that ship with Tableau)
It should not be hard to find a shapefile of zip code boundaries for NYC.
Once you have that use a spatial join with the INTERSECTS operator to combine the zip code boundary data with your subway station data. If your station data is not in a spatial format, you'll need to use the MAKEPOINT() function in Tableau to convert the latitude and longitude coordinates into a spatial geometry datatype that can be used to specify your join condition.
This sounds like more work that it really is. In the end, the INTERSECTS operator will do all the work to assign each station to the correct zip code.

Mapbox: Making a line given two OSM Node IDs

I have two Open Street Map node IDs. Is there any API provided by Mapbox or Leaflet which could draw a PolyLine or LineString given the two node IDs?
I am not able to find any reference to OSM IDs anywhere in Mapbox documentation, apart from here and it does not detail how to use the OSM IDs for ourselves to draw lines on the map.
What I want to do is given 2 OSM IDs, I want to highlight the road segment connecting those OSM IDs. I can't go for things like Leaflet routing machine since the number of such lines are too many, with small distances. I can't run routing for all the edges.
Since you say "I can't go for things like Leaflet routing machine since the number of such lines are too many, with small distances. I can't run routing for all the edges." I'm excluding all solutions calling an external routing API, instead you can do your own internal routing.
Use the OSM Overpass API to get the long,lat points for those nodes
In Mapbox GL JS fitBounds to those two nodes and do map.querySourceFeatures to get the roads as GeoJSON LineStrings
then compute a network graph from this and use Dijkstra's algorithm to get the shortest path between your two OSM nodes.

ArcMap shapefiles won't overlap

When I upload two shapefiles to ArcMap they are not overlapping. I have to click "Zoom to Layer" to see each one. I know I have to change the coordinate systems but I am unsure how... If anyone would like to see the data I am using, I am using an Oklahoma Counties Shapefile and the Tornado Shapefile provided by NOAA. The links to each are provided below:
Oklahoma Counties Link I downloaded the statewide shapefile
Tornado Link: I downloaded the torn.zip for tornadoes from 1950-2016
How do I get these two shapefiles to overlap? I have spent hours trying to figure this and have been reading/searching other posts but but I am not getting anywhere. Any help that can be provided would be great!
There is no projection defined on the county shapefile .Use the Define projection tool to project it to the projection defined in the textfile.Its(Geographic Coordinate system,NAD1983_2011) .
Also to better help overlay them add the USA counties data from ArcGIS Online and then proceed to add the county and tornado shapefiles and it seemed to work just fine
I have attached a picture below with a definition query on the tornado file to Oklahoma city.
image1

Highmaps US County map is missing New York and DC (among others)

Seems like the US County map for Highmaps is missing New York and DC (among others)
http://www.highcharts.com/maps/demo/us-counties
Is there a complete and correct geojson US-county map available?
There is a Free API to obtain US County in GeoJson format:
Example query:
https://vanitysoft-boundaries-io-v1.p.mashape.com/reaperfire/rest/v1/public/boundary?and=true&county=Washington+County&state=MD
please note that some zipcodes do not fall within a county.
The good news is that the GeoJSON does include New York and DC (and I'm fairly certain all counties in the US). What you are experiencing are two separate issues.
For DC, it is already drawn on the map, but the problem is simply that it has no data to display from the source. Therefor it appears as though it is just a hole in the map. The path for DC is drawn and very much visible (just not lively colored). Change the fill color to black and you'll see it.
For New York county it is also drawn on the map, but unfortunately it is only 1 pixel wide and doesn't show up at all visually even when zoomed. This could be fixed by altering the geometry of the GeoJSON data for that county specifically. To see that it is there you could give it an id in the data and use Point.zoomTo to see where it would've been (if visible).
I'm not certain what defines "correct", but you're not going to get a GeoJSON on a centimeter-scale of correctness, so it comes down to how many points you want to use for the geometry of each element.
If you look at the drilldown map it is even more coarse when displaying the overall map, but when zooming in it shows New York county perfectly. Perhaps you could somehow combine or utilize the different levels of granularity of the different GeoJSON files.