Geographic Information Technologies for analysing the digital footprint of tourists

As part of a study on the use of the city by visitors, this paper discusses the technical solution adopted in order to analyse and exploit the geo-digital footprint generated by the said visitors using GPS devices. AGILE 2014 – Castellon, June 3-6, 2014 use PostGIS spatial tools to analyse the information contained in the . gpx files on the basis of SQL sentences. 3.2 Technical challenges The main challenge of the project consists of breaking down each track into a list of streets (or street arrays) along which each track passes. As such, it will be possible to know the sections of the streets through which each track passes and the length of time invested in each of these sections. The area of study itself poses a challenge, since the typical dim, narrow streets of Girona old quarter are susceptible to poor satellite coverage [1]. It is therefore necessary to correct the tracks generated in order not to lose too much data for the subsequent analysis. This challenge will consist of structuring the data in such a way that the planned analysis is both possible and agile. All of the processes carried out are listed below. 3.3 Importing the GPS data In order to import the . gpx files, the ogr2ogr tool has been used [2]. From a command console the following command is keyed in to import the . gpx track file into the track table within the TURISMO database. ogr2ogr -f “PostgreSQL” PG:”host=localhost user=postgres port=5433 dbname=TURISMO schemas=originals password=contrasena” track.gpx -overwrite -lco GEOMETRY_NAME=geom track_points -nln “track” This command uses the Postgres username and password to connect to the TURISMO database. Once connected it generates a new track table with all the information contained in the . gpx track file. The image above shows a fragment of the contents of the track table after it has been imported. The gid field functions as the primary key and serves to identify unequivocally each point in the table. This attribute will subsequently be used in new SQL sentences. The geometry of the points is found in the geo column, while the time column contains both the date and the time at which each track point was captured. The bulk import of the . gpx files, of which there are over 1,600, is carried out through a command file (.bat). This command file is generated from a script that reads the contents of a folder (where the tracks are located) and generates an import sentence for each . gpx file. Once each track is imported it is necessary to convert it from geographic coordinates (GPS) to projected coordinates (UTM). This step is obligatory in order to carry out a subsequent Snap operation indicating a tolerance in metric units (corresponding to the projected coordinates). With the following SQL sentence a new table is created with all the initial columns, plus the geometry contents re-projected to the ETRS89 coordinate reference system (srid = 25831). create table track_reproyectado as select st_transform(geom,25831) as geom_reproyectada, track. * from track; 3.4 Street map In order to carry out this operation it is necessary to import a street map of the area of study into the database. The main characteristic of this street map is that every street is split into various sections. Each section of each street is represented by a specific spatial entity. In other words, the number of sections into which each street is split is equal to the number of intersections that this street has with other streets. By splitting the streets in this way it is possible to detect the specific street section along which each track passes, while at the same time distinguishing the sections of the same street along which the track does not pass. The image below displays the points of intersection between streets (marked in red). The various sections of the same street are displayed in a single colour. The shp2pgsql tool has been used [3] (included in PostGIS) to import this shp format street map into the database. From a command console we execute: Shp2pgsql callejero_shape tabla_callejero > callejero.sql This command will generate the callejero.sql file with the contents of the . shp file translated into SQL expressions. The next step consists of executing the callejero.sql file within the TURISMO database. The file can either be executed from pgAdmin or, from a command console, by using the PostgreSQL command line interactive client, called psql, as shown below. psql -d TURISMO -U postgres -W -f callejero.sql This command will request the password of the corresponding user (-U). AGILE 2014 – Castellon, June 3-6, 2014 3.5 Assigning the track points on the street map Each point located on the track of the GPS device must be assigned to the nearest street. As such we can generate a list with the names of the streets along which the track passes. Only the track points located no more than 7 metres from a street have been assigned; the remaining track points have been discarded. In order to assign each track point to a street the following SQL command has been executed, inspired by Paul Ramsey’s post [4]: create table track_callejero as select distinct on (punto_id) c.gid as calle_id, tp.gid as punto_id from track_reproyectado tp inner join callejero c on st_DWithin(tp.geom, c.geom, 7.0) order by tp.gid, st_Distance(c.geom, tp.geom); This command calculates, for each track point, which streets are less than seven metres away. If a track point has more than one street located less than seven metres away, it places the streets in order so that the nearest street appears in first place. Finally, the distinct (punto_id) clause indicates that we only wish to obtain one street for each point. The fact that the streets have previously been placed in order means that each track point is assigned exclusively to its nearest street. The result of the sentence above is a new track_callejero table that lists each track point together with the nearest street. The matching of track points and streets is carried out on the basis of the alphanumeric attributes (gid) that identify each point and each street. These ‘gid‘ attributes are renamed punto_id and calle_id, respectively, in order to facilitate their interpretation. The streets from the above list for which fewer than five track points have captured have been omitted from the final result. As such we have omitted certain sections that are not very representative of the itinerary followed by the track.