I am a newby in python scripting in GIS. I have 2 shapefile: first one with roads and second one with points that contains address number and street name.
I want to select these points from right or left side of the street but in the correct order according to the street start and end.
Firstly, I want to select the points from the red polygon and check them (checking is another task and I know how to do it but selecting this points in the right order..)
Secondly, the same. I want to select the points from the blue polygon an check them too.
NB: Points is a layer, roads is another layer. also buffer of the roads is another layer.
I think that would be a good idea to parse the buffer and select by location the points that is in the buffer, but i don't know how.
Best Answer
EDIT: I've revamped this answer after realizing that Linear Referencing supports determining the side along a line.
The best approach to this problem is to use the Linear Referencing toolbox in ArcGIS:
Here's how you would do it, assuming we're using the streets and lines below:
Run the Create Routes (Linear Referencing) tool with your streets as your
in_line_features
. Pick a unique ID field for theroute_id_field
parameter. You can leave all other parameters as their defaults.Run the Locate Features Along Routes (Linear Referencing) tool with your points as the
in_features
, the routes we created above as thein_routes
, and the street ID field as yourroute_id_field
. You should change yourradius_or_tolerance
such that there's enough distance from your streets to capture all of your points. Lastly, uncheck them_direction_offsetting
parameter; this will make it such that the left/right designation is based on the digitization direction of your streets rather than the more arbitrary direction of your routes.In your output table (shown below), you will have one row for each point. The value in the
MEAS
field represents the distance along the street that the point is located. The value in theDistance
field represents the distance from the point to the snapped nearest location in your street, where the sign of the distance indicate the side of the street. So negative values indicate points to the left of the street and positive values indicate points to the right of the street.To iterate through your left-side points, sort the table by
RID
andMEAS
and skip positive values; do the same but reverse the sorting ofMEAS
and skip negative values to iterate through your ride-side points in reverse order. It's probably easiest to sort in Python:This results in our points sorted by street ID, then left side from start to end, then right side from end to start: