- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在导入具有 SRID 4326 的 wkt 多点特征的文件时遇到一些问题,其坐标是有序的(纬度、经度):
>st_crs(4326)
Coordinate Reference System:
User input: EPSG:4326
wkt:
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
USAGE[
SCOPE["Horizontal component of 3D system."],
AREA["World."],
BBOX[-90,-180,90,180]],
ID["EPSG",4326]]
所以我“加载”并按如下方式分配 crs(仅显示一行用于可重现的示例,但这将是数百行
tst <- data.frame(ID = rep("Test", 2),
SRIDTrail = rep(4326, 2),
Trail = c("MULTIPOINT (52.86 -8.00, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.89 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.97)",
"MULTIPOINT (53.86 -7.00, 52.02 -6.98, 53.85 -7.80, 51.85 -8.98, 52.89 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.97)"))
tst_sf <- tst %>%
st_as_sf(wkt = "Trail") %>%
st_set_crs(4326)
现在,让我们从 naturalearth 包中下载世界地图,并检查它的 CRS:
library(rnaturalearth)
world <- ne_countries(scale = "medium", returnclass = "sf")
st_crs(world)
给出
Coordinate Reference System:
User input: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
wkt:
BOUNDCRS[
SOURCECRS[
GEOGCRS["unknown",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ID["EPSG",6326]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433],
ID["EPSG",8901]],
CS[ellipsoidal,2],
AXIS["longitude",east,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]],
AXIS["latitude",north,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]]]],
TARGETCRS[
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["latitude",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["longitude",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]]],
ABRIDGEDTRANSFORMATION["Transformation from unknown to WGS84",
METHOD["Geocentric translations (geog2D domain)",
ID["EPSG",9603]],
PARAMETER["X-axis translation",0,
ID["EPSG",8605]],
PARAMETER["Y-axis translation",0,
ID["EPSG",8606]],
PARAMETER["Z-axis translation",0,
ID["EPSG",8607]]]]
表示第一个轴对应于经度,而不是纬度。所以,我尝试的第一件事(因为它会更快)是将我的数据转换为世界地图的相同投影,然后将它们都绘制出来:
tst_sf2 <- tst_sf %>% st_transform(st_crs(world))
ggplot(tst_sf2) +
geom_sf(data = world) +
geom_sf(col = "red") +
theme_bw()
这没有用,因为本应位于爱尔兰的点被绘制在印度洋中,该位置具有“交换”坐标,即纬度 -8,经度 53)。
让我们尝试反过来,变换世界地图,而不是 wtk。
world2 <- world %>% st_transform(st_crs(tst_sf))
ggplot(tst_sf) +
geom_sf(data = world2) +
geom_sf(col = "red") +
theme_bw()
所以,我的问题是:
(1) 是否有任何我可以使用的 EPSG 代码可以让 R 理解 WKT 文件中的坐标是根据预期交换的(我并不是要讨论应该是哪个顺序,只是为了修复它!)
(2) 如果这不可能,我该如何更改坐标的顺序,考虑到会有数百行并且并非所有多点要素的长度都相同。
最佳答案
请寻找另一个利用 sf_project()
函数的参数 authority_compliant = st_axis_order(FALSE/TRUE)
的解决方案。
# The map
world <- ne_countries(scale = "medium", returnclass = "sf")
# Your point(s)
tst <- data.frame(ID = "Test",
SRIDTrail = 4326,
Trail = "MULTIPOINT (52.86 -8.00, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.89 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.97)")
tst_sf <- tst %>%
st_as_sf(wkt = "Trail", crs = 4326) # please, note that I lightened your code a little bit here.
# set the new geometry (i.e. lon-lat instead of lat-long)
RightOrder <- sf_project(from = st_crs(tst_sf),
to = st_crs(world),
matrix(unlist(tst_sf$Trail),
nrow = lapply(tst_sf$Trail, length)[[1]]/2,
ncol = 2),
authority_compliant = st_axis_order(TRUE)) %>% # the argument that allows to choose the order of the axes: lat-lon (FALSE) and lon-lat (TRUE)
as.data.frame() %>%
setNames(., c("lon", "lat")) %>%
st_as_sf(coords = c("lon", "lat"), crs = 4326) %>%
st_cast("MULTIPOINT") %>%
st_union()
# drop the previous geometry and add the new one
tst_sf <- tst_sf %>%
st_drop_geometry() %>%
st_sf(.,RightOrder)
# visualize the result
ggplot(tst_sf) +
geom_sf(data = world) +
geom_sf(col = "red") +
theme_bw()
编辑
更新上述答案以管理多行数据集(参见下面的评论)
请在下面找到以下代表:
# The map
world <- ne_countries(scale = "medium", returnclass = "sf")
# Your point(s)
tst <- data.frame(ID = rep("Test", 2),
SRIDTrail = rep(4326, 2),
Trail = c("MULTIPOINT (52.86 -8.00, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.89 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.97)",
"MULTIPOINT (53.86 -7.00, 52.02 -6.98, 53.85 -7.80, 51.85 -8.98, 52.89 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.98, 52.85 -7.97)"))
tst_sf <- tst %>%
st_as_sf(wkt = "Trail", crs = 4326) # please, note that I lightened your code a little bit here.
# set the new geometry (i.e. lon-lat instead of lat-long)
for (i in seq(tst_sf$Trail)){
tst_sf$Trail[i] <- sf_project(from = st_crs(tst_sf),
to = st_crs(world),
matrix(unlist(tst_sf$Trail[i]),
nrow = lapply(tst_sf$Trail[i], length)[[1]]/2,
ncol = 2),
authority_compliant = st_axis_order(TRUE)) %>% # the argument that allows to choose the order of the axes: lat-lon (FALSE) and lon-lat (TRUE)
as.data.frame() %>%
setNames(., c("lon", "lat")) %>%
st_as_sf(coords = c("lon", "lat"), crs = 4326) %>%
st_cast("MULTIPOINT") %>%
st_union()
}
# visualize the result
ggplot(tst_sf) +
geom_sf(data = world) +
geom_sf(col = "red") +
theme_bw()
由 reprex package 创建于 2021-11-09 (v2.0.1)
关于r - (lat, lon) WKT 坐标不能用 st_transform 很好地重新投影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69771403/
我需要在不点击“保存”按钮的情况下在绘制后保存特征... 我选择使用“drawend”监听器来执行此操作... 这是我的“drawend”代码的一部分... draw.on('drawend', fu
我找不到如何在 OpenLayers 中使用 WKT 格式。 我已经尝试找到 solution in the documentation ,女巫基本上把我带到了这里:http://jsfiddle.n
我正在使用 pandas,我获得的数据集有一个 WKT 格式的位置列。例如: hospital.get_value(1,'WKT') POLYGON ((-58.4932 -34.5810,-58.4
我正在尝试使用 gdal 从多个局部坐标系投影一些基本形状。 ArcGIS 支持这些坐标系,但最终我只是厌倦了使用 gdal(和 proj4)将这些几何图形转换为基本纬度/经度(EPSG:4326)。
我是 GIS 领域的新手,我需要在 Java 中验证 WKT 格式的几何图形,以检查一个简单的多边形是否为闭环,即顶点的起点和终点应该相同。我目前正在使用 jGeometry 类的 oracle sp
我需要将数据从 Well Known-Text 转换为 Oracle SDO_Geometry。我在 Oracle 中找到了 SDO_UTIL.FROM_WKTGEOMETRY 方法,它非常适合我的
我正在开发一个使用 map 的应用程序。我想在 Java Android 中显示一个带有“洞”的多边形。我进行了搜索,但不幸的是,我找不到解决方案。我想我的问题是我无法设置正确的 fillColor。
我有一个 WKT - 包含一些几何数据的文件。 这里是一个例子(折线): s = "ST_GeomFromText( 'LINESTRING( 11.6614 48.0189, 11.6671 48.
我对oracle空间很陌生。 我有一个带有一个 SDO_GEOMETRY 列的空间表。在此表中插入 POINT 数据后,我想以 WKT 格式检索数据。 这是我所做的: 插入数据 - INSERT IN
我在here this文件中找到了。我读了它,但我一直想知道如何在WKT中定义一个具有3个环的多边形? 最佳答案 您可以使用POLYGON或MULTIPOLYGON类型,但请确保首先列出外部容器环,然
我有一个 Postgres 表,它以特定格式在其中一列中存储多边形几何图形,类似于这样- 0103000020E61000000100000004000000B8627F336B1554405DD60
我对 PostGIS 还很陌生,所以请多多包涵。 假设我有一个定义如下的表: CREATE TABLE gtest (name varchar, geom geometry); 起初,为了插入,我正在
我从mysql获取WKT数据: POLYGON((148.798828125 -34.37971258046219, 148.86474609375 -34.10270799
我在 java 中使用 ANLTR4,我可以像这样解析 WKT 多边形字符串 polygon((20 30, 30 40, 50 60, 20 30)) 使用这个词法分析器: POLYGON: ('p
我有一些众所周知的文本 (WKT) 用于表示几何对象,例如点、多点、线串、多边形、多多边形等。我有一个总共有 40000 个点的多边形。 我找到了 this plugin to convert SVG
我想使用定义为 wkt 的 POLYGON 使用 ogr2ogr 剪辑 shapefile。 根据文档,应该可以使用 WKT 作为 clipsrc [1] 但我无法获得正确的语法,我在下面有一些简化的
本文整理了Java中org.apache.sis.io.wkt.WKTFormat类的一些代码示例,展示了WKTFormat类的具体用法。这些代码示例主要来源于Github/Stackoverflow
我有一个 CSV 文件,其中的数据字段包含如下数据 POLYGON ((79.87749999947846 6.997500000409782, 79.882499999478456.99750000
我在 t-sql 语句中有以下 where 子句: where a.CELL_GEOM.STIntersects( STGeomFromText('POLYGON((-25.43623984375 4
我想将 wkt 地理转换为 jts 几何。 我尝试像这样使用 jts wkt reader。 导入 com.vividsolutions.jts.geom.Geometry; 导入 com.vivid
我是一名优秀的程序员,十分优秀!