小编cam*_*sia的帖子

geopandas:sjoin 'NoneType' 对象没有属性 'intersection'

我正在尝试对两个开源数据集进行空间连接。我遇到了一个AttributeError: 'NoneType' object has no attribute 'intersection'错误。通过确保删除空几何体似乎已经解决了类似的错误,但这似乎没有帮助。我还安装了 spatialindex-1.9.3 和 rtree-0.9.3。我正在使用 Python 3.8

import geopandas as gpd
import pandas as pd
from shapely.geometry import Point

# Import LSOA polygon data
LSOA_polygons = gpd.read_file('https://raw.githubusercontent.com/gausie/LSOA- 2011-GeoJSON/master/lsoa.geojson')

# Remove any empty geometry
LSOA_polygons = LSOA_polygons[LSOA_polygons.geometry.type == 'Polygon']

# UK charge point data
url_charge_points = 'http://chargepoints.dft.gov.uk/api/retrieve/registry/format/csv'
charge_points = pd.read_csv(url_charge_points, lineterminator='\n', low_memory=False, usecols=[0,3,4])

# Create a geometry column 
geometry = [Point(xy) for xy in zip(charge_points['longitude'], charge_points['latitude'])]

# Coordinate reference system : WGS84
crs = …
Run Code Online (Sandbox Code Playgroud)

python geopandas

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

ggsurvplot:从函数调用时无法使用 survfit

我正在尝试绘制生存图,并在尝试将我的 survfit 函数移动到主函数中时遇到了问题,我可以在主函数中为不同的数据集调用它。当我运行代码时

fit<- survfit(Surv(time, status) ~ sex, data = lung)

allsurv <- function(fit){
ggsurvplot(
fit,
pval = TRUE,
pval.coord = c(200, 0.10), 
conf.int = TRUE,
xlab = "Days",
ggtheme = theme_light(), 
surv.median.line = "hv", 
legend.labs = c("Female","Male"),
legend.title = "",
palette = c("#8C3F4D","#3E606F")) + 
scale_y_continuous(expand = c(0.02, 0.02),breaks = seq(from = 0, to = 1, by = 0.1),labels=percent) + 
scale_x_continuous(expand = c(0.006, 0.006),
                   limits = c(0,366*12), breaks = seq(0, 4392, 100))
}

allsurv(fit)
Run Code Online (Sandbox Code Playgroud)

函数正常绘制在此输入图像描述

但是,当我从函数调用 survfit 时:

fit_all <- …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

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

标签 统计

geopandas ×1

ggplot2 ×1

python ×1

r ×1