在geopandas数据框图中旋转或交换x-y轴

时间:2018-02-26 23:37:03

标签: python matplotlib shapefile geopandas

我刚接触到geopandas数据帧,我得到了一个GeoDataframe,坐标使得情节非常大。我打算将绘图旋转90°或更改每个多边形的x-y坐标。我还没有实现任何这些选择。

我还想把其他GeoDataframe的传说(这个带点数),但我担心旋转时,图例也会旋转(如果......可能)。

到目前为止,代码如下所示:

from shapely.geometry import Point
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt

# Import data
Zones = gpd.read_file('myfile_with_polygons.shp')
Barr = pd.read_csv('myfile_with_LongLat_Coordinates.csv')

# Create GeoDataFrame from Pandas Dataframe
geometry = [Point(xy) for xy in zip(Barr.Longitud, Barr.Latitud)]
Barr = gpd.GeoDataFrame(Barr, crs={'init': 'epsg:4326'}, geometry=geometry)

# plots
f, ax = plt.subplots(1)
ax.set_title('such title')
Zones.plot(ax=ax, facecolor='lightgray', edgecolor='gray')
Barr.plot(ax=ax, facecolor='green', edgecolor='gray')
plt.axis('scaled')

plt.show()

修改 myfile_with_LongLat_Coordinates.csv文件的格式:

Name,Longitud,Latitud
My Name,-72.5,-30.7
Such Wow,-69.47,-21.93
Very Name,-71.92,-18.53
...

GeoDataFrame Zones的格式为:

    Zone_name    geometry
0       ZoneA    (POLYGON ((-541621.6191 1675026.112, -541621.1...
1       ZoneB    POLYGON ((636925.4216666555 6552020.6959, 3679...
2       ZoneC    (POLYGON ((226598.6520999998 3110548.9596, 276...
....

0 个答案:

没有答案