postGIS 表在用 geopandas 写入后不填充

问题描述 投票:0回答:0

我有一个类方法 poligons_to_postgis 获取形状多边形列表,将它们包含在“几何”列中,然后创建地理数据框并写入 postgreSQL + postGIS 扩展。

import shapely
import time
import geopy

from shapely.geometry import Polygon
from shapely.ops import transform
import pandas as pd
import geopandas as gpd
from pyproj import CRS
import sqlalchemy

class Geo:
    def __init__(self):
        self.constring = "postgresql+psycopg2://postgres:[email protected]/mydb"
        self.dbEngine = sqlalchemy.create_engine(self.constring, connect_args={'connect_timeout': 10}, echo=False)

    

    def poligons_to_postgis(self,table_name,if_exists,schema,index,chunksize,geo_list=[]):
            
            geo_list = geo_list
            crs = CRS.from_epsg(4326)
            gdf = gpd.GeoDataFrame(geometry = geo_list, crs = crs)
    
            gdf.to_postgis(name=table_name,con=self.dbEngine,schema = schema, if_exists =if_exists,
                           index = index, chunksize = chunksize) 

我已经检查了 postGIS 的安装,一切似乎都按照官方网站正确安装了。

将地理数据写入 postGIS 后,我没有收到任何错误,但是当我检查 pgAdmin 时,包含“几何”列的表格是空白的。

postgis geopandas
© www.soinside.com 2019 - 2024. All rights reserved.