def _load_test_gdf(self, fname): fname = os.path.join(BASE_FOLDER, fname) df = read_csv(fname, dtype={ 'id': np.int64, 'geom': object, 'quadkey': object }) gdf = GeoDataFrame(df, crs='epsg:4326') set_geometry(gdf, 'geom', inplace=True) return gdf
def test_column_info_basic_troubled_names(self): gdf = GeoDataFrame( [[1, 'POINT (1 1)', 'fake_geom']], columns=['cartodb_id', 'the_geom', 'the_geom_webmercator']) set_geometry(gdf, 'the_geom', inplace=True) dataframe_columns_info = get_dataframe_columns_info(gdf) assert dataframe_columns_info == [ ColumnInfo('cartodb_id', 'cartodb_id', 'bigint', False), ColumnInfo('the_geom', 'the_geom', 'geometry(Point, 4326)', True) ]
def test_column_info_with_geom(self): gdf = GeoDataFrame( [['Gran Vía 46', 'Madrid', 'POINT (0 0)'], ['Ebro 1', 'Sevilla', 'POINT (1 1)']], columns=['Address', 'City', 'the_geom']) set_geometry(gdf, 'the_geom', inplace=True) dataframe_columns_info = get_dataframe_columns_info(gdf) assert dataframe_columns_info == [ ColumnInfo('Address', 'address', 'text', False), ColumnInfo('City', 'city', 'text', False), ColumnInfo('the_geom', 'the_geom', 'geometry(Point, 4326)', True) ]
def test_column_info_geometry_troubled_names(self): gdf = GeoDataFrame( [['POINT (0 0)', 'POINT (1 1)', 'POINT (2 2)']], columns=['Geom', 'the_geom', 'g-e-o-m-e-t-r-y']) set_geometry(gdf, 'the_geom', inplace=True) dataframe_columns_info = get_dataframe_columns_info(gdf) assert dataframe_columns_info == [ ColumnInfo('Geom', 'geom', 'text', False), ColumnInfo('the_geom', 'the_geom', 'geometry(Point, 4326)', True), ColumnInfo('g-e-o-m-e-t-r-y', 'g_e_o_m_e_t_r_y', 'text', False) ]