The distance between two lists of addresses
Stores and check-ins, customers and their branch, patients and clinics: two lists and one question, how far apart. One command geocodes the addresses on the country file and measures each pair.
New Places and zones Command line Logistics, field work Retail, e-commerce
What you have
Two CSV files. One holds addresses, the other points; rows pair by id:
id,address st-1,"10 Rue de Rivoli, 75004 Paris" st-2,"1 Place Bellecour, 69002 Lyon" st-3,"Rue de la Paix, Paris"
id,lat,lon st-1,48.85533,2.36004 st-2,45.75822,4.83350 st-3,48.86890,2.33150
Steps
1. One distance per pair of rows with the same id:
$ gridpin distance stores.csv checkins.csv --sheet france.bin --key id id,address,distance_id,distance_m,distance_note st-1,"10 Rue de Rivoli, 75004 Paris",st-1,33.0, st-2,"1 Place Bellecour, 69002 Lyon",st-2,213.6, st-3,"Rue de la Paix, Paris",st-3,,weak answer in the first file 2 distances, 1 pairs without one (1 placed by a weak answer)
2. Every row with every row, one line per pair:
$ gridpin distance stores.csv checkins.csv --sheet france.bin --matrix a_id,b_id,distance_m st-1,st-1,33.0 st-1,st-2,391587.9 st-1,st-3,2587.0 st-2,st-1,391426.6 st-2,st-2,213.6 st-2,st-3,393766.5 6 distances, 3 pairs without one (3 placed by a weak answer)
What you get
distance_m is metres in a straight line over the Earth's surface. Rue de la Paix, Paris names a whole street, so it gets no distance and says why: a distance to the wrong place would look like any other number.
Why it works
Each file is read as points, or geocoded on the country file one row at a time. The distance is the great-circle formula GridPin uses everywhere (radius 6,371 km).
Limits
- In release 0.10.0
gridpin distanceworks but is not yet listed bygridpin --help. - Straight lines, not road distance or travel time.
- A row placed only by a street or a town gets no distance.
- A matrix stops at 10 million pairs unless you move the limit.
The function: distances between two lists. All its keys: command reference. Related: a courier's GPS mark against the address, jobs near a candidate.