Friday, 28 September 2018

qgis - How to join many points with lines?


I'm working with QGIS 3.4.3 and have a list of addresses (1500ish) that i need to map into lines. I have a CSV file having a start and end of each street and also have the same list separated in two CSVs, one for start and the other for ending. What I need is to put those addresses as lines into my map.


I also used mmqgis to geolocate the starting and ending points in order to join them with lines. So, I'm working with 2 options now.


My questions are:



  1. How can I geolocate lines with a start and end address?


  2. How can i join multiple points with a line?



Answer



Join by lines (hub lines) tool is what you are after.


You need your two separate files, one with start points and one with end points. Each street needs to have an ID, or unique matching field in both files.


enter image description here


If you do not have this unique field, you can generate it with Excel or QGIS. One idea would be to concatenate the fields STREET | CITY | STATE | COUNTRY. But not sure if this is unique in your case. However, you need to figure this out and in case its not, you will have to find another way to get an unique matching ID for your streets. To concatenate in QGIS, open the field calculator and create a new (virtual) field with the expression concat( "STREET", ' - ', "CITY", ' - ', "STATE", ' - ', "COUNTRY").


Edit: just seen your second table contains a different housenumber in STREET field. You need to remove these, e.g. with nested replace("STREET", 1, '') function.


enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...