I am using QGIS. I have a large dataset of approx a hundred animals and I want to determine the number of successful road crossings and extract the date, the time and the two GPS coordinates before and after the road crossing. Please see screenshot attached that shows the example for one animal.

I have intersected the vector line layer from the road network (in red) with the vector line of the animal movements that links its GPS locations and obtained a layer of points where the animal likely crossed the road (round white coloured dot in the screenshot).

When I create a buffer around the intersected points to include the GPS locations linked to each road crossing, I end up including points where the animal did not cross the road because they are included within the distance of the buffer.

How can I include only the GPS points linked to the data crossing? It would be one GPS location at each side of the road (in red).

Movement of one of the animals at each side of the road

  • use clip with your buffered points and the red line?
    – Mapperz
    May 2, 2020 at 23:52

4 Answers 4


Yet another approach using the Field Calculator... this will work only if your GPS attribute table is sorted according to the recorded date/time.

A dummy GPS point data crossing Road (I've got road 'fid' = only '1').

enter image description here

Now please ope the GPS layer's attribute table and start the Field Calculator.

Give this expression:

WHEN  intersects(make_line($geometry, geometry(get_feature_by_id('GPS', $id +1))),  geometry(get_feature('Road', 'fid', '1'))) = 1 THEN 'Pre'
WHEN  intersects(make_line($geometry, geometry(get_feature_by_id('GPS', $id -1))),  geometry(get_feature('Road', 'fid', '1'))) = 1 THEN 'Post'

It will add a new field with Pre (point before crossing), Post (point after crossing), and NULL (otherwise).

enter image description here

Delete the rows with NULL value.

enter image description here

  • 1
    To add on to this, if the original order of data (not just how it's sorted in the attribute table) is not sorted by datetime, you could add an "order" column using the plugin Sort and Number, and use the expression get_feature('GPS',"order"+1) (and similar) in your expression
    – she_weeds
    May 3, 2020 at 5:51

EDIT: The PointstoPaths plugin (described below) is now available at QGIS 3.x

Reuben, good day to you. I have solved problems like yours with the QGIS tool PointstoPaths (note the plural Paths). This is an extraordinarily useful tool. Sadly, it is only available at QGIS v. 2.X. If you don't have v. 2.X installed, download the latest version at:


For my Windows 10 machine, I use the install file QGIS-OSGeo4W-2.18.28-2-Setup-x86_64.exe

Once installed, add the PointstoPaths plugin.

You will need two layers, your road layer and your GPS points. As with all GIS analysis procedures, please make sure that they have been projected to the same Coordinate Reference System, and that they contain no geometry errors.

Run PointstoPaths, using the GPS point layer. The Point Group Field will identify each unique animal. In my screenshot below, that field is animal_no.

The Point Order field will be your GPS date/time field. I have had best success setting that field to text, 19-characters long. Within that field, the values look like 2020-05-02 18:56:25 That date/time format is entered in Date Format as %Y-%m-%d %H:%M:%S. Note the blank between date and time.

Important: You must check the Line per Vertex checkbox! It is this option that gives PointstoPaths its unique capability.

enter image description here

PointstoPaths will now output a line shapefile. Each segment in this shapefile will have two fields, begin and end. Not surprisingly, begin and end contain the beginning and ending GPS date/time values that sequentially comprise each segment. These two fields are what make PointstoPaths so special, because each segment can now be related back to the two points that created it.

Now, use the QGIS Select by Location tool to select which output line segments intersect with the roads. Voila! The resulting selection will detail which animals crossed a road, along with the beginning and ending time of each crossing.

I only wish that PointstoPaths were upgraded to 3.x!

Note that the output field names begin and end are reserved ESRI words. To avoid downstream problems, I rename them to something else.

enter image description here


You have a good description of the problem. It is a nice logic question which can be dealt with by gis.

I would create a line feature between all the points. The attributes of each line would contain the average of time and somehow average of the gps readings.

Then intersect the road with your new line features. Potentially the intersection will give you true GPS location of the crossing (not the averaged attribute) and an approximation of the time when the animal crossed the road.

I trust this tool in the image will be the one; enter image description here


Thank you very much for the answer and the help. I managed to solve it the following way (it requires several steps):

We had a large amount of collared animals so I had to divide the whole dataset per year. I firstly did an intersection of the road layer with the movement line layer to get an approximation of which animals crossed the roads each year and reduce further each dataset by discarding animals that did not cross the road.

Once I had the gps locations of all the collared animals that crossed roads, I used the "Points to Path" tool to obtain a single line.

Afterwards, I used the tool "Explode" to separate this line in thousands of smaller lines that join each consecutive GPS location.

Then the tool "Join attributes by location" allowed me to give the attributes of the two gps locations to each separate line. This tool was great because it really allowed me to give attributes to all the thousands of lines across the landscape.

Then using the tool "Intersect" I retrieved the GPS coordinates where the road layer intersects with the movements of the cheetahs defined by the line layer and also extracted the attributes of each one of the vector files (date, time, animal ID, road number and type of road). This tool saves the intersections as datapoints that have the attributes of both lines (the road and the movements of the animals (date, time, animal id, etc.).

Great forum! I am happy that I joined!

  • You could add screenshots to improve your answer. May 6, 2020 at 8:50

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.