def CreateGeometryFromGML(string): _obj = _gdal.OGR_G_CreateFromGML(string) if _obj is not None and _obj != 'NULL': result = Geometry(obj=_obj) result.thisown = 1 return result elif len(_gdal.CPLGetLastErrorMsg()) == 0: raise ValueError, 'Failed to parse GML in ogr.CreateGeometryFromGML()' else: raise ValueError, _gdal.CPLGetLastErrorMsg()
def CreateGeometryFromWkt(string, srs=None): if srs is not None: srs_o = srs._o else: srs_o = '' _obj = _gdal.OGR_G_CreateFromWkt(string, srs_o) if _obj is not None and _obj != 'NULL': result = Geometry(obj=_obj) result.thisown = 1 return result elif len(_gdal.CPLGetLastErrorMsg()) == 0: raise ValueError, 'Failed to parse WKT in ogr.CreateGeometryFromWkt()' else: raise ValueError, _gdal.CPLGetLastErrorMsg()
def CopyDataSource(self, src_ds, filename, options=[]): md_c = _gdal.ListToStringList(options) ds_o = _gdal.OGR_Dr_CopyDataSource(self._o, src_ds._o, filename, md_c) _gdal.CSLDestroy(md_c) if ds_o is None or ds_o == 'NULL': raise OGRError, _gdal.CPLGetLastErrorMsg() else: return DataSource(ds_o)
def Centroid(self, pnt_geom=None): if pnt_geom is None: pnt_geom = Geometry(type=wkbPoint) err_code = _gdal.OGR_G_Centroid(self._o, pnt_geom._o) if err_code != 0: raise OGRError, 'Error in Centroid operation. ' + _gdal.CPLGetLastErrorMsg( ) return pnt_geom
def AutoCreateWarpedVRT(src_ds, src_wkt=None, dst_wkt=None, eResampleAlg=GRA_NearestNeighbour, maxerror=0.0): src_wkt = ToNULLableString(src_wkt) dst_wkt = ToNULLableString(dst_wkt) new_ds = _gdal.GDALAutoCreateWarpedVRT(src_ds._o, src_wkt, dst_wkt, eResampleAlg, maxerror, 'NULL') FreeNULLableString(src_wkt) FreeNULLableString(dst_wkt) if new_ds is not None: _gdal.GDALDereferenceDataset(new_ds) return Dataset(_obj=new_ds) else: raise ValueError, _gdal.CPLGetLastErrorMsg()
def GetLastErrorMsg(): return _gdal.CPLGetLastErrorMsg()