Thank you guys for the correction. It seems I have copied an old polygon definition in my previous email (in my last script, I have changed odd ',' with ' ' to set couples). The issue was that I missed double brackets. However, the importFromWkt didn't work (Being undefined in the python bindings, I guess). Before sending the email, I had tried ogr.CreateGeometryFromWkt(wkt) as suggested by Even, but having missformed WKT (single brackets), it gave me ERROR 5: OGR Error: Corrupt data. Now my problem have been solved. Thank you all.
Best Regards, Daniele On Wed, Dec 16, 2009 at 7:43 PM, Frank Warmerdam <warmer...@pobox.com>wrote: > Daniele Romagnoli wrote: > >> Hi list, >> I'm creating a shapefile using the OGR python bindings. (from the 1.6.1 >> installer) >> I have some issues in creating the boundingBox for it. >> This is a snippet of the code I'm using: >> ----------------------------------------------------- >> from osgeo import ogr >> from osgeo import osr >> .... >> .... >> northings_llc = dd['northings_llc'] >> northings_urc = dd['northings_urc'] >> eastings_llc = dd['eastings_llc'] >> eastings_urc = dd['eastings_urc'] >> t_srs = osr.SpatialReference() >> t_srs.SetFromUserInput('EPSG:32632') >> drv = ogr.GetDriverByName('ESRI Shapefile') >> ds = drv.CreateDataSource(fileout) >> x0, y0, x1, y1 = str(eastings_llc[0][0]), str(northings_llc[0][0]), >> str(eastings_urc[0][0]), str(northings_urc[0][0]) >> >> layer = ds.CreateLayer(ds.GetName(), geom_type = ogr.wkbPolygon, srs = >> t_srs) >> geom = ogr.Geometry(type = layer.GetLayerDefn().GetGeomType()) >> geom.AssignSpatialReference(t_srs) >> wkt = 'POLYGON('+x0+','+y0+','+ x0+','+ y1+','+ x1+',' +y1+','+ x1+',' >> +y0+','+ x0+',' +y0+')' >> > > Daniele, > > You are not formatting your WKT right. There should be spaces between > x and y. The commas are only between tuples. > > eg. > > POLYGON ((479819.84375 4765180.5,479690.1875 4765259.5,... > > Best regards, > -- > > ---------------------------------------+-------------------------------------- > I set the clouds in motion - turn up | Frank Warmerdam, > warmer...@pobox.com > light and sound - activate the windows | > http://pobox.com/~warmerdam<http://pobox.com/%7Ewarmerdam> > and watch the world go round - Rush | Geospatial Programmer for Rent > > > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev > -- ------------------------------------------------------- Eng. Daniele Romagnoli Software Engineer GeoSolutions S.A.S. Via Carignoni 51 55041 Camaiore (LU) Italy phone: +39 0584983027 fax: +39 0584983027 mob: +39 328 0559267 http://www.geo-solutions.it -------------------------------------------------------
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev