1
import numpy as np
import pandas as pd

import shapefile as shp

import matplotlib.pyplot as plt
import seaborn as sns
shp_path = 'seoul\seoul.shp'
sf = shp.Reader(shp_path)
sf.records()[1]

最后我得到了这个错误 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte

我想怎么解决这个问题

4

1 回答 1

0

您需要尝试不同的编码选项。该文档显示了一种为 shapefile 的方法 Reader 执行此操作的方法:

shp_path = "Barrios_Cali/Barrios.shp"
sf = shp.Reader(shp_path, encoding="latin1") # Notice the encoding option

所以继续寻找 .shp 可能的编码类型并尝试一下。

于 2020-07-23T20:19:44.260 回答