海洋占总面积的百分比以及每个纬度的陆地复杂性

huangapple go评论65阅读模式
英文:

Percentage of ocean out of total area and the complexity of landmasses at each latitude

问题

我对获取显示每个纬度上海洋(即海洋水域,包括黑海等内陆海)占总表面积比例的折线图感兴趣。以及量化每个纬度上陆地的复杂性。但不确定从何处或如何开始,因为我通常不使用地图,而且谷歌也没有提供特别有见地的信息。

对于第一部分,获取每个纬度上海洋占总表面积的比例(或百分比),我有兴趣重新创建纬度上陆地的公里数图,但是这次是比例而不是绝对值:https://gis.stackexchange.com/questions/190753/using-gis-to-determine-average-land-distance-from-equator

这看起来与以下链接中的第一个图表非常相似:http://www.radicalcartography.net/index.html?histland

不过,我不确定从哪里开始,不过可能的方法之一是通过指定跨越每个纬度的整个多边形来计算面积。

对于第二部分,我想象中的方法可能是在每个纬度上绘制一条线,并计算该线与世界地图形状文件的交点数量?这样在70°N的纬度上,交点数量会比在赤道上少。

至于投影方式,我不挑剔,会选择最准确的方式,并愿意听取任何建议。

我希望能够在R中完成上述工作,但如果在Python或GIS中进行更合逻辑的操作,我也不介意。

提前感谢您的建议和指导!

英文:

I am interested in getting a line graph that shows the proportion of ocean (i.e. marine water bodies, that will include inland seas such as the Black sea) out of the total surface area at each latitude. As well as to quantify the complexity of land masses at each latitude. But am not sure where or how to start as I do not typically work with maps, and google has not been particularly insightful.

For the first part to get the proportion (or percentage) of ocean out of total surface area at each latitude, I am interested in recreating the km of land at latitude graph but as a proportion instead of absolute values: https://gis.stackexchange.com/questions/190753/using-gis-to-determine-average-land-distance-from-equator

That would look very similar to the first plot in: http://www.radicalcartography.net/index.html?histland

Not sure where to start on this, though a possibly way will be to calculate the area by specifying an entire polygon that spans each latitude.

For the second part, I imagine it'd be something along the lines of putting a line through each latitude and count the number of intersections of the line with the world map shape file? Such that at 70°N there would be less intersections than at the equator.

Projection wise, I am not particular, and would be happy with what is most accurate and will go with any recommendations.

I am hoping to be able to do the above in R, but would not mind doing the above in either Python or GIS as well if its more logical to do so.

Thank you for your tips and advice in advance!

答案1

得分: 2

从https://github.com/gkaramanis/xkcd-map借鉴创建一个包含地球陆地坐标的数据框架:

library(rnaturalearth)
library(terra)
library(tidyverse)

world <- ne_countries(scale = 50, type = "countries", returnclass = "sf") %>%
  rmapshaper::ms_dissolve()
r <- terra::rast(world, nrows = 1000, ncols = 1000) # adj. for higher res. if wanted
rr <- rasterize(terra::vect(world), r)
rr_df <- terra::as.data.frame(rr, xy = TRUE)

我们可以绘制这个数据框以确认其内容:地球上有343,000个(在此分辨率下)陆地点。这些点是未投影的,因此外观相当扭曲(例如,南极点的显示宽度与赤道一样宽),但对于此目的来说是可以的。

ggplot(rr_df, aes(x, y)) +
  geom_point(size = 0.1) +
  scale_y_continuous(breaks = scales::breaks_width(10))

在此分辨率下,地球表面在每个1000个纬度的1000个纬度上进行了采样,因此要获取陆地的份额,我们可以使用以下代码:

rr_df %>%
  count(y) %>%
  ggplot(aes(n/1000, y)) +
  geom_area(orientation = "y") +
  scale_y_continuous(breaks = scales::breaks_width(10)) +
  scale_x_continuous(labels = scales::percent_format())

对于第二部分,我们可以获取数据框并计算每个点是否比其左侧的前一个邻居的标准间距更远(在我的示例中为0.36度,因为我在每个纬度上取样了1000个像素,总共360度),这表示一个面向西的海滩。我认为每个纬度都必须有一个面向东的海滩,所以如果你愿意,可以将这些数字翻倍以获取总沿海线数量。

rr_df %>%
  arrange(y, x) %>%
  mutate(lat_grp = cumsum(x > lag(x, default = -179.82) + 0.37), .by = y) %>%
  summarize(coasts_per_lat = max(lat_grp), .by = y) %>%
  ggplot(aes(coasts_per_lat, y)) +
  geom_line(orientation = "y") +
  scale_y_continuous(breaks = scales::breaks_width(10))

在这里,我将这个图与上面的地图组合在一起,使用了patchwork包:

# 插入图片

或者我们可以将两者组合,将背景中的沿海线数量映射到地面上。

# 插入图片
英文:

Borrowing from https://github.com/gkaramanis/xkcd-map to create a data frame with coordinates for the earth's landmasses:

library(rnaturalearth)
library(terra)
library(tidyverse)

world &lt;- ne_countries(scale = 50, type = &quot;countries&quot;, returnclass = &quot;sf&quot;) %&gt;%
  rmapshaper::ms_dissolve()
r &lt;- terra::rast(world, nrows = 1000, ncols = 1000) # adj. for higher res. if wanted
rr &lt;- rasterize(terra::vect(world), r)
rr_df &lt;- terra::as.data.frame(rr, xy = TRUE)

We can plot this to confirm what it is: 343k (at this resolution) points on the globe where land is. These are unprojected points, so the appearance is quite distorted (e.g. the south pole point gets as much display width as the equator), but is fine for this purpose.

ggplot(rr_df, aes(x,y)) +
  geom_point(size = 0.1) +
  scale_y_continuous(breaks = scales::breaks_width(10))

海洋占总面积的百分比以及每个纬度的陆地复杂性

At this resolution, the earth's surface is sampled 1000x at each of 1000 latitudes, so to get the share of land we can use:

rr_df %&gt;%
  count(y) %&gt;%
  ggplot(aes(n/1000, y)) +
  geom_area(orientation = &quot;y&quot;) +
  scale_y_continuous(breaks = scales::breaks_width(10)) +
  scale_x_continuous(labels = scales::percent_format())

海洋占总面积的百分比以及每个纬度的陆地复杂性

For the 2nd part, we could take the data frame and count how often each point is farther than a standard spacing from its prior neighbor on the left (0.36 degrees in my example since I sampled at 1000 pixels per latitude consisting of 360 degrees), indicating a western-facing beach. I think by necessity every latitude must have an eastern-facing beach for every western-facing one, so you could double the numbers to get the total number of coasts, if you prefer.

rr_df %&gt;%
  arrange(y, x) %&gt;%
  mutate(lat_grp = cumsum(x &gt; lag(x, default = -179.82) + 0.37), .by = y) %&gt;%
  summarize(coasts_per_lat = max(lat_grp), .by = y) %&gt;%
  ggplot(aes(coasts_per_lat, y)) +
  geom_line(orientation = &quot;y&quot;) +
  scale_y_continuous(breaks = scales::breaks_width(10)) 

Here I've composed this with the map above using the patchwork package:

海洋占总面积的百分比以及每个纬度的陆地复杂性

Or we could combine both by mapping the # of coasts in the background with the land on top.

海洋占总面积的百分比以及每个纬度的陆地复杂性

huangapple
  • 本文由 发表于 2023年8月5日 07:34:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76839606.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定