Pythonshapefile。Writer方法代码示例
本文整理汇总了Python中 shapefile.Writer方法 的典型用法代码示例。如果您正苦于以下问题:Python shapefile.Writer方法的具体用法?Python shapefile.Writer怎么用?Python shapefile.Writer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在 类 shapefile 的用法示例。
在下文中一共展示了 shapefile.Writer方法 的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。 示例1: __init__# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def __init__(self, filename=None, shapeType=1, hasShx=True): self.filename = filename self.hasShx = hasShx # Count records for metadata self.count = 0 # Maximum number of records before disk flush self.max = 1000 self.started = False self.minx = 0 self.miny = 0 self.maxx = 0 self.maxy = 0 self.numRecs = 0 self.tmpShp = cStringIO.StringIO() if self.hasShx: self.tmpShx = cStringIO.StringIO() self.tmpDbf = cStringIO.StringIO() self.shp = open("%s.shp" % self.filename, "wb") if self.hasShx: self.shx = open("%s.shx" % self.filename, "wb") self.dbf = open("%s.dbf" % self.filename, "wb") self.dbfHdrLen = 0 self.w = shapefile.Writer(shapeType) 示例2: _point_file# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def _point_file(test_file): with shapefile.Writer(test_file, shapefile.POINT) as shp: shp.field("name", "C") shp.point(0, 0) shp.record("point1") shp.point(0, 1) shp.record("point2") shp.point(1, 1) shp.record("point3") shp.point(1, 0) shp.record("point4") 示例3: _polygon_file# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def _polygon_file(test_file): with shapefile.Writer(test_file, shapefile.POLYGON) as shp: shp.field("name", "C") shp.poly([ [[.25, -.25], [.25, .25], [.75, .25], [.75, -.25]], ]) shp.record("polygon1") shp.poly([ [[.25, .75], [.75, .75], [.5, 1.25]] ]) shp.record("polygon2") 示例4: _polyline_file# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def _polyline_file(test_file): with shapefile.Writer(test_file, shapefile.POLYLINE) as shp: shp.field("name", "C") n = 5 x = np.repeat(np.linspace(0, 1, n), 2) y = np.tile([0.375, 0.625], n) shp.line([list(zip(x, y))]) shp.record("line1") 示例5: test_bad_points# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def test_bad_points(): shp = BytesIO() shx = BytesIO() dbf = BytesIO() w = shapefile.Writer(shp=shp, shx=shx, dbf=dbf) w.shapeType = 3 w.field("spam", "N") w.line([[[5, 5], [10, 10]]]) w.record(37) w.line([[[5, 0], [5, 5]]]) w.record(100) w.line([[[5, 5], [0, 10]]]) w.record(239) w.close() # pass a line shapefile here insted. p_shp = BytesIO() p_shx = BytesIO() p_dbf = BytesIO() p_w = shapefile.Writer(shp=p_shp, shx=p_shx, dbf=p_dbf) w.shapeType = 3 p_w.field("spam", "N") p_w.line([[[5, 5], [10, 10]]]) p_w.record(37) p_w.line([[[5, 0], [5, 5]]]) p_w.record(100) p_w.line([[[5, 5], [0, 10]]]) p_w.record(239) p_w.close() with raises(ValueError): read_shapefile(shp, dbf=dbf, points_shapefile=p_shp, points_dbf=p_dbf) 示例6: test_points_but_too_far# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def test_points_but_too_far(): shp = BytesIO() shx = BytesIO() dbf = BytesIO() w = shapefile.Writer(shp=shp, shx=shx, dbf=dbf) w.shapeType = 3 w.field("spam", "N") w.line([[[5, 5], [10, 10]]]) w.record(37) w.line([[[5, 0], [5, 5]]]) w.record(100) w.line([[[5, 5], [0, 10]]]) w.record(239) w.close() # make a p_shp = BytesIO() p_shx = BytesIO() p_dbf = BytesIO() p_w = shapefile.Writer(shp=p_shp, shx=p_shx, dbf=p_dbf) p_w.shapeType = 1 p_w.field("eggs", "N") p_w.point(5, 0) p_w.record(2) p_w.point(5, 5) p_w.record(4) p_w.point(0, 10) p_w.record(8) p_w.point(12, 10) p_w.record(6) p_w.close() with raises(ValueError): read_shapefile(shp, dbf=dbf, points_shapefile=p_shp, points_dbf=p_dbf) 示例7: test_points_but_not_one_one# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def test_points_but_not_one_one(): shp = BytesIO() shx = BytesIO() dbf = BytesIO() w = shapefile.Writer(shp=shp, shx=shx, dbf=dbf) w.shapeType = 3 w.field("spam", "N") w.line([[[5, 5], [10, 10]]]) w.record(37) w.line([[[5, 0], [5, 5]]]) w.record(100) w.line([[[5, 5], [0, 10]]]) w.record(239) w.close() # make a p_shp = BytesIO() p_shx = BytesIO() p_dbf = BytesIO() p_w = shapefile.Writer(shp=p_shp, shx=p_shx, dbf=p_dbf) p_w.shapeType = 1 p_w.field("eggs", "N") p_w.point(5, 0) p_w.record(2) p_w.point(5, 5) p_w.record(4) p_w.point(0, 10) p_w.record(8) p_w.point(10, 10) p_w.record(6) p_w.point(10, 10) p_w.record(7) p_w.close() with raises(ValueError): read_shapefile(shp, dbf=dbf, points_shapefile=p_shp, points_dbf=p_dbf) 示例8: test_points_but_one_missing# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def test_points_but_one_missing(): shp = BytesIO() shx = BytesIO() dbf = BytesIO() w = shapefile.Writer(shp=shp, shx=shx, dbf=dbf) w.shapeType = 3 w.field("spam", "N") w.line([[[5, 5], [10, 10]]]) w.record(37) w.line([[[5, 0], [5, 5]]]) w.record(100) w.line([[[5, 5], [0, 10]]]) w.record(239) w.close() # make a p_shp = BytesIO() p_shx = BytesIO() p_dbf = BytesIO() p_w = shapefile.Writer(shp=p_shp, shx=p_shx, dbf=p_dbf) p_w.shapeType = 1 p_w.field("eggs", "N") p_w.point(5, 0) p_w.record(2) p_w.point(5, 5) p_w.record(4) p_w.point(0, 10) p_w.record(8) p_w.close() with raises(ValueError): read_shapefile(shp, dbf=dbf, points_shapefile=p_shp, points_dbf=p_dbf) 示例9: write_shapefile# 需要导入模块: import shapefile [as 别名] # 或者: from shapefile import Writer [as 别名] def write_shapefile(df, filename, geomtype="line", prj=None): """ create a shapefile given a pandas Dataframe that has coordinate data in a column called "coords". """ import shapefile df["Name"] = df.index # create a shp file writer object of geom type "point" if geomtype == "point": w = shapefile.Writer(shapefile.POINT) elif geomtype == "line": w = shapefile.Writer(shapefile.POLYLINE) elif geomtype == "polygon": w = shapefile.Writer(shapefile.POLYGON) # use the helper mode to ensure the # of records equals the # of shapes # (shapefile are made up of shapes and records, and need both to be valid) w.autoBalance = 1 # add the fields for fieldname in df.columns: w.field(fieldname, "C") for k, row in df.iterrows(): w.record(*row.tolist()) w.line(parts=[row.coords]) w.save(filename) # add projection data to the shapefile, if prj is None: # if not sepcified, the default, projection is used (PA StatePlane) prj = os.path.join(ROOT_DIR, "swmmio/defs/default.prj") prj_filepath = os.path.splitext(filename)[0] + ".prj" shutil.copy(prj, prj_filepath)
小R角真全面屏各种黑科技,小米MIX4真的回来了8月份,小米有款屏下摄像头旗舰机发布,至于是不是MIX之前还不确定,不过从今天数码闲聊站曝光的这张新机钢化膜看,基本可以确定,这就是MIX。真全面屏窄边框小R角,不按套路的一点,它
极米科技引领科技前沿,极米H3S强大超前极米H3S是极米科技于2021年3月16日推出的一款拥有1080P全高清的智能投影。据了解,该产品在预售期间就获得了市场较高关注度,首批现货一经发售便迅速售罄,深受用户的喜爱。能够
实力圈粉,揭秘王者荣耀的5V5团队作战哲学一大清早看到玩家们吵起来了。其实大可不必,两个游戏都有自己的玩家群体,玩好自己的游戏就是了,两个游戏都是好游戏,为什么要争吵呢?营销号也不要总是为了流量踩一捧一了。在团队竞技手游中
8个神奇的小网站,原地开启新世界大门谁能知道我网上冲浪的时候,都在收藏夹里收藏了一堆什么奇奇怪怪的东西狗头今天就把这些奇奇怪怪,但又迷之有趣的网站分享给大家,一起来看看吧1。任意门打开这个网站,点LETSGO会被传送
16个宝藏小众网站,带你看见更大的创意世界我从我收藏的一大堆网站中,整理出了这16个我根本离不开的网站!一各种大全网站1。配色大全dopelycolors一个神奇的配色网站,一打开就是花里胡哨的。点最下面的骰子,就可以随机
9个暗藏惊险与刺激的网站,叩开你新世界的大门这9个暗藏惊险与刺激的小众网站,绝对能叩开你新世界的大门!1外表平平的3D作品合集这个网站乍一看平平无奇,就是一些图片展示嘛,但是当你随意点击一个图片进入后,哇靠惊呆了,全都是动态
特朗普政府将小米列入黑名单,称其为中国军事公司虽然任期只有六天,但是特朗普政府已决定将另一家中国电子巨头放在黑名单上世界第三大手机制造商小米。美国国防部现将小米指定为中国军事公司,这意味着它现在容易受到特朗普禁止美国投资此类公
特朗普政府将小米列入黑名单,小米港股开盘暴跌11任期只有六天,但是特朗普政府已决定将另一家中国电子巨头放在黑名单上世界第三大手机制造商小米。美国国防部现将小米指定为中国军事公司,这意味着它现在容易受到特朗普禁止美国投资此类公司的
LCD党等到了,RedmiK30s已入网,定价比预期更低前段时间小米海外发布的小米10T的国行版,在今天正式入网,与猜测一样给到了Redmi,至于命名是K30S还是K30T暂不确定,不过从配置来看这款手机定位是与K30Ultra一个级别
3299起,聊聊小米10S优势在哪小米10的基础配置,小米10Pro的双扬声器小米11的配色及哈曼卡顿音效小米10Ultra的ID设计,再加上骁龙870处理器,可以说小米10S是将历代好评的配置全部汇聚在一起,那么
Windows电脑有哪些必装软件?这10款电脑神器,神了推荐10款免安装的电脑神器!免费看片儿官方电子书一键清理电脑快速检索文件每一款都强大的不得了!一便携版免安装工具1电脑清理工具GlaryUtilities便携版免安装!一款简洁但强