Re: [gdal-dev] Polygonize: are these steps the right ones?

2010-03-12 Thread Jorge Arevalo
On Fri, Mar 12, 2010 at 1:54 PM, Ari Jolma  wrote:
> I should have sent this to the list and not just Jorge. Anyway, the problem
> is solved.
>
> Jorge Arevalo kirjoitti:
>>
>> The problem is that the MEM-based layer doesn't have fields. So, if I
>> use "0" as iPixValField, I get an error, because there's no field with
>> index 0 in the Feature. Of course, the same result if I use any value
>>
>>>
>>> 0.
>>>
>>
>> I thought the solution was to "modify" the Layer's Feature Definition
>> to allow fields in the Features created. So, I created a new Feature
>> Defintion, with a Field Definition of one field, of type OFTReal.
>> Then, I created a new Feature following this schema, and I added this
>> Feature to the Layer. I know, it's not the best way, and it didn't
>> work. But I don't know how to "force" the MEM-based layer to allow
>> fields in its features.
>
> Jorge,
>
> You can manipulate (well, add fields only) the schema of the layer with
> the CreateField method:
> http://www.gdal.org/ogr/classOGRLayer.html#00b1376a1eabb1298ef278f92f6d84be
>
> This works for in-memory layers. Depending on the driver, when you add a
> feature, the schema may become read-only.
>
> Best regards,
>
> Ari
>

Yes, I should have added the list direction too. Sorry. Thanks for
solution, it was easier than my code.

Best regards,
Jorge


> ___
> gdal-dev mailing list
> gdal-dev@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Polygonize: are these steps the right ones?

2010-03-12 Thread Ari Jolma
I should have sent this to the list and not just Jorge. Anyway, the 
problem is solved.


Jorge Arevalo kirjoitti:

The problem is that the MEM-based layer doesn't have fields. So, if I
use "0" as iPixValField, I get an error, because there's no field with
index 0 in the Feature. Of course, the same result if I use any value
  

0.



I thought the solution was to "modify" the Layer's Feature Definition
to allow fields in the Features created. So, I created a new Feature
Defintion, with a Field Definition of one field, of type OFTReal.
Then, I created a new Feature following this schema, and I added this
Feature to the Layer. I know, it's not the best way, and it didn't
work. But I don't know how to "force" the MEM-based layer to allow
fields in its features.


Jorge,

You can manipulate (well, add fields only) the schema of the layer with
the CreateField method:
http://www.gdal.org/ogr/classOGRLayer.html#00b1376a1eabb1298ef278f92f6d84be

This works for in-memory layers. Depending on the driver, when you add a
feature, the schema may become read-only.

Best regards,

Ari

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev