[gdal-dev] How to create a Memory Vector dataset?
Joaquim Manuel Freire Luís
jluis at ualg.pt
Sun Feb 2 11:31:58 PST 2020
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 <even.rouault at spatialys.com>
Sent: Sunday, February 2, 2020 6:21 PM
To: Joaquim Manuel Freire Luís <jluis at ualg.pt>
Cc: gdal-dev at lists.osgeo.org
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
More information about the gdal-dev
mailing list