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
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to