I'm trying to avoid saving a matplotlib figure to file, just to recall it and preprocess the image for a tensorflow model. I saw this which made me optimistic, unfortunately, geopandas has an inbuilt plotting function. I am wondering if anyone has any ideas?
Ideally, I would like a numPy image array of the intensity values of all points
data = gp.read_file('/path_to.shp')
fig = plt.figure()
ax = fig.add_subplot(111)
lines = data.plot(ax=ax)
print(lines[0].get_data())
Unfortunately, I get the error:
Traceback (most recent call last):
File "GIS2img.py", line 108, in <module>
print(lines[0].get_data())
TypeError: 'AxesSubplot' object does not support indexing
I would like to get RGB image data in an array for each figure
I would appreciate any help, thanks
Edit: Clarified question
Solved!
Thanks to ImportanceOfBeingErnest for the help.
You can draw to a canvas using: fig.canvas.draw()
and then retrieve that image using np.array(fig.canvas.renderer._renderer)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.