[GRASS-user] finding bounding box of polygons

benjamin.ducke at ufg.uni-kiel.de benjamin.ducke at ufg.uni-kiel.de
Mon Oct 1 08:02:46 EDT 2007


Couldn't you dissolve the polygons for each region of interest
into points (using v.type and v.to.points) and then just calculate
the convex hull (v.hull) for the result points cloud and take that as
your region envelope?

Benjamin

> What I'm trying to do is get the bounding boxes around each country in the
> world, so I can create a region file for each. This would make doing
> graphics by country much easier. For example, we have constructed a raster
> at 1 km resolution of the number of amphibian species ranges at each
> location for the whole world. There are times when I just want, say the
> counts in India. We have a nice little script that generates a png
> automatically based on a region file. It would be nice to have such a file
> for each country in the world.
>
> If I read your example correctly, ogrinfo gives me the box around the
> entire
> shapefile, not individual polygons. I suppose an alternative would be to
> somehow export each country polygon as a separate shapefile and get the
> region of that.
>
> Any tips appreciated.
> Thanks, Jerry
>
> -----Original Message-----
> From: Jose Gomez-Dans [mailto:jgomezdans at gmail.com]
> Sent: Thursday, September 27, 2007 4:59 PM
> To: Jerry Nelson
> Cc: grassuser at grass.itc.it
> Subject: Re: [GRASS-user] finding bounding box of polygons
>
> Hi,
>
> On 9/27/07, Jerry Nelson <gnelson at uiuc.edu> wrote:
>> I'd like to construct a list of the bounding box coordinates for all the
>> polygons in a vector file. I could find nothing in the manual that
>> seemed
> to
>> do that. Any tips appreciated.
>
> Not a GRASS-centric response :), but if it is just a box you're after,
> you can probably use ogrinfo for this, as it gives you the Extent of
> your file. As an example, using it with the world.shp Shapefile
> results in:
> $ ogrinfo -so python/world.shp world
> INFO: Open of `python/world.shp'
>       using driver `ESRI Shapefile' successful.
>
> Layer name: world
> Geometry: Polygon
> Feature Count: 244
> Extent: (-180.000000, -89.900000) - (180.000000, 83.674733)
> Layer SRS WKT:
> (unknown)
> NAME: String (40.0)
> CAPITAL: String (64.0)
> APPROX: Real (15.0)
> AREA: Real (20.15)
> SOURCETHM: String (16.0)
>
> Hope that helps
>
> _______________________________________________
> grassuser mailing list
> grassuser at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grassuser
>
>





More information about the grass-user mailing list