2

I'm trying to associate a set of points (lat, long) to an edge using osmnx library in Python.

I would like to find the nearest points to an edge within a distance x.

I have an edge and I would like to draw a circle and count how many points are into the circle, with a given radius. I have tha lat and long coordinates of each point but I don't know how to calculate the lat, long coordinate of the edge. I also have the coordinates lat, long of the nodes connected by that edge.

Thank you for your help.

1
  • I calculated the mid point of the edge using the coordinates of the nodes connected by that edge. Commented Sep 30, 2019 at 1:30

1 Answer 1

0
    import pandas as pd
    from shapely.ops import transform
    from functools import partial
    import pyproj
    from shapely.geometry import Point

    mid_point = Point(lon,lat) # UNPROJECTED CO-ORDINATES OF MID-POINT OF AN EDGE
    node_point = Point(lon_node, lat_node)# UNPROJECTED CO-ORDINATES OF THE NODE
    x = 500 #DISTANCE IN METERS

    #TRANSFORM INTO PROJECTED CO-ORDINATES
    project = partial(pyproj.transform,pyproj.Proj(init='epsg:4326'),pyproj.Proj(init='epsg:3112'))
    mid_point_projected = transform(project, mid_point)
    node_point_projected = transform(project, node_point)

    #CREATE BUFFER CIRCLE WITH DISTANCE X METRES WITH CENTRE AT EDGE MID-POINT
    buffer_circle = mid_point_projected.buffer(x)

    #PERFORM POINT-IN-POLYGON ANALYSIS TO CHECK WHETHER THE NODE FALLS WITHIN THE BUFFER CIRCLE
    print(buffer_circle.contains(node_point_projected))

POINTS TO BE NOTED:

  1. EPSG Geodetic Parameter Dataset is a structured dataset of Coordinate Reference Systems and Coordinate Transformations, accessible through this online registry (www.epsg-registry.org)

  2. EPSG 4326 represents World Geodetic System (WGS84) (https://epsg.io/4326)(points on the Earth's surface represented in terms of latitude and longitude)

  3. I have transformed it into EPSG 3112 representing GDA94 / Geoscience Australia Lambert (https://epsg.io/3112). You should transform it into the corresponding EPSG code for your study area.

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