[FWTools] individual polygon extents from shapefile

Newman, Michael MNewman at trcsolutions.com
Sun Mar 15 07:24:51 EST 2015


I suggest you switch over to osgeo4w which has the "shapely" python library. Alternatively, "shapely" can be downloaded for a standalone python installation:

>>> import shapely.wkt
>>> p = shapely.wkt.loads("POLYGON ((472710.59239499446 4447191.1177953873,47351
5.91798531159 4447194.0712389778,473512.31589255232 4446393.7382313022,473508.71
421388636 4445593.4045362221,472703.32047291857 4445589.2403627886,471897.926487
74385 4445585.0767617933,471901.59630449413 4446386.621201124,471905.26656266931
4447188.1650511464,472710.59239499446 4447191.1177953873))")
>>> p.bounds # Returns minimum bounding region (minx, miny, maxx, maxy)
(471897.92648774385, 4445585.076761793, 473515.9179853116, 4447194.071238978)

-Mike

From: fwtools-bounces at lists.maptools.org [mailto:fwtools-bounces at lists.maptools.org] On Behalf Of Robert Parker
Sent: Thursday, March 12, 2015 3:22 PM
To: 'fwtools at lists.maptools.org'
Subject: [FWTools] individual polygon extents from shapefile

Hello,

I'm looking for a way to get all individual polygon extents from a shapefile. I'm currently using FWTools 2.4.7 ogrinfo.exe

ogrinfo -al file.shp

I can get the polygon points:

POLYGON ((472710.59239499446 4447191.1177953873,473515.91798531159 4447194.0712389778,473512.31589255232 4446393.7382313022,473508.71421388636 4445593.4045362221,472703.32047291857 4445589.2403627886,471897.92648774385 4445585.0767617933,471901.59630449413 4446386.621201124,471905.26656266931 4447188.1650511464,472710.59239499446 4447191.1177953873))
POLYGON ((471688.54221804038 4418152.8334539989,470880.90043970715 4418138.1126390798,470073.25818921922 4418123.3921459038,470103.17207824974 4419002.9582215408,470133.08692401153 4419882.5239751786,470931.59635465598 4419883.2638069894,471730.10502626933 4419884.0035029622,471709.32331517525 4419018.4185792021,471688.54221804038 4418152.8334539989))

But I really need just the extents. I could take some time to build something to calculate that but I'm hoping I won't have to. If ogrinfo does not do this, is there a tool that can generate extents for each polygon?

Robert

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20150315/753fd460/attachment.htm 


More information about the FWTools mailing list