Skip to content

wplam107/nyc_intersection_geocoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NYC Intersection Geocoder

Package to help finding latitude and longitude for NYC street intersections utilizing OSMPythonTools wrapper for OpenStreetMaps.

Dependencies:

Installation:

pip install nyc_intersection_geocoder

Usage:

from nyc_intersection_geocoder.geocoder import IntersectionGC

encoder = IntersectionGC()
result = encoder.get_intersection(
    'Wythe Ave', 'N 4th Street', 'Brooklyn'
)
print(type(result)) # shapely.geometry.point.Point
print(result.coords.xy) # (array('d', [-73.962206]), array('d', [40.717871]))

Note: Geographic data for plot is ordered in (longitude, latitude) for to match (x, y) coordinates.

Motivation:

MapBox/OSM could not geocode the intersection 'Wythe Ave and N 4th Street Brooklyn, NY'. The reason seemed to be a lack of county tags across all OpenStreetMaps street data and intersection querying queries county tags for NYC streets.

Input:

from OSMPythonTools.overpass import Overpass, overpassQueryBuilder
from OSMPythonTools.nominatim import Nominatim

nominatim = Nominatim()
nyc = nominatim.query('NYC')

query = overpassQueryBuilder(
    area=nyc,
    elementType='way',
    selector=['highway', '"name"="North 4th Street"'],
    out='body',
    includeGeometry=True
)

overpass = Overpass()
result = overpass.query(query, timeout=100)

for ele in result.elements():
    print(f'{ele.tags()}' + '\n')

Output:

{'highway': 'residential', 'name': 'North 4th Street', 'oneway': 'yes'}

{'highway': 'residential', 'name': 'North 4th Street', 'oneway': 'yes', 'tiger:cfcc': 'A41', 'tiger:county': 'Kings, NY', 'tiger:name_base': '4th', 'tiger:name_direction_prefix': 'N', 'tiger:name_type': 'St', 'tiger:zip_left': '11211', 'tiger:zip_right': '11211'}

One section of North 4th Street is tagged with 'Kings, NY' while the other section does not. In this example, the first section coincides with the intersection point of North 4th Street and Wythe Avenue.

Solution:

Merging all street sections with the same name in the same geographic county into a shapely MultiLineString object.

About

To help finding latitude and longitude for NYC street intersections.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages