2

I have point features indicating the taxis' trip data for pick-ups and drop-offs like the following:

[pickup_longitude, pickup_latitude, dropoff_longitude, dropoff_latitude, #passengers]

I want to select only the rows (trips) that their both pick-ups and drop-offs are locate in the background (Polygon) layer.

Any suggestions?

1 Answer 1

1

It would be more convenient if you had a TripID field to identify the pairs. Right now, I assume they go after each other (first two rows for TripID = 1, next two rows for TripID = 2 and so forth).

You could use Python if you are comfortable with scripting to select each point in the trip pair (start, end) and test whether both of them are within the polygon layer. Use arcpy.Geometry() for creating point features and then class methods for finding whether they are within the polygon. This is best approach, I strongly recommend this one.

If you are not comfortable with Python, you could choose a more lengthy process. You would need to create a point feature class with each point in the pair going after each other in the attribute table. Make XY Event Layer will help you with creating points. Then you need to generate a list of pairs:

[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10]

and calculate the new pairId field with the pairID.

First, create a sequential field like this.

Then calculate the newly created pairID field with [y for x in range(1,10) for y in [x, x]][!SeqField!-1].

Now you would need to use a combination of Spatial Join to find out what points in the pairs are located within the polygon. Still, using Python here would save a lot of time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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