从经度,经度,值创建png文件 [英] Create a png file from lat,long,value

查看:103
本文介绍了从经度,经度,值创建png文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在awk中有一个程序,该程序具有一个Lat,long值数组.假设纬度/经度是栅格单元格的中心.对于每个bin,都有一个值,我想创建一个png文件,根据该值对每个bin进行颜色编码.对于纬度/经度/值的每一行(例如600X600像素或360,000个bin),我希望生成png文件.现在,每个垃圾箱代表大约30米乘30米的垃圾箱大小.例如参见图片.假设我希望在整个值范围内使用5种颜色,例如0-10是蓝色,11-20,红色等.

我的数据如下: 38.0098946,78.5092495,30 38.0101420,78.5091242,20 38.0103893,78.5089989,10 38.0106366,78.5088737,50

示例

解决方案

作为我其他答案的替代方案,您可以编写一个PGM(便携式灰度图)文件,该文件在我链接到的同一Wikipedia页面上进行了描述在另一个答案中.因此,在标头中您将写P2代替P3,并且对于每个像素,您将写已经拥有的单个值(0-50范围内),而不是特定颜色的三个分量./p>

他的方法的优点是您可以随后使用查找表为图像着色,并用颜色进行着色,而无需更改程序或缩放比例.

因此,假设您的程序(奇迹般地)产生了此灰度渐变,其值在0-255(output.pgm)之间变化:

现在您要根据以下内容为其着色:

  • 0-9 =>红色
  • 10-19 =>黄色
  • 20-29 =>绿色
  • 30-39 =>深灰色
  • 40-49 =>浅灰色
  • 50+ =>洋红色

您可以像这样制作一个颜色查询表:

convert -size 10x1 xc:red xc:yellow xc:lime xc:gray40 xc:gray80 +append -background magenta -extent 256x1\! LUT.png

现在,您可以使用以下方法将该查询表应用于结果:

convert output.pgm LUT.PNG -clut result.png

I have a program in awk that has an array of Lat, long, values. assume the lat/long are the center of a bin of a grid. For each bin there is a value and I would like to create a png file that color codes each bin depending on the value. For each line of lat/long/value (lets say for a 600X600 pixels or 360,000 bins) I would like the png file to be generated. Each bin now represents about a 30 meter by 30 meter bin size. See picture for example. Assume I woul dlike to have 5 colors for the entire range of values lets say 0-10 is blue, 11-20, red, etc.

the data I have is as follows: 38.0098946, 78.5092495 ,30 38.0101420, 78.5091242 ,20 38.0103893, 78.5089989 ,10 38.0106366, 78.5088737 ,50

example

解决方案

As an alternative to my other answer, you could write a PGM (Portable Gray Map) file, which is described on the same Wikipedia page I linked to in the other answer. So, in the header you would write P2 in place of P3 and for each pixel you would write the single value (in range 0-50) that you already have, rather than the three components of a specific colour.

The advantage of his method is that you can then colour the images with a lookup table afterwards and dink with the colours without needing to change your program or the scaling.

So, let's say your program (miraculously) produced this greyscale ramp where the values vary from 0-255 (output.pgm):

And now you want to colour it according to:

  • 0-9 => red
  • 10-19 => yellow
  • 20-29 => green
  • 30-39 => dark grey
  • 40-49 => light grey
  • 50+ => magenta

You can make a Colour Lookup Table like this:

convert -size 10x1 xc:red xc:yellow xc:lime xc:gray40 xc:gray80 +append -background magenta -extent 256x1\! LUT.png

And now you can apply that lookup table to your results with:

convert output.pgm LUT.PNG -clut result.png

这篇关于从经度,经度,值创建png文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆