Cool, that worked. But I had to go back to

hDS = GDALCreate(hDriver, "mem", 0, 0, 0, GDT_Unknown, NULL);

otherwise hDS == NULL


I now have something with 1 point only. Seems a bit inefficient, for each 
point, having to

Loop over all points {
                hFeature = OGR_F_Create(OGR_L_GetLayerDefn(hLayer));
                OGR_F_SetFieldString(hFeature, OGR_F_GetFieldIndex(hFeature, 
"Name"), "0");

                hPt = OGR_G_CreateGeometry(wkbPoint);
                OGR_G_SetPoint(hPt, 0, x, y, z);
                OGR_F_SetGeometry(hFeature, hPt);
                OGR_G_DestroyGeometry(hPt);

                if (OGR_L_CreateFeature(hLayer, hFeature) != OGRERR_NONE) {
                        GMT_Report (GMT->parent, GMT_MSG_ERROR, "Failed to 
create feature in dataset.\n");
                        GDALDestroyDriverManager();
                        return NULL;
                }
                OGR_F_Destroy(hFeature);
}

But let me have a true working case to see.

Thanks.


-----Original Message-----
From: Even Rouault <[email protected]> 
Sent: Sunday, February 2, 2020 6:21 PM
To: Joaquim Manuel Freire Luís <[email protected]>
Cc: [email protected]
Subject: Re: [gdal-dev] How to create a Memory Vector dataset?

On dimanche 2 février 2020 18:11:26 CET Joaquim Manuel Freire Luís wrote:
> >> Is there an
> >> example somewhere of creating a Memory (not MEM?) vector dataset 
> >> that I could use to learn more on this?
> > 
> > https://gdal.org/tutorials/vector_api_tut.html#writing-to-ogr should 
> > work with MEM too.
> Even,
> 
> Sorry, I'm having *some* troubles with the MEM driver that I don't see 
> how to solve
> 
> <begin snip>
>       hDriver = GDALGetDriverByName("MEM");

--> should be "Memory" here for the vector driver. The MEM driver is 
--> raster-
only.

--
Spatialys - Geospatial professional services http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to