Python 将点添加到Geopandas对象

Python 将点添加到Geopandas对象,python,pandas,geojson,geopandas,Python,Pandas,Geojson,Geopandas,我的目标是创建某种geojson对象,并使用For循环向其中添加几个点的对象 我错过了什么 from geojson import Feature import pandas as pd import geopandas as gpd # Point((-115.81, 37.24)) # Create a Dataframe with **Schools Centroids** myManipulationObj = pd.DataFrame for schoolNumber in list

我的目标是创建某种geojson对象,并使用For循环向其中添加几个点的对象

我错过了什么

from geojson import Feature
import pandas as pd
import geopandas as gpd
# Point((-115.81, 37.24))

# Create a Dataframe with **Schools Centroids**
myManipulationObj = pd.DataFrame
for schoolNumber in listOfResults:
    myManipulationObj.append(centroids[schoolNumber])

# GDF should be a Beautiful collection (geoDataFrame) of Points
gdf = gpd.GeoDataFrame(myManipulationObj, geometry='Coordinates')
之后,我想使用geopandaswrite()创建一个.geojson文件

有什么帮助吗


(已解决)

我通过以下方式解决了这个问题:

  • 创建python列表(listOfPoints
  • 将点对象用作要素对象的几何图形参数
  • 使用要素列表(带点)创建要素集合
  • 如果有人需要,请留下此处以备将来参考:D

    # Used to get the Index of Schools from the M Model Optimized
    listOfResults = []
    for e in range(numSchools):
        tempObj = m.getVarByName(str(e))
        # If This School is on the Results Optimized
        if(tempObj.x != 0):
            listOfResults.append(int(tempObj.varName))
    
     # Select, from the List Of Results, A set of Centroid Points 
     listOfPoints = []
     for schoolNumber in listOfResults:
         # Attention to the Feature(geometry) from geopandas
         listOfPoints.append(Feature(geometry=centroids[schoolNumber]))
    
     # Creating a FeatureCollection with the Features (Points) manipulated above
     resultCentroids = FeatureCollection(listOfPoints)
    

    你被卡住的步骤是什么?你能不能把问题说得更具体一些,或者提供一个可重复的例子()?谢谢你的时间。我错过了特征(几何=点)的东西。没有注意到我可以使用列表来存储对象,然后将它们转换为featureCollection