In all_routes.shp: length_m: $length * 100 * 1000 length_km: $length * 100 Then generate distances: Name: if ( "distance" > 0, if ( "distance" = round( "distance", 2 ), "distance" * 100, 'Finish' ), 'Start' ) Create a new text field, quadrants, and set it to the result of: CASE WHEN "RouteLen" = '21' THEN CASE WHEN regexp_match( "Name", '^([136]|20|1[45678])$') THEN 'L,TL' WHEN regexp_match( "Name", '^([489]|10|1[123])$') THEN 'R,BR' WHEN regexp_match( "Name", '^([25]|19)$') THEN 'T' WHEN regexp_match( "Name", '^([7])$') THEN 'B' END WHEN "RouteLen" = '10' THEN CASE WHEN regexp_match( "Name", '^[789]$') THEN 'L,TL' WHEN regexp_match( "Name", '^[2456]$') THEN 'R,BR' WHEN regexp_match( "Name", '^[1]$') THEN 'T' WHEN regexp_match( "Name", '^[3]$') THEN 'B' END WHEN "RouteLen" = '5' THEN CASE WHEN regexp_match( "Name", '^[12]$') THEN 'L,TL' WHEN regexp_match( "Name", '^[0]$') THEN 'R,BR' WHEN regexp_match( "Name", '^[4]$') THEN 'T' WHEN regexp_match( "Name", '^[3]$') THEN 'B' END END