0

I want to visualize the shapefile data about Iran accidents in googlecolab, but when I try to read it as Geopaandas data frame the plot function is not working correctly, would you please advise me on this issue,

import pandas as pd
import matplotlib.pyplot as plt
import geopandas as gpd
gdf = gpd.read_file('/content/accidents.shp',crs=4326)

gdf = gdf.fillna(value=0)
fig, ax = plt.subplots(1, figsize=(20, 20))
ax.axis('off')
ax.set_title('accidents in Iran',
             fontdict={'fontsize': '15', 'fontweight' : '3'})
fig = gdf.plot(column='tedad_jarh', cmap='RdYlGn', linewidth=0.5, ax=ax, edgecolor='0.2',legend=True)

input: input

the error:

/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py:2450: RuntimeWarning:

overflow encountered in double_scalars

WARNING:matplotlib.text:posx and posy should be finite values
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/ipykernel/pylab/backend_inline.py in show(close, block)
     41             display(
     42                 figure_manager.canvas.figure,
---> 43                 metadata=_fetch_figure_metadata(figure_manager.canvas.figure)
     44             )
     45     finally:

------------------------------------------------------------
/usr/local/lib/python3.7/dist-packages/matplotlib/axis.py in get_tick_space(self)
   2193         size = tick.label1.get_size() * 3
   2194         if size > 0:
-> 2195             return int(np.floor(length / size))
   2196         else:
   2197             return 2**31 - 1

**ValueError: cannot convert float NaN to integer**
fatane
  • 5
  • 7
  • please include the [full traceback](//realpython.com/python-traceback) (everything from `Traceback (most recent call last)` to `XXXXError: message`) when asking about errors. This appears to be a warning, not an error - if it's an error, we can't see it. thanks! – Michael Delgado Nov 17 '22 at 23:46
  • Hi Michael, I add traceback too, I'm a beginner sorry for the Trivial mistake, and BTW thanks for answering me. – fatane Nov 18 '22 at 05:53
  • Thanks for the edits! Don’t worry about it - I’m just trying to point you in the right direction :) hope you get a good answer! – Michael Delgado Nov 18 '22 at 07:01

0 Answers0