Dry goods丨Folium library case-Part1-vector field drawing

    The next few issues will introduce some applications of Folium in oceanography, a geographic visualization tool involved in recent coursework.

    Folium is a powerful Python library for creating interactive map visualizations. It is based on Leaflet.js and enables easy drawing of maps in Python with support for various markers, shapes and layers. With Folium, you can draw point markers, polylines, polygons, etc., add colors, fills, and pop-ups, and create time-series maps and heatmaps. Folium's concise API and flexibility make map visualization simple and intuitive, providing an elegant and beautiful map visualization solution.

Folium official website:

https://python-visualization.github.io/folium/

Folium official example:

https://nbviewer.org/github/python-visualization/folium/tree/main/examples/

    In the next three issues, I will introduce three applications of Folium in oceanography: vector field (flow field, wind field, etc.) drawing, path (floating, typhoon, etc.) drawing and raster image visualization. First, the drawing of the vector field is introduced.

The backstage of Gongzhonghao replied "folium" to receive the sample code

 

Sample code runtime environment

    python——3.8

    leaf——0.14.0

    numpy——1.24.3

    netCDF4——1.6.3

    mplleaflet——0.0.5

    scipy——1.10.1 

    matplotlib——3.4.3

    Notice:

    ①The installation method of folium is the same as that of most libraries, that is, pip install folium. It should be noted that the mplleaflet library used to draw the flow field does not seem to support python versions above 3.8, so if you want to run the sample code I gave, It is better to create a virtual environment with version 3.8 and then install the above libraries.

    ② After the installation of mplleaflet is completed, the two codes need to be modified (refer to this link https://github.com/mpld3/mplexporter/compare/2f766e439b9d91ab4d4682245a2360bc1e5c2bb5...be8e3da62c81fea15a0107f3ae96ba16fc2cc9f), otherwise it will report Wrong 'XAxis' object has no attribute ' _gridOnMajor'.

    ③matplotlib needs to be installed with a version below 3.5, otherwise the error 'Quiver' object has no attribute 'get_offset_position' will be reported. It is recommended to install version 3.4.3 like me.

program effect

    This part of vector field drawing provides two examples, one is the visualization of GOCI2 sea surface flow field product data, and the other is the visualization of CCMP wind field data. If necessary, you can reply "folium" in the background to get the sample code .

    Note: When opening the html file and the Juypter program, if you want to view the base map other than the Gaode map, you need to hang a ladder

     I have added nanny-level comments in the program, and you can refer to it if you need it.

    That's it for this issue first, and the next issue will introduce the case of drawing typhoon and floating paths. If you have any questions about children's shoes, you can ask me in the background and I will try my best to help you solve them.

Guess you like

Origin blog.csdn.net/m0_51143849/article/details/131382520