1

After reading a shapefile using the following: Using Fiona

y_data = fiona.open("example.shp")
y_data.schema

and I came across how to save it as a mat file by doing:

scipy.io.savemat("example_save.mat", y_data)

The following error showed up: TypeError: 'int' object is not subscriptable

Any hints?

Hamid
  • 41
  • 6

1 Answers1

1

I tried it with geopandas, and it seems to work. Check this out.

import geopandas as gpd
from scipy.io import loadmat


# LOAD shapefile using gpd
gdf=gpd.read_file(r"path\to_your_data.shp")


#SAVE the data
scipy.io.savemat("path\to_your_data.mat", gdf)


# LOAD .mat file
y_data = loadmat('path\to_your_data.mat')
Rishi
  • 66
  • 1
  • 9