首页 > 解决方案 > 从 ox.projection.project_gdf(city,yerevan.crs) 获取 b'在初始化列表中没有参数'

问题描述

试图获取我正在研究的国家/地区的地图,但得到b'no arguments in initialization list'错误。代码如下:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import geopandas as gpd
import osmnx as ox
from descartes import PolygonPatch
from shapely.geometry import Point, LineString, Polygon,  MultiPolygon
import os
os.environ["PROJ_LIB"] = "C:\\Users\\torre\\Desktop\\Yerevan shapefile\\Yerevan.shp"

import pyproj as project


#Load Yerevan city from openstreetmap using osmnx api

city = ox.gdf_from_place("Yerevan, Armenia",which_result=2)
print(city.crs)
meta = ox.projection.project_gdf(city,yerevan.crs)
#get error of b'no arguments in initialization list' fig, ax = ox.plot_shape(city)
print(city.crs)

标签: python-3.x

解决方案


您没有提供可重现的代码片段,因此您在这里尝试做什么有点不清楚。但是以下用于下载/投影 Yerevan 的可重现代码片段在 OSMnx 的当前版本 (v0.15.1) 中运行良好:

import osmnx as ox
city = ox.geocode_to_gdf('Yerevan, Armenia', which_result=2)
print(city.crs) # prints epsg:4326
city_proj = ox.project_gdf(city, to_crs='epsg:2935')
print(city_proj.crs) # prints epsg:2935

推荐阅读