2

Fairly new to python so this may seem noobish. I have created two basic maps in .line format (new to me), each showing different features using matplotlib. These maps were converted from separate shapefiles. Now I need to merge these two .line maps into one.

Any ideas would be highly appreciated. TY.

kawakawa
  • 75
  • 1
  • 4
  • 1
    Hello. Your question would be greatly improved if you shared some of your code so we can see what your maps look like. You might find some of the help pages useful, such as https://stackoverflow.com/tour. – Joseph Hansen Jun 23 '20 at 03:09
  • Does this answer your question? [How do I merge two dictionaries in a single expression?](https://stackoverflow.com/questions/38987/how-do-i-merge-two-dictionaries-in-a-single-expression) – joel Jan 04 '23 at 17:07

1 Answers1

6

In Python 3.5 or greater:

z = {**x, **y}

In Python 2, (or 3.4 or lower) write a function:

def merge_two_dicts(x, y):
    z = x.copy()   # start with x's keys and values
    z.update(y)    # modifies z with y's keys and values & returns None
    return z

z = merge_two_dicts(x, y)
sushanth
  • 8,275
  • 3
  • 17
  • 28
Jaganath Kamble
  • 506
  • 2
  • 10