You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried many times in different ways, I have not been able to extract valid polygons shp from for example regions of a country.
Some of what I have tried so far :
public void Extract(string fileNameIn, string folderOut)
{
using (var fileStream = new FileInfo(fileNameIn).OpenRead())
{
var source = new PBFOsmStreamSource(fileStream);
var f = (from s in source
where s.Tags.Contains("boundary", "administrative")
where s.Tags.Contains("admin_level", "3")
where s.Tags.ContainsKey("name")
where !s.Tags.ContainsKey("highway")
select s)
// .Take(1)
.ToFeatureSource();
var fileOut = Path.Combine(folderOut, f.ToString());
// build feature collection.
var featureCollection = new FeatureCollection();
var attributesTable = new AttributesTable();
var geoCount = 0;
foreach (var feature in f)
{ // make sure there is a constant # of attributes with the same names before writing the shapefile.
featureCollection.Add(new Feature(feature.Geometry, attributesTable));
geoCount++;
}
geoCount.Dump();
if (geoCount > 0)
{
// convert to shape.
var header = NetTopologySuite.IO.ShapefileDataWriter.GetHeader(featureCollection.First(), featureCollection.Count);
var shapeWriter = new ShapefileDataWriter(fileOut + ".shp", new GeometryFactory())
{
Header = header
};
shapeWriter.Write(featureCollection);
}
}
}
This takes ~15min applied to an extract of France, but no relevant result.
Any recommendation ?
The text was updated successfully, but these errors were encountered:
I have tried many times in different ways, I have not been able to extract valid polygons shp from for example regions of a country.
Some of what I have tried so far :
This takes ~15min applied to an extract of France, but no relevant result.
Any recommendation ?
The text was updated successfully, but these errors were encountered: