[Python] Converting a pandas series of centroids into points that can be mapped in geopandas

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm new to geopandas and am having trouble plotting the list of centroids seen below. I pulled these from a much larger/more complicated CSV file. Converting the larger CSV to a geodataframe and trying to plot that didn't work, so now I'm just trying to plot these points as their own geodataframe.

    For those interested, these points represent the point sources of greenhouse gas emissions in the state of Michigan. The Michigan .shp basemap plots just fine.

    The first five lines of the data:

    Centroid
    0 {'Geometry': [-83.23064676125937, 42.33149724073557], 'SRID': 4326}
    1 {'Geometry': [-82.4951, 42.7741], 'SRID': 4326}
    2 {'Geometry': [-83.27446123221068, 42.54121682538758], 'SRID': 4326}
    3 {'Geometry': [-86.2007, 42.9103], 'SRID': 4326}
    4 {'Geometry': [-82.4719, 42.7642], 'SRID': 4326}



    I tried this:

    import pandas as pd
    import geopandas as gpd

    mi_sources_centroids = gpd.GeoDataFrame(mi_sources_gdf["Centroid"])
    fig, ax = plt.subplots(figsize=(13,13))
    mi_sources_centroids.plot(ax=ax, color="red")



    But there is always the following error: "TypeError: no numeric data to plot."

    Any tips would be much appreciated.

    Continue reading...

Compartilhe esta Página