I have a sample of the address histories of households.

ID  ZIP1   ZIP2   ZIP3

It's easy enough for me to find the centroids of the ZIP codes. What I would like to do is link those centroids together to create an image showing household i's path from ZIP1 to ZIP2 to ZIP3.

Does anyone know any tools to make this easy in QGIS (or even better: R)? I have the feeling there must be some tool, but I don't know enough to think of what the name would be.

  • So basically you want to create polygons from points? – nickves Mar 28 '13 at 20:52
  • Well, the object would be a polyline. – gregmacfarlane Mar 29 '13 at 14:27

First of all you should try to get geographical information for your zip-codes (geocode them). Without any real points you can't construct a polyline so therefore you should start with that.
With the help of R you can easily geocode a lot of addresses using web-services. See a little example here on my blog. Of course you might have to change the code to your needs and possibly also consult other geocoding services.
The resulting data.frame can be converted to a spatial-object (package sp - coordinates(data) = ~x+y) and then be saved to a shapefile (package rgdal - writeOGR(...) ).

As soon as you have your point layer grouped with a ID you can import it into QGIS and use the excellent plugins Points2One or Points to Path.

| improve this answer | |
  • I figured a much easier way to get the spatial information would be by linking the ZIP code information to ZCTA TIGER files, which I already have. And my points are already geocoded anyways. The problem is that each point has multiple pairs of coordinates, and I need a way to map the links. Will look at Points to Path. – gregmacfarlane Mar 31 '13 at 1:31
  • The Points to Paths package worked for me. – gregmacfarlane Apr 17 '13 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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