[Gdal-dev] extent of a file/map [2]
Fulko van Westrenen
Fulko.vanWestrenen at dto.tudelft.nl
Wed Jul 28 13:33:00 EDT 2004
On Tue, Jul 27, 2004 at 04:12:18PM -0400, Frank Warmerdam wrote:
> Fulko van Westrenen wrote:
> >Hello,
> >
> >I have some python code to retrieve layer information from a
> >s57 file. This works nice, but I would like to know the area
> >covered by a file.
> >
> >The documentation suggests the use of GetExtent, but that is
> >for a layer. What is the proper way to get the extent of a file?
>
> Fulko,
>
> In general I think you would need to merge the extents of all the layers.
> But I'm pretty sure that all S-57 layers return the extent of the whole
> datasource so just using the extent of the first layer should be fine.
Frank,
Thank you for your reply. I tried some code, but it does not behave as
expected:
File "./mooring65.gtk.py", line 846, in load_objects
feat = objects.GetNextFeature()
File "/usr/lib/python2.3/site-packages/ogr.py", line 383, in GetNextFeature
return Feature( obj = f_o )
TypeError: a float is required
A snippet of the offending code:
def load_objects(dataset,name,sumloc):
try:
objects=dataset.GetLayerByName( name )
except:
return sumloc
if objects is not None:
extent = objects.GetExtent(0)
print extent
feat = objects.GetNextFeature() #this is the line that generates the error
while feat is not None:
geom=feat.GetGeometryRef()
I inserted objects.ResetReading() after the print instruction, but
that didn't help much. I have the feeling I do not understand the
behaviour of osr. Any help is much appreciated.
Thanks,
Fulko
--
Fulko van Westrenen
Fulko.vanWestrenen at DTO.TUDelft.NL
More information about the Gdal-dev
mailing list