Geopandas Coloring of concatenated shapefiles

Viewed 188

I am trying to set a different color for map objects of a concatenated set of geodataframes (instead of a single color) using GEOPANDAS PYTHON.

I've tried conventional ways to set facecolor and cmap however it did not work for concatenated geodataframes.

I want to get different color shapes for gdf and boundaries (red and blue for example) instead of a single color which is what I'm currently getting.

here is the code:

import pandas as pd
import geopandas as gpd
from geopandas import GeoDataFrame
import matplotlib.pyplot as plt
import pandas
from shapely import wkt

#Converting an excel file into a geodataframe

Shape=pd.read_excel('C:/Users/user/OneDrive/documents/Excel .xlsx')
print(Shape)
Shape['geometry'] = Shape['geometry'].apply(wkt.loads)
gdf = gpd.GeoDataFrame(Shape, geometry='geometry')
gdf.plot()

#reading another geodataframe
Boundaries=gpd.read_file('C:/Users/user/Desktop/Boundaries/eez_v10.shp')

#concatenating  Boundaries and gdfgeodataframes
map=pd.concat([gdf,Boundaries], sort=False)
ax=map.plot(figsize=(20,20))
plt.xlim([47,60])
plt.ylim([22,32])
plt.show()
1 Answers

You don't need to do concat, just plot both df to the same axis.

gdf = gpd.GeoDataFrame(Shape, geometry='geometry')
Boundaries=gpd.read_file('C:/Users/user/Desktop/Boundaries/eez_v10.shp')

ax = gdf.plot(color='blue')
Boundaries.plot(ax=ax, color='red')
Related