我有一个由各个州组成的美国多边形shapefile作为它们的属性值。此外,我还使用数组来存储我也感兴趣的点事件的纬度和经度值。本质上,我想‘空间连接’点和多边形(或执行检查,以查看每个点所在的多边形,即每个点所在的状态),然后将每个状态中的点数相加,以找出哪个状态具有最多数量的“事件”。
我相信伪代码应该是这样的:
Read in US.shp
Read in lat/lon points of events
Loop through each state in the shapefile and find number of points in each state
print 'H
我有两个大的GeoDataFrame:
其中一个来自于一个shapefile,其中每个多边形都有一个名为'asapp‘的浮动值。
第二个是3x3米的渔网网格的质心和一个列'asapp‘的零。
我需要的是填充第二个基地的'asapp‘,其中质心在第一个多边形内。
下面的代码可以做到这一点,但速度很低的是每秒15个多边形(其中一个最小的shapefile有更多的20000个多边形)。
# fishnet_grid is a dict created by GDAL with a raster with 3m pixel size
cells_in_wsg = np.arra
我试图通过使用属性联接来合并熊猫数据和地质公园。我使用的是一个美国县形状文件( first response)和一个csv文件(是第一个Excel格式,然后保存为csv)。使用FIPS连接数据后,我尝试打印新的geodataframe,但只打印上面空的GeoDataFrame消息的标题。这是我正在使用的代码
from matplotlib import pyplot as plt
import csv
import numpy as np
import datetime
import pandas as pd
import geopandas as gpd
import csv
from s
使用以前的答案(merci Booboo),代码的想法是:
from multiprocessing import Pool
def worker_1(x, y, z):
...
t = zip(list_of_Polygon,list_of_Point,column_Point)
return t
def collected_result(t):
x, y, z = t # unpack
save_shp("polys.shp",x)
save_shp("point.shp",y,z)
if __name__ ==
Shapefile数据:整个世界(和5个行政区)来自
import geopandas as gpd
World = gpd.read_file("~/gadm36.shp")
World=World[['NAME_0','NAME_1','NAME_2','geometry']] #Keep only 3 columns
World.head()
在这个GeoDataFrame中,我有60列 (NAME_:对于国家名称,NAME_1表示该区域,.)
目前,我有兴趣研究我在德国的网站用户数。
German
我正在尝试合并两个地理数据帧(想看看每个点在哪个多边形中)。
下面的代码首先给我一个警告("CRS does not match!"),然后是一个错误("RTreeError: Coordinates must not have minimums more than maximums")。
这里面到底出了什么问题?CRS是坐标系吗?如果是这样,为什么它们不是以相同的方式加载的?
import geopandas as gpd
from shapely.geometry import Point, mapping,shape
from geopandas impo
我在.xyz、.txt或.csv扩展名文件中读取以下python代码,并将其转换为头为X、Y和Z的shapefile
import pandas as pd
import os
import geopandas as gpd
from shapely.geometry import Point #convert to 3D GeoPandas GeoDataFrame
input_file = "C:/test/input_xyz.xyz"
file_extension = os.path.splitext(input_file)[-1].lower()
if file_
我正在玩下面的shapefile,它可以在here on Github上找到。我不打算包含输出,但下面是将其作为geopandas df读取并绘制shapefile的代码。 states = geopandas.read_file('usa-states-census-2014.shp')
states.head()
states.plot() 我还有以下df,它是可以在here on Kaggle中找到的USArrests数据集。 我尝试做的是合并这两个数据集,这样我就可以在USArrests中用要素的色彩映射表绘制shapefile。我运行了以下代码来合并数据集。 df