[gdal-dev] Re: delete feature without fid

Imran Rajjad rajjad at gmail.com
Thu Feb 2 02:09:03 EST 2012


i think its f.GetFID()

I`m guessing to show these changes on the file we need to call
layer.SyncToDisk();

regards,
Imran

On Thu, Feb 2, 2012 at 11:59 AM, Imran Rajjad <rajjad at gmail.com> wrote:

> hi list,
>
> in the gdal java bindings I need to delete a feature from layer, but it
> seems the only way to delete the feature is its FID, which in my case is
> unknown. Is there anyway to find the true FID of a feature in layer or
> remove a feature by reference just like it can be updated or re-written.
>
> my code ..
>
>
> Feature f = layer.GetFeature(i); // i is index of loop that runs till
> total feature count
>
> g=f.GetGeometryRef();
>
> layer.SetSpatialFilter(g); //reducing layer content to features with same
> geom...here its a point
>
> Feature comparefeature = layer.GetNextFeature();
>
> *do*
> {
>
> *if*(!f.Equal(comparefeature))
>
> {
>
> comparefeature.delete(); // not the right method...
>
> delcount++;
>
> }
>
>  comparefeature = layer.GetNextFeature();
>
> }
> *while*(comparefeature!=*null*);
>
> layer.ResetReading();
>
> layer.SetSpatialFilter(
> *null*); //remove spatial filter
> -----------------------
> regards,
> Imran
>
> --
> I.R
>



-- 
I.R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120202/ae6fc382/attachment.html


More information about the gdal-dev mailing list