从空间点数据创建边界多边形以在传单

从空间点数据创建边界多边形以在传单

本文介绍了从空间点数据创建边界多边形以在传单中进行绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好(在这里映射新手!)

Hello (mapping novice here!)

我四处游历,无法解决似乎棘手的问题.

I have had a good hunt around and can't find a solution to what seems to be a tricky problem.

我有基本的XY(坐标)数据:

I have basic XY (coordinate) data:

我想做的是基于不重叠且有一定大小限制的坐标数据创建相邻的多边形(因此它们不会永远延伸到海洋中).

What I want to do is create neighbouring polygons based on the coordinate data that do not overlap and have a certain size limit (so they don't extend forever into the ocean).

请原谅我糟糕的MS Paint技术,但所需的结果将是这样的:

Forgive my poor MS Paint skills, but the desired outcome would be something like this:

我有一个标记为陆/海界面的多边形,所以多边形也不能重叠.

I have a polygon that marks the land/sea interface so polygons cannot overlap that either.

我正在使用Leaflet使这些地图具有交互性,它不是用于任何统计分析,而是用于提供概述.

I am using Leaflet to make these maps interactive, its not for any statistical analysis but to provide an overview.

最终目的是使每个多边形都以变量(例如温度)上色,并覆盖生态数据.

The ultimate aim is to have each polygon coloured by a variable (e.g. Temperature) with ecological data overlaid.

一些示例数据:

    > data[1:10,]
   Station  Lat_dec  Long_dec Surface_T
1      247 50.33445 -2.240283     15.19
2      245 50.58483 -2.535217     14.11
3      239 50.16883 -2.509250     15.41
4      225 50.32848 -2.765967     15.34
5      229 50.63900 -2.964800     14.09
6      227 50.33757 -3.303217     15.12
7      217 50.16657 -3.563817     15.13
8      207 49.66683 -3.556550     15.04
9      213 50.16512 -3.824667     14.97
10     219 49.83707 -3.815483     14.78

产生图1的代码是基本的传单脚本:

the Code to produce figure 1 is a basic leaflet script:

leaflet() %>%
  addProviderTiles('Esri.OceanBasemap'
  ) %>%
  addCircleMarkers(data = data,
                   lng = ~Long_dec,
                   lat = ~Lat_dec,
                   radius = 2
  ) %>%
  addPolygons(data = Land,
              weight = 1,
              color = 'black')

整天让我感到沮丧的是,大多数示例都使用下载的多边形(例如,看起来像是经典的美国,而不是制造它们)

Its been frustrating me all day, most of the examples use downloaded polygons (e.g. what seems to be the classic US States rather than making them)

任何帮助,我们将不胜感激!(或者我问得太多!)

Any help greatly appreciated! (or am I asking too much!)

吉姆

推荐答案

以下是一些入门知识:

library(sf)
library(dplyr)

#create sf object with points
stations <- st_as_sf( df, coords = c( "Long_dec", "Lat_dec" ) )

#create voronoi/thiessen polygons
v <- stations %>%
  st_union() %>%
  st_voronoi() %>%
  st_collection_extract()

library(leaflet)
leaflet() %>%
  addTiles() %>%
  addCircleMarkers( data = stations ) %>%
  addPolygons( data = v )

这篇关于从空间点数据创建边界多边形以在传单中进行绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 02:27