2 Star 4 Fork 3

汉塞大叔/Geospatial_Analysis_By_Python

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
1.3 读取记录.py 807 Bytes
Copy Edit Raw Blame History
汉塞大叔 authored 2021-01-20 19:53 +08:00 . 上传 py
import shapefile
r = shapefile.Reader("shapefiles/NYC_MUSEUMS/NYC_MUSEUMS_GEO")
# 1.读取属性记录
rec = r.record(3)
print(rec[1:3])
# 2.同时读取几何图形和记录
"""
shapeRecord()和shapeRecords()方法可做到这一点。调用shapeRecords()方法将
返回所有形状的几何形状和属性,作为ShapeRecord对象的列表。每个ShapeRecord实例都
有一个“ shape”和“ record”属性。shape属性是Shape对象,如第一部分“阅读几何”中所
述。记录属性是一个类似列表的对象,其中包含字段值,如“读取记录”部分所述。
"""
shapeRecs = r.shapeRecords()
print(shapeRecs[3].record[1:3]) # 结果与上面一致
print(shapeRecs[3].shape.shapeTypeName)
print(shapeRecs[3].shape.points)
r.close()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/fengfeng233/geospatial_-analysis_-by_-python.git
git@gitee.com:fengfeng233/geospatial_-analysis_-by_-python.git
fengfeng233
geospatial_-analysis_-by_-python
Geospatial_Analysis_By_Python
master

Search