小编The*_*ady的帖子

RGDAL不会安装

我无法在R中安装RGDAL.我正在使用Ubuntu 12.04.

configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/james/R/x86_64-pc-linux-gnu-library/3.2/rgdal’
Warning in install.packages :
  installation of package ‘rgdal’ had non-zero exit status
Run Code Online (Sandbox Code Playgroud)

我找到了一些解决方案,据说这样做:

sudo apt-get install aptitude
sudo aptitude install libgdal-dev 
sudo aptitude install libproj-dev
Run Code Online (Sandbox Code Playgroud)

我遵循这些,在提示时接受"是",但之后是相同的原始错误.它没有解决它.我想知道我是否应该降级一些东西?

谢谢,詹姆斯.

r gdal rgdal ubuntu-12.04

10
推荐指数
1
解决办法
5378
查看次数

在一条直线的R偏移处绘制一条平行线

我有线串代表一些街道上的驾驶旅程.但我想要真正代表一个骑行者的旅程,它偏离了线路,即他们在路边行进.我正在努力解决这个问题.我已经制作了一个可重现的R代码来说明.

## Let's say I have a route along some streets.
library(ggplot2)

## It can be described by this
data          <- data.frame(x = c(1,3,10,5,0,5),
                            y = c(1,3,1,0,5,7),
                            label = c('a', 'b', 'c', 'd', 'e', 'f'))
## Visualised by this
ggplot(data, aes(x, y)) +
  geom_path() +
  geom_text(aes(label=label),hjust=0, vjust=0)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

但我想做的就像有人骑自行车一样.假设它们从道路的中心线向左旋转0.5,向左,但当然"左"是相对于线的方向.旅程的开始实际上看起来像这样注意'new_x'和'new_y '在数学上不正确.它们是用于说明目的的估计.

data          <- data.frame(x = c(1,3,10,5,0,5),
                            y = c(1,3,1,0,5,7),
                            new_x = c(0.7, 3, 10.5,NA, NA, NA) ,
                        new_y = c(1.5, 3.5, 1, NA, NA, NA),
                        label = c('a', 'b', 'c', 'd', 'e', …
Run Code Online (Sandbox Code Playgroud)

gis r spatial geospatial coordinates

7
推荐指数
1
解决办法
620
查看次数

更改SF对象的CRS

我有一些“路”作为sp​​对象:

class       : SpatialLinesDataFrame 
features    : 17360 
extent      : 490176.4, 567680.9, 148639.1, 212821  (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:27700 +proj=tmerc +lat_0=49 +lon_0=-2     +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs     +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 
variables   : 4
names       :    osm_id, lanes,     type, width 
min values  :        73,     2, motorway,   6.3 
max values  : 587969162,     6,    trunk,  18.9
Run Code Online (Sandbox Code Playgroud)

我将它们转换为sf对象,如下所示:

roads                   <- st_as_sf(roads, crs = 27700)
Run Code Online (Sandbox Code Playgroud)

转换后,SRID为空,并且proj4string(可能)看起来不正确。为什么是这样?我可以解决吗?

Simple feature collection with 17360 features and 4 fields
geometry type:  LINESTRING
dimension:      XY
bbox:           xmin: 490176.4 …
Run Code Online (Sandbox Code Playgroud)

r spatial r-sp r-sf

2
推荐指数
1
解决办法
1203
查看次数

Postgresql LEFT JOIN with CASE condition

我想在PostgreSQL中使用CASE条件来决定要加入的另一个表的哪一列.这就是我所在的地方,我认为,这解释了我正在努力做的事情.非常感谢您的想法和想法:

SELECT hybrid_location.*,
       concentration
FROM   hybrid_location
CASE   WHEN EXTRACT(month FROM hybrid_location.point_time) = 1 
            THEN LEFT JOIN (SELECT jan_conc FROM io_postcode_ratios) ON
            st_within(hybrid_location.the_geom, io_postcode_ratios.the_geom) = true
       WHEN EXTRACT(month FROM hybrid_location.point_time) = 2 
            THEN LEFT JOIN (SELECT feb_conc FROM io_postcode_ratios) ON
            st_within(hybrid_location.the_geom, io_postcode_ratios.the_geom) = true
       ELSE LEFT JOIN (SELECT march_conc FROM io_postcode_ratios) ON
            st_within(hybrid_location.the_geom, io_postcode_ratios.the_geom) = true
       END AS concentration;
Run Code Online (Sandbox Code Playgroud)

sql postgis case left-join postgresql-9.3

1
推荐指数
1
解决办法
1万
查看次数

在 Python / GeoPandas 中组合 shapefile

我有三个相互重叠的多边形 shapefile。让我们称他们为:

  • file_one.shp(多边形名称为 1)
  • file_two.shp(多边形名称为 2)
  • file_three.shp(多边形名称为 3)

我想将它们结合起来并保持这样的值。

在此处输入图片说明

请问如何在Python中实现结果(如图所示)?

谢谢!

python gis spatial shapefile geopandas

1
推荐指数
1
解决办法
5352
查看次数

使用 terra 有条件地更新另一个栅格的栅格值

我正在 R 中使用 {terra} 的 lapp 函数,我想根据 rast_a 每个单元格中的值使用 rast_b 或 rast_c (以及其他一些数学)中的值更新 rast_a 。

样本数据

rast_a <- rast(ncol = 2, nrow = 2)
values(rast_a) <- 1:4

rast_b <- rast(ncol = 2, nrow = 2)
values(rast_b) <- c(2,2,2,2)

rast_c <- rast(ncol = 2, nrow = 2)
values(rast_c) <- c(3,3,3,3)
Run Code Online (Sandbox Code Playgroud)

问题

这是我的(错误的)尝试。

my_update_formula <- function(a, b, c) {

  a[a == 1] <- b[a == 1] + 10 + 20 - 30
  a[a == 2] <- c[a == 2] + 10 + …
Run Code Online (Sandbox Code Playgroud)

gis r raster spatial terra

1
推荐指数
1
解决办法
577
查看次数