我想使用 pyshp 在特定的邮政编码制表区域 shapefile 中生成 1000 个随机点。我的代码是:
import shapefile
zctashape = shapefile.Reader('C:/mypath/tl_2019_us_zcta510.shp')
shapefile_len = len(zctashape.shapes())
#identify the index for zcta 84049 and designate number of points.
zcta_to_use = '84049'
pointcount = 1000
for i in range(0,shapefile_len):
if zctashape.record(i)[1] == zcta_to_use:
record_i=i
break
record_i
我该如何从这里开始?如果这是基本的,我深表歉意,我主要是 R 用户,使用该语言非常容易。从https://www.census.gov/cgi-bin/geo/shapefiles/index.php?year=2019&layergroup=ZIP+Code+Tabulation+Areas下载的 Shapefile