The following command
ogrinfo -al -where 'CNTRY_NAME=GERMANY' SubNationalboundaries.shp
gets me all the attributes for Germany in the shapefile. This includes a POLYGON attribute for each subnational unit with a bunch of lat-long values, but does not, as far as I can tell, get me a bounding box.
Any other suggestions appreciated.
Jerry
---- Original message ----
Date: Sun, 30 Sep 2007 16:56:25 -0700
From: "John C. Tull" <john.tull@wildnevada.org>
Subject: Re: [GRASS-user] finding bounding box of polygons
To: Jerry Nelson <gnelson@uiuc.edu>You can run a query on ogrinfo with -where, but I am not certain if
the bounds will reflect the query. I would suspect as much.http://www.gdal.org/ogr/ogrinfo.html
Cheers,
JohnOn Sep 30, 2007, at 3:19 PM, Jerry Nelson wrote:
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@gmail.com]
Sent: Thursday, September 27, 2007 4:59 PM
To: Jerry Nelson
Cc: grassuser@grass.itc.it
Subject: Re: [GRASS-user] finding bounding box of polygonsHi,
On 9/27/07, Jerry Nelson <gnelson@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
seemedto
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@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser
Gerald Nelson
Professor, Dept. of Agricultural and Consumer Economics
University of Illinois, Urbana-Champaign
office: 217-333-6465
cell: 217-390-7888
315 Mumford Hall
1301 W. Gregory
Urbana, IL 61801