yes, I get it
but how about convert one feature to geojson string?
GISNET-346 ---- Status : Open GISNET-348 ---- Status : Closed GISNET-350 ---- Status : Open GISNET-351 ---- Status : Open
thnks for your hard work, above feature is very helpful ,Is there any progress
this example convert each gdb-feature in the separated geo-json layers (in memory) and prints as strings in console. I hope its help you.
// open a gdb layer at '1' index for reading.
using (var inputGdb = Dataset.Open(gdbPath, Drivers.FileGdb))
using (var inputLayer = inputGdb.OpenLayerAt(1))
{
// print each features as geo-json
foreach (var inputFeature in inputLayer)
{
using (var stream = new MemoryStream())
{
// create a new geo-json layer in memory stream.
var jsonPath = AbstractPath.FromStream(stream);
using (VectorLayer outputLayer = VectorLayer.Create(jsonPath, Drivers.GeoJson))
{
// take gdb attributes schema and write this schema to new geo-json layer.
outputLayer.CopyAttributes(inputLayer);
// first we need to create a new feature with attributes.
Feature outputFeature = outputLayer.ConstructFeature();
// then we take a geometry from gdb and set to geo-json.
// here we can to add logic that modify output geometry (srs transformation, modification etc).
outputFeature.Geometry = inputFeature.Geometry;
// then we copies all values of attributes from another feature.
// here we can to add logic that modify output attributes values.
outputFeature.CopyValues(inputFeature);
// adds a new feature to the layer.
outputLayer.Add(outputFeature);
}
// convert stream to string
stream.Seek(0, SeekOrigin.Begin);
StreamReader reader = new StreamReader(stream);
string geoJson = reader.ReadToEnd();
Console.WriteLine(geoJson);
}
}
}
And thank you that confirmed the relevance of open tasks.
In the previous year, we implemented primarily tasks that were recommended by business analytics. And we could not pay attention to the tasks associated with updating the layer data. Now we are making major efforts to implement the tasks from the forum.
I researched the discussion from the ‘How modify Gdb’ topic. And it is important to be able to update the large data sets. We will try to add this new functionality.
thanks , it work for me . But I found a new question. The format of exported geojson is different from that of GDAL exported geojson , for example: no crs , no id in feature
Although If a feature has a commonly used identifier, that identifier should be included as a member of the feature object with the name “id”. Thank you for pointing that out.
I have created the GISNET-1287 ticket. We will add the id_field option.