God-level programmers teach you how to draw a map of China with four lines of code! Python is a cool thing.

Source: Internet
Author: User

The first two lines into the corresponding library, the real code is 4 lines, simple enough. The 1th line may not even be written, it defines the size of the graph. Line 2nd we create a map, line 3rd lines up the shoreline, and the 4th line shows the map, that's it:

You use Java the 4 line code to draw a map out?

And then we started painting the country, and again, 1 lines of code:

m.drawcountries(linewidth=1.5)

It becomes this:

Looks a bit deformed, this is because we did not add any projection of the reason, Basemap provide a 24 different projection method, you can try it one after another, more commonly 兰勃特投影 , we add:

m = Basemap(llcrnrlon=77, llcrnrlat=14, urcrnrlon=140, urcrnrlat=51, projection=‘lcc‘, lat_1=33, lat_2=45, lon_0=100)

This time it looks more normal at last:

God-level programmers teach you how to draw a map of China with four lines of code! Python is a cool thing.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.