在 C# 中生成地理参考图像
我想创建一些热图样式图块以使用开放图层覆盖在我们的底图上。 基本上,我想将一些边界框划分为网格,并根据样本中有多少点落在该网格正方形内,使用不同的颜色显示网格的每个正方形。
涉及的技术有C#、OpenLayers、SQL Server 2008和GeoServer。
我的问题基本上是一种通用方法,我不太确定将凿子的尖端放在哪里。
我的最终目标是能够采用任意边界框,计算适合该边界框的 x 英里 x 英里网格,迭代一组单独的点并将它们分配给一个网格方块或另一个网格方块,这样我可以计算每个网格正方形的点密度,然后根据密度为网格着色,然后使用开放图层将其覆盖在 CloudMade 底图上。
任何帮助,无论是整个事情还是其中的任何部分,我们都将不胜感激。
I want to create some heat-map style tiles to overlay over our base maps using Open Layers. Basically, I want to divide some some bounding box into a grid, and display each square of the grid using a different color based on how many points of a sample fall within that grid square.
The technologies involved are C#, OpenLayers, SQL Server 2008 and GeoServer.
My question is basically one of general approach, I'm not really sure where to put the tip of the chisel on this one.
My ultimate goal is to be able to take any arbitrary bounding box, calculate an x-mile by x-mile grid that fits within that bounding box, the iterate over a collection of individual points and assign them to one grid square or another so I can calculate point density per grid square, then color the grid according to the densities, then overlay that on a CloudMade base map using Open Layers.
Any help at all would be greatly appreciated, on the whole thing or any piece of it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的边界框是轴对齐的,那么这相当简单。 只需制作您的图像,然后手动为其创建一个世界文件即可。 世界文件只有 6 行文本,您已经知道所需的一切(x 和 y 像素大小、左上角的坐标)。
只需确保您使用左上角像素的中心,而不是框的角。
------ 以下是制作世界文件的方法 ----------
假设您的边界框的左上角位于 203732x598374,并且您想要一个具有东边宽 200m 的矩形的图像<->西、南北高300m。
您将创建一个具有适当像素数的图像,然后创建一个包含以下 6 行的世界文件:
这对应于:
如果您使用 .png 图像,您将需要使用相同的名称保存它,但是作为.pgw。 如果您使用 .jpg,则为 .jgw 等。
有关完整详细信息,请参阅:
世界文件维基
If your bounding box is axis aligned, this is fairly simple. Just make your image, and create a world file for it by hand. The world file is just 6 lines of text, and you already know everything needed (x & y pixel size, coordinate of your upper left corner).
Just make sure that you use the CENTER of the upper left corner pixel, not the corner of the box.
------ Here's how you'd make the world file -------
Say your bounding box's upper left corner is at 203732x598374, and you want an image that has rectangles that are 200m wide east<->west and 300m tall north<->south.
You'd make an image that was the appropriate number of pixels, then a world file that had the following 6 lines:
This corresponds to:
If you use a .png image, you'll want to save this with the same name, but as .pgw. If you use a .jpg, it'd be .jgw, etc.
For complete details, see:
Wiki on World Files
“将一些边界框划分为网格,并根据样本中有多少点落在该网格方块内,使用不同的颜色显示网格的每个方块。” 这是一个栅格,有GeoServer 中的功能,用于通过颜色阴影、图例等显示这些内容。 我认为使用这些功能比在 C# 中创建图像图块更加灵活。
来自地理服务器文档:
在其他 GIS 软件包中,这也称为专题制图、等高线图、热图或 2.5D 图。
您可以使用免费的 GIS,例如 Grass 到 创建栅格网格,但根据您的描述,您不需要插值(因为每个单元格至少包含一个点)因此,编写自己的代码可能同样容易。
编辑:有一个开源库 GDAL 您可以使用它在 各种格式。 有 C# 绑定。
"Dividing some some bounding box into a grid, and displaying each square of the grid using a different color based on how many points of a sample fall within that grid square." This is a raster and there are features in GeoServer for displaying these with colour shading, legends and so on. I think it will be more flexible to use these features than to create image tiles in C#.
From the GeoServer documentation:
This is also called thematic mapping or contour plots or heatmaps or 2.5D plots in other GIS packages.
You could use a free GIS like Grass to create the raster grids, but from your description you don't need to interpolate (because every cell contains at least one point) so it might be just as easy to roll your own code.
EDIT: there is an open source library GDAL which you can use to write raster files in various formats. There are C# bindings.
我认为计算左上角像素中心的公式是错误的。 在该示例中,左上角像素的中心将位于 (203732,598374) 的右下方。 那么不应该是下面这样吗?
I think the formulas for computing the center of the upper left pixel are wrong. In the example, the center of the upper left pixel would be down and to the right of (203732,598374). So shouldn't it be the following?