当前位置:网站首页>Using numpy for elevation statistics and visualization
Using numpy for elevation statistics and visualization
2022-07-25 10:38:00 【51CTO】
Let's watch a video of the common evils :
After watching the , Shrimp God thought , Isn't that what hadoop Basic skills inside wordcount Well …… But don't hadoop, Also need not Spark, use Numpy How to do it ? Do what you say , Let's see the effect first :

Although functions are often easy to implement , However, the effect of not being able to support others is flawed , So there is the following dialogue :

Point directly to the topic in one sentence …… Millions later , Begging yard farmer …… Too real .
Let's briefly talk about the basic principle of the whole function realization :
First , If you don't paint , It is the simplest elevation frequency statistics , If you like to do it with a dictionary , It's also easy , Like this :

Here's divided by 10 After rounding, multiply by 10, It is used for reclassification , Give up all the ten places and all the places : such as 4530, Round it down to 4500.
But such a calculation actually used 5.54s…… Isn't it a double cycle , So slowly , There is a way to hurry up ? The answer, of course, is wooden , For example, direct use numpy Built in functions for :

Oh my god !84 millisecond …… use numpy The speed of , was Python Circularly calculated 65 times …… Don't write the statistical process by yourself , Sure enough Python Using bags is the king .
numpy Of unique function , The unique value statistics can be carried out directly , After the statistics are finished , You can draw the histogram directly :

Actually so far , Even if the elevation statistics are finished ……

Color ! Where is the color ? Don't say color , Let's finish the work in a rough way !!
ok , The following to continue …… Set the color of matplotlib A basic skill of , Directly through cmap Color mapping , You can render directly , For example, for terrain , We use different colors to map :
gist_earth, The so-called earth color :

Or directly use gray color :

matplotlib Logo color jet( Hot and cold color ):

cmap The principle of is to directly generate a linear hierarchical color builder : Well, I picked up the name myself , The official name is “LinearSegmentedColormap ”, The function is based on the color name you set , Generate a series of color values . So we can directly from this builder , To get the color we need :
Now I'll start with jet Inside , obtain 10 One color :

This is a rgb+ The value of transparency , Of course , We can also change the standard color number to hexadecimal :

Of course , You can also use gradients :

Know these methods , You can naturally get the rendering colors of different elevations , Then get the histogram , All the source codes are as follows :

If you need source code , You can go to shrimp God's new code warehouse to find .
Code reference address , Send directly to official account 6, You can get , The above codes and data , All in PythonDemo/021 Elevation statistics and visualization .
边栏推荐
- Basic concepts of testing
- Trojang attack on neural networks paper reading notes
- 7.shell实用的小工具cut等
- 4.隔壁小孩都会的,各种shell符号{}[]等
- About the jar package of slf4j log4j log4j2 used together
- 2021 牛客网笔试总结 02
- Supervisor部署(离线部署需要提前下载部署包)
- Multithreading -- callable interface, lambda
- 9.shell文本处理三剑客之awk
- Mysql5.7主从数据库部署(离线部署)
猜你喜欢
随机推荐
Basic concepts of testing
使用Numpy进行高程统计及可视化
Strut2 form label
JS encryption parameter positioning
Vs Code connects to the remote jupyter server
4、 Testfixture test fixture, or test firmware
Angr (VIII) -- angr_ ctf
shortest-unsorted-continuous-subarray
Install MySQL database version 5.7.29 under ubuntu20.04 system
存储、计算、分布式虚拟化篇(收集整理适合小白)
User preferences
How to connect tdengine through open source database management tool dbeaver
Test plan and test plan
Pytoch separates tensor by the value of one dimension of tensor (simple)
Acquisition and compilation of UE4 source code
10. Expect interaction free
Ansible Deployment Guide
For cycle: daffodil case
Configuration of OSPF protocol (take Huawei ENSP as an example)
1、 The difference between unittest framework and pytest framework







