【问题标题】:reading shp file with pyshp jupyter使用 pyshp jupyter 读取 shp 文件
【发布时间】:2020-02-08 14:03:02
【问题描述】:
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”编解码器无法解码位置 0 的字节 0xba:无效的起始字节

我想怎么解决这个问题

【问题讨论】:

  • 你能添加一个seoul.shp的例子吗?
  • print(sf.fields[1]) ['emd_cd', 'C', 10, 0]
  • 有sf.records里面有首尔的记录数据
  • 有 sf.shapes() 包含首尔行政区的多边形

标签: record shapefile pyshp


【解决方案1】:

您需要尝试不同的编码选项。 documentation 为 shapefile 的方法 Reader 显示了一种方法:

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

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

【讨论】:

    猜你喜欢
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-24
    • 2017-09-19
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多