Hi list,<br>I'm creating a shapefile using the OGR python bindings. (from the 1.6.1 installer)<br>I have some issues in creating the boundingBox for it.<br>This is a snippet of the code I'm using:<br>-----------------------------------------------------<br>
from osgeo import ogr<br>from osgeo import osr<br>....<br>....<br>northings_llc = dd['northings_llc']<br>northings_urc = dd['northings_urc']<br>eastings_llc = dd['eastings_llc']<br>eastings_urc = dd['eastings_urc']<br>
t_srs = osr.SpatialReference()<br>t_srs.SetFromUserInput('EPSG:32632')<br>drv = ogr.GetDriverByName('ESRI Shapefile')<br>ds = drv.CreateDataSource(fileout)<br>x0, y0, x1, y1 = str(eastings_llc[0][0]), str(northings_llc[0][0]), str(eastings_urc[0][0]), str(northings_urc[0][0])<br>
<br>layer = ds.CreateLayer(ds.GetName(), geom_type = ogr.wkbPolygon, srs = t_srs)<br>geom = ogr.Geometry(type = layer.GetLayerDefn().GetGeomType())<br>geom.AssignSpatialReference(t_srs)<br>wkt = 'POLYGON('+x0+','+y0+','+ x0+','+ y1+','+ x1+',' +y1+','+ x1+',' +y0+','+ x0+',' +y0+')'<br>
print(wkt)<br>geom.importFromWkt(wkt)<br>...<br>...<br><br>When running, I get this output:<br>POLYGON(602759.984846,4739727.96408,602759.984846,4739720.3473,602760.45247,4739720.3473,602760.45247,4739727.96408,602759.984846,4739727.96408)<br>
Traceback (most recent call last):<br> File "prova.py", line 42, in <module><br> geom.importFromWkt(wkt)<br> File "c:\python26\lib\site-packages\osgeo\ogr.py", line 2672, in <lambda><br>
__getattr__ = lambda self, name: _swig_getattr(self, Geometry, name)<br> File "c:\python26\lib\site-packages\osgeo\ogr.py", line 34, in _swig_getattr<br> raise AttributeError,name<br>AttributeError: importFromWkt<br>
<br clear="all">Indeed, looking at the ogr.py there is no "importFromWkt" in the Geometry definition.<br>How can I set the bounding box within the geometry?<br>Any help would be greatly appreciated.<br><br>Best Regards,<br>
Daniele<br><br>-- <br>-------------------------------------------------------<br>Eng. Daniele Romagnoli <br>Software Engineer<br><br>GeoSolutions S.A.S.<br>Via Carignoni 51<br>55041 Camaiore (LU)<br>Italy<br><br>phone: +39 0584983027<br>
fax: +39 0584983027<br>mob: +39 328 0559267<br><br><br><a href="http://www.geo-solutions.it">http://www.geo-solutions.it</a><br><br>-------------------------------------------------------<br><br>