I have a shapefile that looks like this on mapshaper:
But when I tried to plot it in pandas with the following code
police = gpd.read_file('srilanka_policestations')
police.plot()
jupyter notebook gives me an error message saying "AttributeError: 'str' object has no attribute 'type'".
I'm not sure what's wrong. I tried to plot the GeoPandas dataset "naturalearth_cities", and it works fine. See below:
The geo-dataframe reads fine in pandas, but it wouldn't plot:
Any help is much, much appreciated. Thank you all!
police.dtypes
? And also what is the output oftype(police.loc[0,'geometry'])
– Bob Haffnerpolice.geometry
works? also try to add the file format, e.g. 'serilanka_policestations.shp'. – Alzpolice.dtypes
is object for everything (including geometry). Latitude and Longitude are both float64. The output oftype(police.loc[0,'geometry'])
is string. – user7999601police.geometry
doesn't work either, and neither does adding a ".shp" after the file name. :( – user7999601type(police.loc[0,'geometry'])
shouldn't be string, but should be a shapely.geometry.Point type. So something went wrong with reading that file. Are you able to share the shapefile? And you can also open an issue at github.com/geopandas/geopandas – joris