python求一条线的长度_我如何获取创建一条线的点列表,并将它们向内延伸到一定长度的多边形中?...

GDAL/OGR是另一种选择。最终你要做的是一个缓冲区。要向外展开多边形形状,请使用缓冲区距离为正的缓冲区,向内的缓冲区距离为负。下面是一个使用shapefile的简单示例。不知道你的数据是什么格式的,但是如果GDAL/OGR不能读取它,我会很惊讶。在import osgeo.ogr

# using ESRI Shape file in this example but there are a number

# of different files this lib supports: http://www.gdal.org/ogr/ogr_formats.html

driver = osgeo.ogr.GetDriverByName('ESRI Shapefile')

osgeo.ogr.UseExceptions()

# Create a data source using the driver...

dataSource = driver.Open("/home/user1/data.shp")

# Get the layer

lyr = dataSource.GetLayer()

# Select the feature in this case using an attribute query

lyr.SetAttributeFilter("column = 'value'")

# verify that you have a feature selected

print 'features in layer:', lyr.GetFeatureCount()

# get the firest feature from the layer

feature = lyr.GetNextFeature()

# get the geometry from the feature

geom = feature.GetGeometryRef()

# perform a 100 unit buffer, not sure what units the coordinates of the

# the data you have are in.

bufferGeom = geom.buffer(100)

# bufferGeom is a geometry object, which is described here:

#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值