Karthik
Karthik

Reputation: 69

How to save a shapely object as an image

I have a shapely object in python. It is the outline of the map of the US. How do I save it as an EPS or PDF?

Upvotes: 4

Views: 431

Answers (1)

Bera
Bera

Reputation: 1949

I have a multipolygon object:

import matplotlib.pyplot as plt
from shapely.plotting import plot_polygon

print(type(multipolygon))
#<class 'shapely.geometry.multipolygon.MultiPolygon'>

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,5))
plot_polygon(polygon=multipolygon, ax=ax, add_points=False, color="green")
fig.savefig(r"C:\Users\bera\Desktop\gistest\usa.pdf", bbox_inches='tight')

The pdf: enter image description here

Upvotes: 0

Related Questions