Beau, On Wed, Sep 10, 2014 at 7:30 AM, Beau Taylor <[email protected]> wrote: > The following program successfully creates a shape file I am requiring. > > from osgeo import ogr > from osgeo import osr > > def myRing(coords): > ring = ogr.Geometry(ogr.wkbLinearRing) > for xy in coords: > ring.AddPoint(xy[0],xy[1]) > return ring > > coords = [(-23.378906,68.974164), (-23.378906,34.307144), > (31.464844,34.307144), (31.464844,68.974164), (-23.378906,68.974164)] > > ring = myRing(coords) > poly = ogr.Geometry(ogr.wkbPolygon) > poly.AddGeometry(ring) > > outDriver = ogr.GetDriverByName('ESRI Shapefile') > data_source = outDriver.CreateDataSource('test.shp') > srs = osr.SpatialReference() > srs.ImportFromEPSG(4326) > layer = data_source.CreateLayer('test.shp', srs, ogr.wkbPolygon) > > feature = ogr.Feature(layer.GetLayerDefn()) > feature.SetGeometry(poly) > layer.CreateFeature(feature) > > feature.Destroy > data_source.Destroy() > > However, I did not know how to do the followings: > > -set the color of outer ring as blue, > -do not fill the polygen
Style is usually dictated by the application. You can set them in the app, or for some formats/drivers you can use the OGR style API: http://gdal.org/ogr_feature_style.html AFAIK, shapefiles do not support styles > -name the feature as 'test' Add a field to the feature definition, called 'name', see the tutorial, I think it has that exact example: http://gdal.org/ogr_apitut.html > > I hope someone can help me. > > Thanks in the advance. > Beau > > _______________________________________________ > gdal-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev If you are using GDAL/OGR 1.x, use the docs at: http://gdal.org/1.11/index.html -- Kyle _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
