Last active
April 21, 2022 23:53
-
-
Save aspose-com-gists/10f3783b9581d10bc69dbada42705d2c to your computer and use it in GitHub Desktop.
Aspose.GIS for .NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This Gist contains code snippets from examples of Aspose.GIS for .NET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
private class AttributesConverterExample : IAttributesConverter | |
{ | |
public void ModifyAttribute(FeatureAttribute attribute, AttributesConverterActions actions) | |
{ | |
switch (attribute.Name) | |
{ | |
case "name": | |
// rename and adjust width | |
attribute.Name = "nickname"; | |
attribute.Width = 10; | |
break; | |
case "age": | |
// change type and adjust width | |
attribute.DataType = AttributeDataType.String; | |
attribute.Width = 3; | |
attribute.Precision = 0; | |
break; | |
case "dob": | |
// exclude attribute from destination file. | |
actions.Exclude = true; | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
ConversionOptions options = new ConversionOptions(); | |
options.AttributesConverter = new AttributesConverterExample(); | |
VectorLayer.Convert(dataDir + "input.json", Drivers.GeoJson, dataDir + "ConvertGeoJSONToShapeFileWithAttributeAdjustment_out.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string sampleGeoJsonPath = RunExamples.GetDataDir() + "sample.geojson"; | |
var outputFilePath = RunExamples.GetDataDir() + "convertedSample_out.topojson"; | |
VectorLayer.Convert(sampleGeoJsonPath, Drivers.GeoJson, outputFilePath, Drivers.TopoJson); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string sampleGeoJsonPath = RunExamples.GetDataDir() + "sample.geojson"; | |
var outputFilePath = RunExamples.GetDataDir() + "convertedSampleWithObjectName_out.topojson"; | |
var options = new ConversionOptions | |
{ | |
DestinationDriverOptions = new TopoJsonOptions | |
{ | |
// specify the name of the object where features should be written | |
DefaultObjectName = "name_of_the_object", | |
} | |
}; | |
VectorLayer.Convert(sampleGeoJsonPath, Drivers.GeoJson, outputFilePath, Drivers.TopoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string sampleGeoJsonPath = RunExamples.GetDataDir() + "sample.geojson"; | |
var outputFilePath = RunExamples.GetDataDir() + "convertedSampleWithGrouping_out.topojson"; | |
var options = new ConversionOptions | |
{ | |
DestinationDriverOptions = new TopoJsonOptions | |
{ | |
// we set the attribute in GeoJSON layer by which we are going to group into objects | |
ObjectNameAttribute = "group", | |
// if value of "group" is unknown for some feature it should be placed into object with name "unnamed". | |
DefaultObjectName = "unnamed", | |
} | |
}; | |
VectorLayer.Convert(sampleGeoJsonPath, Drivers.GeoJson, outputFilePath, Drivers.TopoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// convert GeoJSON to TopoJSON with quantization - transforming doubles to integers | |
// to reduce file size. | |
string SampleGeoJsonPath = RunExamples.GetDataDir() + "sample.geojson"; | |
var outputFilePath = RunExamples.GetDataDir() + "convertedSampleWithQuantization_out.topojson"; | |
var options = new ConversionOptions | |
{ | |
DestinationDriverOptions = new TopoJsonOptions | |
{ | |
// There are two ways to set quantization parameters - with Transform property or | |
// with quantization number. Here we specify quantization number. | |
// Quantization number specifies number of expressible values per dimension in a result | |
// coordinates. | |
QuantizationNumber = 100_000, | |
// Alternatively, 'Transform' property can be set (but not simultaneously with quantization number). | |
// Refer to TopoJSON specification for more details on transform object and quantization. | |
// | |
// Transform = new TopoJsonTransform( | |
// xTranslate: 0, | |
// yTranslate: 0, | |
// xScale: 0.0001000010000100001, | |
// yScale: 0.0001000010000100001), | |
} | |
}; | |
VectorLayer.Convert(SampleGeoJsonPath, Drivers.GeoJson, outputFilePath, Drivers.TopoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
VectorLayer.Convert(shapefilePath, Drivers.Shapefile, jsonPath, Drivers.GeoJson); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var sampleTopoJsonPath = RunExamples.GetDataDir() + "sample.topojson"; | |
var outputFilePath = RunExamples.GetDataDir() + "convertedSample_out.geojson"; | |
VectorLayer.Convert(sampleTopoJsonPath, Drivers.TopoJson, outputFilePath, Drivers.GeoJson); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var decimalDegrees = GeoConvert.AsPointText(25.5, 45.5, PointFormats.DecimalDegrees); | |
Console.WriteLine(decimalDegrees); | |
var degreeDecimalMinutes = GeoConvert.AsPointText(25.5, 45.5, PointFormats.DegreeDecimalMinutes); | |
Console.WriteLine(degreeDecimalMinutes); | |
var degreeMinutesSeconds = GeoConvert.AsPointText(25.5, 45.5, PointFormats.DegreeMinutesSeconds); | |
Console.WriteLine(degreeMinutesSeconds); | |
var geoRef = GeoConvert.AsPointText(25.5, 45.5, PointFormats.GeoRef); | |
Console.WriteLine(geoRef); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
if (GeoConvert.TryParsePointText("25.5°, 45.5°", out var point1)) | |
{ | |
Console.WriteLine("25.5°, 45.5° parsed as" + point1); | |
} | |
if (GeoConvert.TryParsePointText("25°30.00000', 045°30.00000'", out var point2)) | |
{ | |
Console.WriteLine("25°30.00000', 045°30.00000' parsed as" + point2); | |
} | |
if (GeoConvert.TryParsePointText("25°30'00.3000\", 045°30'00.3000\"", out var point3)) | |
{ | |
Console.WriteLine("25°30'00.3000\", 045°30'00.3000\" parsed as" + point3); | |
} | |
if (GeoConvert.TryParsePointText("RHAL30003000", out var point4)) | |
{ | |
Console.WriteLine("RHAL30003000 parsed as" + point4); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
ILineString readOnlyLine = (ILineString)Geometry.FromText("LINESTRING (1 1, 2 2)"); | |
// Interfaces inherited from IGeometry represent read-only geometries, while | |
// concrete classes inherited from Geometry represent editable geometries. | |
// If you need to edit a geometry represented by an interface, 'ToEditable' method should be used to | |
// get an editable copy. | |
LineString editableLine = readOnlyLine.ToEditable(); | |
// Line can be edited now | |
editableLine.AddPoint(3, 3); | |
Console.WriteLine(editableLine.AsText()); // LINESTRING (1 1, 2 2, 3 3) | |
// Initial geometry did not change | |
Console.WriteLine(readOnlyLine.AsText()); // LINESTRING (1 1, 2 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(40.7128, -74.006); | |
LineString line = new LineString(); | |
line.AddPoint(78.65, -32.65); | |
line.AddPoint(-98.65, 12.65); | |
GeometryCollection geometryCollection = new GeometryCollection(); | |
geometryCollection.Add(point); | |
geometryCollection.Add(line); | |
int geometriesCount = geometryCollection.Count; | |
Console.WriteLine(geometriesCount); // 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LineString line = new LineString(); | |
line.AddPoint(78.65, -32.65); | |
line.AddPoint(-98.65, 12.65); | |
int pointsCount = line.Count; | |
Console.WriteLine(pointsCount); // 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = RunExamples.GetDataDir() + "CreateCircularString_out.shp"; | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.Shapefile)) | |
{ | |
var feature = layer.ConstructFeature(); | |
// create a circle with center at (1,0) and radius 1. | |
var circularString = new CircularString(); | |
circularString.AddPoint(0, 0); | |
circularString.AddPoint(1, 1); | |
circularString.AddPoint(2, 0); | |
circularString.AddPoint(1, -1); | |
circularString.AddPoint(0, 0); | |
feature.Geometry = circularString; | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = RunExamples.GetDataDir() + "CreateCompoundCurve_out.shp"; | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.Shapefile)) | |
{ | |
var feature = layer.ConstructFeature(); | |
// create an 'S' letter (starts at bottom left end) | |
var compoundCurve = new CompoundCurve(); | |
var bottom = (ILineString)Geometry.FromText("LineString (0 0, 3 0)"); | |
var firstArc = (ICircularString)Geometry.FromText("CircularString (3 0, 4 1, 3 2)"); | |
var middle = (ILineString)Geometry.FromText("LineString (3 2, 1 2)"); | |
var secondArc = (ICircularString)Geometry.FromText("CircularString (1 2, 0 3, 1 4)"); | |
var top = (ILineString)Geometry.FromText("LineString (1 4, 4 4)"); | |
compoundCurve.AddCurve(bottom); | |
compoundCurve.AddCurve(firstArc); | |
compoundCurve.AddCurve(middle); | |
compoundCurve.AddCurve(secondArc); | |
compoundCurve.AddCurve(top); | |
feature.Geometry = compoundCurve; | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = RunExamples.GetDataDir() + "CreateCurvePolygon_out.shp"; | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.Shapefile)) | |
{ | |
var feature = layer.ConstructFeature(); | |
// create a torus with center at (0,0), radius equal to 2 and hole radius equal to 1 | |
var curvePolygon = new CurvePolygon(); | |
var exterior = new CircularString(); | |
exterior.AddPoint(-2, 0); | |
exterior.AddPoint(0, 2); | |
exterior.AddPoint(2, 0); | |
exterior.AddPoint(0, -2); | |
exterior.AddPoint(-2, 0); | |
curvePolygon.ExteriorRing = exterior; | |
var interior = new CircularString(); | |
interior.AddPoint(-1, 0); | |
interior.AddPoint(0, 1); | |
interior.AddPoint(1, 0); | |
interior.AddPoint(0, -1); | |
interior.AddPoint(-1, 0); | |
curvePolygon.AddInteriorRing(interior); | |
feature.Geometry = curvePolygon; | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(40.7128, -74.006); | |
LineString line = new LineString(); | |
line.AddPoint(78.65, -32.65); | |
line.AddPoint(-98.65, 12.65); | |
GeometryCollection geometryCollection = new GeometryCollection(); | |
geometryCollection.Add(point); | |
geometryCollection.Add(line); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LineString line = new LineString(); | |
line.AddPoint(78.65, -32.65); | |
line.AddPoint(-98.65, 12.65); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = RunExamples.GetDataDir() + "CreateMultiCurve_out.shp"; | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.Shapefile)) | |
{ | |
var feature = layer.ConstructFeature(); | |
var multiCurve = new MultiCurve(); | |
multiCurve.Add(Geometry.FromText("LineString (0 0, 1 0)")); | |
multiCurve.Add(Geometry.FromText("CircularString (2 2, 3 3, 4 2)")); | |
multiCurve.Add(Geometry.FromText("CompoundCurve ((0 1, 0 0), CircularString (0 0, 3 3, 6 0))")); | |
feature.Geometry = multiCurve; | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LineString firstLine = new LineString(); | |
firstLine.AddPoint(7.5, -3.5); | |
firstLine.AddPoint(-9.6, 12.6); | |
LineString secondLine = new LineString(); | |
secondLine.AddPoint(8.5, -2.6); | |
secondLine.AddPoint(-8.6, 1.5); | |
MultiLineString multiLineString = new MultiLineString(); | |
multiLineString.Add(firstLine); | |
multiLineString.Add(secondLine); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
MultiPoint multipoint = new MultiPoint(); | |
multipoint.Add(new Point(1, 2)); | |
multipoint.Add(new Point(3, 4)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LinearRing firstRing = new LinearRing(); | |
firstRing.AddPoint(8.5, -2.5); | |
firstRing.AddPoint(-8.5, 2.5); | |
firstRing.AddPoint(8.5, -2.5); | |
Polygon firstPolygon = new Polygon(firstRing); | |
LinearRing secondRing = new LinearRing(); | |
secondRing.AddPoint(7.6, -3.6); | |
secondRing.AddPoint(-9.6, 1.5); | |
secondRing.AddPoint(7.6, -3.6); | |
Polygon secondPolygon = new Polygon(secondRing); | |
MultiPolygon multiPolygon = new MultiPolygon(); | |
multiPolygon.Add(firstPolygon); | |
multiPolygon.Add(secondPolygon); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = RunExamples.GetDataDir() + "CreateMultiSurface_out.json"; | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.GeoJson)) | |
{ | |
var feature = layer.ConstructFeature(); | |
var multiSurface = new MultiSurface(); | |
var polygon = Geometry.FromText("Polygon ((0 0, 0 1, 1 1, 1 0, 0 0))"); | |
multiSurface.Add(polygon); | |
var curvePolygon = Geometry.FromText("CurvePolygon (CircularString (-2 0, 0 2, 2 0, 0 -2, -2 0))"); | |
multiSurface.Add(curvePolygon); | |
feature.Geometry = multiSurface; | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(40.7128, -74.006); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Polygon polygon = new Polygon(); | |
LinearRing ring = new LinearRing(); | |
ring.AddPoint(50.02, 36.22); | |
ring.AddPoint(49.99, 36.26); | |
ring.AddPoint(49.97, 36.23); | |
ring.AddPoint(49.98, 36.17); | |
ring.AddPoint(50.02, 36.22); | |
polygon.ExteriorRing = ring; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Polygon polygon = new Polygon(); | |
LinearRing ring = new LinearRing(); | |
ring.AddPoint(50.02, 36.22); | |
ring.AddPoint(49.99, 36.26); | |
ring.AddPoint(49.97, 36.23); | |
ring.AddPoint(49.98, 36.17); | |
ring.AddPoint(50.02, 36.22); | |
LinearRing hole = new LinearRing(); | |
hole.AddPoint(50.00, 36.22); | |
hole.AddPoint(49.99, 36.20); | |
hole.AddPoint(49.98, 36.23); | |
hole.AddPoint(50.00, 36.24); | |
hole.AddPoint(50.00, 36.22); | |
polygon.ExteriorRing = ring; | |
polygon.AddInteriorRing(hole); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometry1 = new MultiLineString | |
{ | |
new LineString(new [] { new Point(0, 0), new Point(1, 1) }), | |
new LineString(new [] { new Point(1, 1), new Point(2, 2) }), | |
}; | |
var geometry2 = new LineString(new[] | |
{ | |
new Point(0, 0), new Point(2, 2), | |
}); | |
Console.WriteLine(geometry1.SpatiallyEquals(geometry2)); // True | |
geometry2.AddPoint(3, 3); | |
Console.WriteLine(geometry1.SpatiallyEquals(geometry2)); // False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometry1 = new LineString(); | |
geometry1.AddPoint(0, 0); | |
geometry1.AddPoint(2, 2); | |
var geometry2 = new LineString(); | |
geometry2.AddPoint(1, 1); | |
geometry2.AddPoint(3, 3); | |
Console.WriteLine(geometry1.Crosses(geometry2)); // False | |
var geometry3 = new LineString(); | |
geometry3.AddPoint(0, 2); | |
geometry3.AddPoint(2, 0); | |
Console.WriteLine(geometry1.Crosses(geometry3)); // True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometry1 = new Polygon(new LinearRing(new[] | |
{ | |
new Point(0, 0), | |
new Point(0, 3), | |
new Point(3, 3), | |
new Point(3, 0), | |
new Point(0, 0), | |
})); | |
var geometry2 = new Polygon(new LinearRing(new[] | |
{ | |
new Point(1, 1), | |
new Point(1, 4), | |
new Point(4, 4), | |
new Point(4, 1), | |
new Point(1, 1), | |
})); | |
Console.WriteLine(geometry1.Intersects(geometry2)); // True | |
Console.WriteLine(geometry2.Intersects(geometry1)); // True | |
// 'Disjoint' is opposite to 'Intersects' | |
Console.WriteLine(geometry1.Disjoint(geometry2)); // False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometry1 = new LineString(); | |
geometry1.AddPoint(0, 0); | |
geometry1.AddPoint(0, 2); | |
var geometry2 = new LineString(); | |
geometry2.AddPoint(0, 2); | |
geometry2.AddPoint(0, 3); | |
Console.WriteLine(geometry1.Overlaps(geometry2)); // False | |
var geometry3 = new LineString(); | |
geometry3.AddPoint(0, 1); | |
geometry3.AddPoint(0, 3); | |
Console.WriteLine(geometry1.Overlaps(geometry3)); // True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometry1 = new LineString(); | |
geometry1.AddPoint(0, 0); | |
geometry1.AddPoint(2, 2); | |
var geometry2 = new LineString(); | |
geometry2.AddPoint(2, 2); | |
geometry2.AddPoint(3, 3); | |
Console.WriteLine(geometry1.Touches(geometry2)); // True | |
Console.WriteLine(geometry2.Touches(geometry1)); // True | |
var geometry3 = new Point(2, 2); | |
Console.WriteLine(geometry1.Touches(geometry3)); // True | |
var geometry4 = new LineString(); | |
geometry4.AddPoint(1, 1); | |
geometry4.AddPoint(4, 4); | |
Console.WriteLine(geometry1.Touches(geometry4)); // False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometryWithoutCurves = Geometry.FromText(@"GeometryCollection (LineString (0 0, 1 1, 2 0),CompoundCurve ((4 0, 5 1), (5 1, 6 2, 7 1)))"); | |
// geometry does not contain circular string, so HasCurveGeometry returns false. | |
Console.WriteLine(geometryWithoutCurves.HasCurveGeometry); // False | |
var geometry = Geometry.FromText(@"GeometryCollection (LineString (0 0, 1 1, 2 0),CompoundCurve ((4 0, 5 1), CircularString (5 1, 6 2, 7 1)))"); | |
// geometry contains circular string, so HasCurveGeometry returns true. | |
Console.WriteLine(geometry.HasCurveGeometry); // True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometry1 = new Polygon(); | |
geometry1.ExteriorRing = new LinearRing(new[] | |
{ | |
new Point(0, 0), | |
new Point(0, 4), | |
new Point(4, 4), | |
new Point(4, 0), | |
new Point(0, 0), | |
}); | |
geometry1.AddInteriorRing(new LinearRing(new[] | |
{ | |
new Point(1, 1), | |
new Point(1, 3), | |
new Point(3, 3), | |
new Point(3, 1), | |
new Point(1, 1), | |
})); | |
var geometry2 = new Point(2, 2); | |
Console.WriteLine(geometry1.SpatiallyContains(geometry2)); // False | |
var geometry3 = new Point(0.5, 0.5); | |
Console.WriteLine(geometry1.SpatiallyContains(geometry3)); // True | |
// 'a.SpatiallyContains(b)' equals to 'b.Within(a)' | |
Console.WriteLine(geometry3.Within(geometry1)); // True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var line = new LineString(); | |
line.AddPoint(0, 0); | |
line.AddPoint(1, 1); | |
var point = new Point(0, 0); | |
Console.WriteLine(line.Covers(point)); // True | |
Console.WriteLine(point.CoveredBy(line)); // True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometry1 = new LineString(); | |
geometry1.AddPoint(0, 0); | |
geometry1.AddPoint(0, 2); | |
var geometry2 = new LineString(); | |
geometry2.AddPoint(0, 1); | |
geometry2.AddPoint(0, 3); | |
// Relate method takes a string representation of DE-9IM matrix | |
// (Dimensionally Extended Nine-Intersection Model matrix). | |
// see Simple Feature Access specification for more details on DE-9IM. | |
// this is the equivalent of 'geometry1.SpatiallyEquals(geometry2)' | |
Console.WriteLine(geometry1.Relate(geometry2, "T*F**FFF*")); // False | |
// this is the equivalent of 'geometry1.Disjoint(geometry2)' | |
Console.WriteLine(geometry1.Relate(geometry2, "FF*FF****")); // False | |
// this is the equivalent of 'geometry1.Overlaps(geometry2)' | |
Console.WriteLine(geometry1.Relate(geometry2, "1*T***T**")); // True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// find intersection, union, difference and symmetric difference of two geometries. | |
var polygon1 = new Polygon(); | |
polygon1.ExteriorRing = new LinearRing(new[] | |
{ | |
new Point(0, 0), | |
new Point(0, 2), | |
new Point(2, 2), | |
new Point(2, 0), | |
new Point(0, 0), | |
}); | |
var polygon2 = new Polygon(); | |
polygon2.ExteriorRing = new LinearRing(new[] | |
{ | |
new Point(1, 1), | |
new Point(1, 3), | |
new Point(3, 3), | |
new Point(3, 1), | |
new Point(1, 1), | |
}); | |
var intersection = polygon1.Intersection(polygon2); | |
Console.WriteLine("Intersection type is {0}", intersection.GeometryType); // Polygon | |
PrintRing(((IPolygon)intersection).ExteriorRing); | |
// [0] - (1 1) | |
// [1] - (1 2) | |
// [2] - (2 2) | |
// [3] - (2 1) | |
// [4] - (1 1) | |
var union = polygon1.Union(polygon2); | |
Console.WriteLine("Union type is {0}", union.GeometryType); // Polygon | |
PrintRing(((IPolygon)union).ExteriorRing); | |
// [0] - (0 0) | |
// [1] - (0 2) | |
// [2] - (1 2) | |
// [3] - (1 3) | |
// [4] - (3 3) | |
// [5] - (3 1) | |
// [6] - (2 1) | |
// [7] - (2 0) | |
// [8] - (0 0) | |
var difference = polygon1.Difference(polygon2); | |
Console.WriteLine("Difference type is {0}", difference.GeometryType); // Polygon | |
PrintRing(((IPolygon)difference).ExteriorRing); | |
// [0] - (0 0) | |
// [1] - (0 2) | |
// [2] - (1 2) | |
// [3] - (1 1) | |
// [4] - (2 1) | |
// [5] - (2 0) | |
// [6] - (0 0) | |
var symDifference = polygon1.SymDifference(polygon2); | |
Console.WriteLine("Symmetric Difference type is {0}", symDifference.GeometryType); // MultiPolygon | |
var multiPolygon = (IMultiPolygon)symDifference; | |
Console.WriteLine("Polygons count is {0}", multiPolygon.Count); // 2 | |
PrintRing(((IPolygon)multiPolygon[0]).ExteriorRing); | |
// [0] - (0 0) | |
// [1] - (0 2) | |
// [2] - (1 2) | |
// [3] - (1 1) | |
// [4] - (2 1) | |
// [5] - (2 0) | |
// [6] - (0 0) | |
PrintRing(((IPolygon)multiPolygon[1]).ExteriorRing); | |
// [0] - (1 2) | |
// [1] - (1 3) | |
// [2] - (3 3) | |
// [3] - (3 1) | |
// [4] - (2 1) | |
// [5] - (2 2) | |
// [6] - (1 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LineString lineString = new LineString(); | |
bool simple = lineString.IsSimple; // simple == true | |
lineString.AddPoint(0, 0); | |
lineString.AddPoint(1, 0); | |
simple = lineString.IsSimple; // simple == true | |
lineString.AddPoint(0.5, 0); | |
simple = lineString.IsSimple; // simple == false (line string crosses itself) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LinearRing linearRing = new LinearRing(); | |
linearRing.AddPoint(0, 0); | |
linearRing.AddPoint(0, 1); | |
linearRing.AddPoint(1, 0); | |
bool valid = linearRing.IsValid; // valid == false | |
linearRing.AddPoint(0, 0); | |
valid = linearRing.IsValid; // valid == true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var exteriorRing = new LinearRing(); | |
exteriorRing.AddPoint(0, 0); | |
exteriorRing.AddPoint(0, 1); | |
exteriorRing.AddPoint(1, 1); | |
exteriorRing.AddPoint(1, 0); | |
exteriorRing.AddPoint(0, 0); | |
var interiorRing = new LinearRing(); | |
interiorRing.AddPoint(0.5, 0.5); | |
interiorRing.AddPoint(1, 0.5); | |
interiorRing.AddPoint(1, 1); | |
interiorRing.AddPoint(0.5, 1); | |
interiorRing.AddPoint(0.5, 0.5); | |
var invalidPolygon = new Polygon(); | |
invalidPolygon.ExteriorRing = exteriorRing; | |
invalidPolygon.AddInteriorRing(interiorRing); | |
// invalidPolygon.IsValid == false, since polygon rings share segments (have infinite number of intersection points) | |
GeoJsonOptions options = new GeoJsonOptions(); | |
options.ValidateGeometriesOnWrite = false; // false is default | |
File.Delete(dataDir + "not_validated_data_out.shp"); | |
using (var nonValidatingLayer = Drivers.GeoJson.CreateLayer(dataDir + "not_validated_data_out.shp", options)) | |
{ | |
Feature feature = nonValidatingLayer.ConstructFeature(); | |
feature.Geometry = invalidPolygon; | |
// no exception is thrown, since ValidateGeometriesOnWrite == false, and GeoJson specification doesn't say that rings of polygon can't share segments. | |
nonValidatingLayer.Add(feature); | |
} | |
options.ValidateGeometriesOnWrite = true; | |
File.Delete(dataDir + "validated_data_out.shp"); | |
using (var validatingLayer = Drivers.GeoJson.CreateLayer(dataDir + "validated_data_out.shp", options)) | |
{ | |
Feature feature = validatingLayer.ConstructFeature(); | |
feature.Geometry = invalidPolygon; | |
try | |
{ | |
validatingLayer.Add(feature); // GisException is thrown, since polygon is not valid | |
} | |
catch (GisException e) | |
{ | |
Console.WriteLine(e.Message); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LineString lineStrinWithOnePoint = new LineString(); | |
lineStrinWithOnePoint.AddPoint(0, 0); | |
GeoJsonOptions options = new GeoJsonOptions(); | |
options.ValidateGeometriesOnWrite = false; | |
using (var layer = Drivers.GeoJson.CreateLayer(dataDir + "ValidateOnWriteObeyingSpecifications_out.json", options)) | |
{ | |
Feature feature = layer.ConstructFeature(); | |
// GeoJSON specification says that line string must have at least two coordinates. | |
feature.Geometry = lineStrinWithOnePoint; | |
try | |
{ | |
// Geometry of feature doesn't match data format specification, so exception is thrown | |
// regardless what ValidateGeometriesOnWrite option is. | |
layer.Add(feature); | |
} | |
catch (GisException e) | |
{ | |
Console.WriteLine(e.Message); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var triangleRing = new LinearRing(); | |
triangleRing.AddPoint(4, 6); | |
triangleRing.AddPoint(1, 3); | |
triangleRing.AddPoint(8, 7); | |
triangleRing.AddPoint(4, 6); | |
var triangle = new Polygon(triangleRing); | |
var squareRing = new LinearRing(); | |
squareRing.AddPoint(0, 9); | |
squareRing.AddPoint(0, 7); | |
squareRing.AddPoint(2, 7); | |
squareRing.AddPoint(2, 9); | |
squareRing.AddPoint(0, 9); | |
var square = new Polygon(squareRing); | |
var multiPolygon = new MultiPolygon { triangle, square }; | |
Console.WriteLine("{0:F}", triangle.GetArea()); // 4.50 | |
Console.WriteLine("{0:F}", square.GetArea()); // 4.00 | |
Console.WriteLine("{0:F}", multiPolygon.GetArea()); // 8.50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var polygon = new Polygon(); | |
polygon.ExteriorRing = new LinearRing(new[] | |
{ | |
new Point(1, 0), | |
new Point(2, 2), | |
new Point(0, 4), | |
new Point(5, 5), | |
new Point(6, 1), | |
new Point(1, 0), | |
}); | |
IPoint centroid = polygon.GetCentroid(); | |
Console.WriteLine("{0:F} {1:F}", centroid.X, centroid.Y); // 3.33 2.58 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geometry = new MultiPoint | |
{ | |
new Point(3, 2), | |
new Point(0, 0), | |
new Point(6, 5), | |
new Point(5, 10), | |
new Point(10, 0), | |
new Point(8, 2), | |
new Point(4, 3), | |
}; | |
var convexHull = geometry.GetConvexHull(); | |
// [0] = (0 0) | |
// [1] = (5 10) | |
// [2] = (10 0) | |
// [3] = (0 0) | |
var ring = (ILinearRing)convexHull; | |
for (int i = 0; i < ring.Count; ++i) | |
{ | |
Console.WriteLine("[{0}] = ({1} {2})", i, ring[i].X, ring[i].Y); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var polygon = new Polygon(); | |
polygon.ExteriorRing = new LinearRing(new[] | |
{ | |
new Point(0, 0), | |
new Point(0, 1), | |
new Point(1, 1), | |
new Point(1, 0), | |
new Point(0, 0), | |
}); | |
var line = new LineString(); | |
line.AddPoint(2, 0); | |
line.AddPoint(1, 3); | |
double distance = polygon.GetDistanceTo(line); | |
Console.WriteLine(distance.ToString("F")); // 0.63 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var line = new LineString(); | |
line.AddPoint(0, 0); | |
line.AddPoint(3, 3); | |
// buffer with positive distance contains all points whose distance to input geometry is less or equal to 'distance' argument. | |
var lineBuffer = line.GetBuffer(distance: 1); | |
Console.WriteLine(lineBuffer.SpatiallyContains(new Point(1, 2))); // True | |
Console.WriteLine(lineBuffer.SpatiallyContains(new Point(3.1, 3.1))); // True | |
var polygon = new Polygon(); | |
polygon.ExteriorRing = new LinearRing(new[] | |
{ | |
new Point(0, 0), | |
new Point(0, 3), | |
new Point(3, 3), | |
new Point(3, 0), | |
new Point(0, 0), | |
}); | |
// buffer with negative distance 'shrinks' geometry. | |
var polygonBuffer = (IPolygon)polygon.GetBuffer(distance: -1); | |
// [0] = (1 1) | |
// [1] = (1 2) | |
// [2] = (2 2) | |
// [3] = (2 1) | |
// [4] = (1 1) | |
var ring = polygonBuffer.ExteriorRing; | |
for (int i = 0; i < ring.Count; ++i) | |
{ | |
Console.WriteLine("[{0}] = ({1} {2})", i, ring[i].X, ring[i].Y); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(40.7128, -74.006); | |
GeometryType geometryType = point.GeometryType; | |
Console.WriteLine(geometryType); // Point |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var line = new LineString(); | |
line.AddPoint(0, 0); | |
line.AddPoint(2, 2); | |
line.AddPoint(2, 0); | |
Console.WriteLine("{0:F}", line.GetLength()); // 4.83 | |
var rectangle = new Polygon(new LinearRing(new[] | |
{ | |
new Point(0, 0), | |
new Point(0, 1), | |
new Point(1, 1), | |
new Point(1, 0), | |
new Point(0, 0), | |
})); | |
// GetLength() returns perimeter for polygons | |
Console.WriteLine("{0:F}", rectangle.GetLength()); // 4.00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var polygon = new Polygon(); | |
polygon.ExteriorRing = new LinearRing(new[] | |
{ | |
new Point(0, 0), | |
new Point(0, 1), | |
new Point(1, 1), | |
new Point(0, 0), | |
}); | |
IPoint pointOnSurface = polygon.GetPointOnSurface(); | |
// point on surface is guaranteed to be inside a polygon. | |
Console.WriteLine(polygon.SpatiallyContains(pointOnSurface)); // True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point pointGeometry = new Point(40.7128, -74.006); | |
LineString lineGeometry = new LineString(); | |
lineGeometry.AddPoint(78.65, -32.65); | |
lineGeometry.AddPoint(-98.65, 12.65); | |
GeometryCollection geometryCollection = new GeometryCollection(); | |
geometryCollection.Add(pointGeometry); | |
geometryCollection.Add(lineGeometry); | |
foreach (Geometry geometry in geometryCollection) | |
{ | |
switch (geometry.GeometryType) | |
{ | |
case GeometryType.Point: | |
Point point = (Point)geometry; | |
break; | |
case GeometryType.LineString: | |
LineString line = (LineString)geometry; | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LineString line = new LineString(); | |
line.AddPoint(78.65, -32.65); | |
line.AddPoint(-98.65, 12.65); | |
foreach (IPoint point in line) | |
{ | |
Console.WriteLine(point.X + "," + point.Y); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = RunExamples.GetDataDir() + "LimitPrecisionWhenReadingGeometries_out.shp"; | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.Shapefile)) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.Geometry = new Point(1.10234, 2.09743); | |
layer.Add(feature); | |
} | |
var options = new ShapefileOptions(); | |
// read data as-is. | |
options.XYPrecisionModel = PrecisionModel.Exact; | |
using (VectorLayer layer = VectorLayer.Open(path, Drivers.Shapefile, options)) | |
{ | |
var point = (IPoint)layer[0].Geometry; | |
// 1.10234, 2.09743 | |
Console.WriteLine("{0}, {1}", point.X, point.Y); | |
} | |
// truncate all X and Y, so only two fractional digits are left. | |
options.XYPrecisionModel = PrecisionModel.Rounding(2); | |
using (VectorLayer layer = VectorLayer.Open(path, Drivers.Shapefile, options)) | |
{ | |
var point = (IPoint)layer[0].Geometry; | |
// 1.1, 2.1 | |
Console.WriteLine("{0}, {1}", point.X, point.Y); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var options = new GeoJsonOptions | |
{ | |
// write only 3 fractional digits of X and Y coordinates. | |
XYPrecisionModel = PrecisionModel.Rounding(3), | |
// write all fractional digits of Z coordinate (the default, you don't have to specify it) | |
ZPrecisionModel = PrecisionModel.Exact | |
}; | |
var path = RunExamples.GetDataDir() + "LimitPrecisionWhenWritingGeometries_out.json"; | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.GeoJson, options)) | |
{ | |
var point = new Point(); | |
point.X = 1.8888888; | |
point.Y = 1.00123; | |
point.Z = 1.123456789; | |
Feature feature = layer.ConstructFeature(); | |
feature.Geometry = point; | |
layer.Add(feature); | |
} | |
using (VectorLayer layer = VectorLayer.Open(path, Drivers.GeoJson)) | |
{ | |
var point = (IPoint)layer[0].Geometry; | |
// 1.889, 1.001, 1.123456789 | |
Console.WriteLine("{0}, {1}, {2}", point.X, point.Y, point.Z); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = RunExamples.GetDataDir() + "LinearizeGeometry_out.kml"; | |
using (var layer = Drivers.Kml.CreateLayer(path)) | |
{ | |
var feature = layer.ConstructFeature(); | |
var geometry = Geometry.FromText(@"GeometryCollection (LineString (0 0, 1 1, 2 0),CompoundCurve ((4 0, 5 1), CircularString (5 1, 6 2, 7 1)))"); | |
// creates linear geometry that approximates input geometry | |
var linear = geometry.ToLinearGeometry(); | |
feature.Geometry = linear; | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(1.344, 2.345, 3.345, 4.345); | |
point.RoundXY(digits: 2); | |
// 1.34, 2.35, 3.345, 4.345 | |
Console.WriteLine("{0}, {1}, {2}, {3}", point.X, point.Y, point.Z, point.M); | |
point.RoundZ(digits: 1); | |
// 1.34, 2.35, 3.3, 4.345 | |
Console.WriteLine("{0}, {1}, {2}, {3}", point.X, point.Y, point.Z, point.M); | |
LineString line = new LineString(); | |
line.AddPoint(1.2, 2.3); | |
line.AddPoint(2.4, 3.1); | |
line.RoundXY(digits: 0); | |
// 1, 2 | |
Console.WriteLine("{0}, {1}", line[0].X, line[0].Y); | |
// 2, 3 | |
Console.WriteLine("{0}, {1}", line[1].X, line[1].Y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
{ | |
var srcGeometry = Geometry.FromText(@"GeometryCollection (POLYGON((1 2, 1 4, 3 4, 3 2)), Point (5 1))"); | |
var dstGeometry = srcGeometry.ReplacePolygonsByLines(); | |
Console.WriteLine($"source: {srcGeometry.AsText()}"); | |
Console.WriteLine($"result: {dstGeometry.AsText()}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// If file format does not support curve geometries, we linearize them on write. | |
// This example shows how to specify tolerance of the linearization. | |
var options = new GeoJsonOptions | |
{ | |
// linearized geometry must be within 1e-4 from curve geometry | |
LinearizationTolerance = 1e-4, | |
}; | |
string path = RunExamples.GetDataDir() + "SpecifyLinearizationTolerance_out.json"; | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.GeoJson, options)) | |
{ | |
var curveGeometry = Geometry.FromText("CircularString (0 0, 1 1, 2 0)"); | |
var feature = layer.ConstructFeature(); | |
feature.Geometry = curveGeometry; | |
// geometry is linearized with tolerance 1e-4 | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
IGeometry geometry = Geometry.FromText("LINESTRING (1.2 3.4, 5.6 7.8)"); | |
byte[] wkb = geometry.AsBinary(WkbVariant.ExtendedPostGis); | |
File.WriteAllBytes(Path.Combine(RunExamples.GetDataDir(), "EWkbFile.ewkb"), wkb); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(23.5732, 25.3421) { M = 40.3 }; | |
point.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
Console.WriteLine(point.AsText(WktVariant.Iso)); // POINT M (23.5732, 25.3421, 40.3) | |
Console.WriteLine(point.AsText(WktVariant.SimpleFeatureAccessOutdated)); // POINT (23.5732, 25.3421) | |
Console.WriteLine(point.AsText(WktVariant.ExtendedPostGis)); // SRID=4326;POINTM (23.5732, 25.3421, 40.3) | |
// to get max a decimal precision | |
Console.WriteLine("G17 : " + point.AsText(WktVariant.Iso, NumericFormat.General(17))); // POINT M (23.5732 25.342099999999999 40.299999999999997) | |
Console.WriteLine("R : " + point.AsText(WktVariant.Iso, NumericFormat.RoundTrip)); // POINT M (23.5732 25.3421 40.3) | |
// to trim a decimal precision | |
Console.WriteLine("G3 : " + point.AsText(WktVariant.Iso, NumericFormat.General(3))); // POINT M (23.6 25.3 40.3) | |
Console.WriteLine("Flat3: " + point.AsText(WktVariant.Iso, NumericFormat.Flat(3))); // POINT M (23.573 25.342 40.3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = Path.Combine(RunExamples.GetDataDir(), "WkbFile.wkb"); | |
byte[] wkb = File.ReadAllBytes(path); | |
IGeometry geometry = Geometry.FromBinary(wkb); | |
Console.WriteLine(geometry.AsText()); // LINESTRING (1.2 3.4, 5.6 7.8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
ILineString line = (ILineString)Geometry.FromText("LINESTRING Z (0.1 0.2 0.3, 1 2 1, 12 23 2)"); | |
Console.WriteLine(line.Count); // 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
IGeometry geometry = Geometry.FromText("LINESTRING (1.2 3.4, 5.6 7.8)"); | |
byte[] wkb = geometry.AsBinary(); | |
//File.WriteAllBytes(Path.Combine(TestConfiguration.TestOutputPath, "file.wkb"), wkb); | |
File.WriteAllBytes(Path.Combine(RunExamples.GetDataDir(), "WkbFile.wkb"), wkb); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(23.5732, 25.3421); | |
Console.WriteLine(point.AsText()); // POINT (23.5732, 25.3421) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string sampleTopoJsonPath = RunExamples.GetDataDir() + "sample.topojson"; | |
StringBuilder builder = new StringBuilder(); | |
using (VectorLayer layer = VectorLayer.Open(sampleTopoJsonPath, Drivers.TopoJson)) | |
{ | |
foreach (Feature feature in layer) | |
{ | |
// get id property | |
int id = feature.GetValue<int>("id"); | |
// get name of the object that contains this feature | |
string objectName = feature.GetValue<string>("topojson_object_name"); | |
// get name attribute property, located inside 'properties' object | |
string name = feature.GetValue<string>("name"); | |
// get geometry of the feature. | |
string geometry = feature.Geometry.AsText(); | |
builder.AppendFormat("Feature with ID {0}:\n", id); | |
builder.AppendFormat("Object Name = {0}\n", objectName); | |
builder.AppendFormat("Name = {0}\n", name); | |
builder.AppendFormat("Geometry = {0}\n", geometry); | |
} | |
} | |
Console.WriteLine("Output:"); | |
Console.WriteLine(builder.ToString()); | |
// Output: | |
// Feature with ID 0: | |
// Object Name = named_object_1 | |
// Name = point_feature | |
// Geometry = POINT (102 0.5) | |
// Feature with ID 1: | |
// Object Name = named_object_1 | |
// Name = line_feature | |
// Geometry = LINESTRING (102 0, 103 1, 104 0, 105 1) | |
// Feature with ID 2: | |
// Object Name = named_object_2 | |
// Name = polygon_feature | |
// Geometry = POLYGON ((100 0, 100 1, 101 1, 101 0, 100 0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// -- copy test dataset, to avoid modification of test data. | |
var path = RunExamples.GetDataDir() + "ThreeLayers.gdb"; | |
var datasetPath = RunExamples.GetDataDir() + "AddLayerToFileGdbDataset_out.gdb"; | |
RunExamples.CopyDirectory(path, datasetPath); | |
// -- | |
using (var dataset = Dataset.Open(datasetPath, Drivers.FileGdb)) | |
{ | |
Console.WriteLine(dataset.CanCreateLayers); // True | |
using (var layer = dataset.CreateLayer("data", SpatialReferenceSystem.Wgs84)) | |
{ | |
layer.Attributes.Add(new FeatureAttribute("Name", AttributeDataType.String)); | |
var feature = layer.ConstructFeature(); | |
feature.SetValue("Name", "Name_1"); | |
feature.Geometry = new Point(12.21, 23.123, 20, -200); | |
layer.Add(feature); | |
} | |
using (var layer = dataset.OpenLayer("data")) | |
{ | |
Console.WriteLine(layer.Count); // 1 | |
Console.WriteLine(layer[0].GetValue<string>("Name")); // "Name_1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var geoJsonPath = RunExamples.GetDataDir() + "ConvertGeoJsonLayerToLayerInFileGdbDataset_out.json"; | |
using (VectorLayer layer = VectorLayer.Create(geoJsonPath, Drivers.GeoJson)) | |
{ | |
layer.Attributes.Add(new FeatureAttribute("name", AttributeDataType.String)); | |
layer.Attributes.Add(new FeatureAttribute("age", AttributeDataType.Integer)); | |
Feature firstFeature = layer.ConstructFeature(); | |
firstFeature.Geometry = new Point(33.97, -118.25); | |
firstFeature.SetValue("name", "John"); | |
firstFeature.SetValue("age", 23); | |
layer.Add(firstFeature); | |
Feature secondFeature = layer.ConstructFeature(); | |
secondFeature.Geometry = new Point(35.81, -96.28); | |
secondFeature.SetValue("name", "Mary"); | |
secondFeature.SetValue("age", 54); | |
layer.Add(secondFeature); | |
} | |
// -- | |
// -- copy test dataset, to avoid modification of test data. | |
var sourceFile = RunExamples.GetDataDir() + "ThreeLayers.gdb"; | |
var destinationFile = RunExamples.GetDataDir() + "ThreeLayersCopy_out.gdb"; | |
RunExamples.CopyDirectory(sourceFile, destinationFile); | |
// -- | |
using (var geoJsonLayer = VectorLayer.Open(geoJsonPath, Drivers.GeoJson)) | |
{ | |
using (var fileGdbDataset = Dataset.Open(destinationFile, Drivers.FileGdb)) | |
using (var fileGdbLayer = fileGdbDataset.CreateLayer("new_layer", SpatialReferenceSystem.Wgs84)) | |
{ | |
fileGdbLayer.CopyAttributes(geoJsonLayer); | |
foreach (var feature in geoJsonLayer) | |
{ | |
fileGdbLayer.Add(feature); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer source = VectorLayer.Open(dataDir + "PolygonShapeFile.shp", Drivers.Shapefile)) | |
{ | |
using (VectorLayer destination = VectorLayer.Create(dataDir + "PolygonShapeFileToLineShapeFile_out.shp", Drivers.Shapefile)) | |
{ | |
foreach (Feature sourceFeature in source) | |
{ | |
Polygon polygon = (Polygon)sourceFeature.Geometry; | |
LineString line = new LineString(polygon.ExteriorRing); | |
Feature destinationFeature = destination.ConstructFeature(); | |
destinationFeature.Geometry = line; | |
destination.Add(destinationFeature); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Console.WriteLine(Drivers.FileGdb.CanCreateDatasets); // True | |
var path = RunExamples.GetDataDir() + "CreateFileGdbDataset_out.gdb"; | |
using (var dataset = Dataset.Create(path, Drivers.FileGdb)) | |
{ | |
Console.WriteLine(dataset.LayersCount); // 0 | |
using (var layer = dataset.CreateLayer("layer_1")) | |
{ | |
layer.Attributes.Add(new FeatureAttribute("value", AttributeDataType.Integer)); | |
for (int i = 0; i < 10; ++i) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.SetValue("value", i); | |
feature.Geometry = new Point(i, i); | |
layer.Add(feature); | |
} | |
} | |
using (var layer = dataset.CreateLayer("layer_2")) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.Geometry = new LineString(new[] | |
{ | |
new Point(1, 2), | |
new Point(3, 4), | |
}); | |
layer.Add(feature); | |
} | |
Console.WriteLine(dataset.LayersCount); // 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var path = RunExamples.GetDataDir() + "CreateFileGdbDatasetWithSingleLayer_out.gdb"; | |
var options = new FileGdbOptions(); | |
using (var layer = VectorLayer.Create(path, Drivers.FileGdb, options, SpatialReferenceSystem.Wgs84)) | |
// this 'using' is equivalent to | |
// using (var dataset = Dataset.Create(path, Drivers.FileGdb)) | |
// using (var layer = Dataset.CreateLayer("layer")) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.Geometry = new LineString(new[] | |
{ | |
new Point(1, 2), | |
new Point(3, 4), | |
}); | |
layer.Add(feature); | |
} | |
using (var dataset = Dataset.Open(path, Drivers.FileGdb)) | |
using (var layer = dataset.OpenLayer("layer")) | |
{ | |
Console.WriteLine("Features count: {0}", layer.Count); // 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Create(dataDir + "NewShapeFile_out.shp", Drivers.Shapefile)) | |
{ | |
// add attributes before adding features | |
layer.Attributes.Add(new FeatureAttribute("name", AttributeDataType.String)); | |
layer.Attributes.Add(new FeatureAttribute("age", AttributeDataType.Integer)); | |
layer.Attributes.Add(new FeatureAttribute("dob", AttributeDataType.DateTime)); | |
// case 1: sets values | |
Feature firstFeature = layer.ConstructFeature(); | |
firstFeature.Geometry = new Point(33.97, -118.25); | |
firstFeature.SetValue("name", "John"); | |
firstFeature.SetValue("age", 23); | |
firstFeature.SetValue("dob", new DateTime(1982, 2,5, 16, 30,0)); | |
layer.Add(firstFeature); | |
Feature secondFeature = layer.ConstructFeature(); | |
secondFeature.Geometry = new Point(35.81, -96.28); | |
secondFeature.SetValue("name", "Mary"); | |
secondFeature.SetValue("age", 54); | |
secondFeature.SetValue("dob", new DateTime(1984, 12, 15, 15, 30, 0)); | |
layer.Add(secondFeature); | |
// case 2: sets new values for all of the attributes. | |
Feature thirdFeature = layer.ConstructFeature(); | |
secondFeature.Geometry = new Point(34.81, -92.28); | |
object[] data = new object[3] {"Alex", 25, new DateTime(1989, 4, 15, 15, 30, 0)}; | |
secondFeature.SetValues(data); | |
layer.Add(thirdFeature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var parameters = new ProjectedSpatialReferenceSystemParameters | |
{ | |
Name = "WGS 84 / World Mercator", | |
Base = SpatialReferenceSystem.Wgs84, | |
ProjectionMethodName = "Mercator_1SP", | |
LinearUnit = Unit.Meter, | |
XAxis = new Axis("Easting", AxisDirection.East), | |
YAxis = new Axis("Northing", AxisDirection.North), | |
AxisesOrder = ProjectedAxisesOrder.XY, | |
}; | |
parameters.AddProjectionParameter("central_meridian", 0); | |
parameters.AddProjectionParameter("scale_factor", 1); | |
parameters.AddProjectionParameter("false_easting", 0); | |
parameters.AddProjectionParameter("false_northing", 0); | |
var projectedSrs = SpatialReferenceSystem.CreateProjected(parameters, Identifier.Epsg(3395)); | |
using (var layer = Drivers.Shapefile.CreateLayer(dataDir + "filepath_out.shp", new ShapefileOptions(), projectedSrs)) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.Geometry = new Point(1, 2); | |
layer.Add(feature); | |
feature = layer.ConstructFeature(); | |
feature.Geometry = new Point(1, 2) { SpatialReferenceSystem = SpatialReferenceSystem.Nad83 }; | |
try | |
{ | |
layer.Add(feature); // geometry of feature has different SRS - exception is thrown | |
} | |
catch (GisException e) | |
{ | |
Console.WriteLine(e.Message); | |
} | |
} | |
using (var layer = Drivers.Shapefile.OpenLayer(dataDir + "filepath_out.shp")) | |
{ | |
var srsName = layer.SpatialReferenceSystem.Name; // "WGS 84 / World Mercator" | |
layer.SpatialReferenceSystem.IsEquivalent(projectedSrs); // true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string filesPath = RunExamples.GetDataDir(); | |
using (var layer = Drivers.GeoTiff.OpenLayer(Path.Combine(filesPath, "geodetic_world.tif"))) | |
using (var warped = layer.Crop(Geometry.FromText("POLYGON ((-160 0, 0 60, 160 0, 0 -160, -160 0))"))) | |
{ | |
// read and print raster | |
var cellSize = warped.CellSize; | |
var extent = warped.GetExtent(); | |
var spatialRefSys = warped.SpatialReferenceSystem; | |
var code = spatialRefSys == null ? "'no srs'" : spatialRefSys.EpsgCode.ToString(); | |
var bounds = warped.Bounds; | |
Console.WriteLine($"cellSize: {cellSize}"); | |
Console.WriteLine($"source extent: {layer.GetExtent()}"); | |
Console.WriteLine($"target extent: {extent}"); | |
Console.WriteLine($"spatialRefSys: {code}"); | |
Console.WriteLine($"bounds: {bounds}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Csv.OpenLayer(dataDir + "sample.csv")) | |
{ | |
// print attributes | |
foreach (var attribute in layer.Attributes) | |
{ | |
Console.Write($"'{attribute.Name}' "); | |
} | |
Console.WriteLine(); | |
// print records | |
foreach (var feature in layer) | |
{ | |
var dump = feature.GetValuesDump(); | |
foreach (var item in dump) | |
{ | |
Console.Write($"'{item}' "); | |
} | |
Console.WriteLine(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Csv.OpenLayer(dataDir + "geometries.csv", | |
new CsvOptions() | |
{ | |
ColumnWkt = "geom_data" | |
})) | |
{ | |
// print geometry in wkt format | |
foreach (var feature in layer) | |
{ | |
Console.Write($"'{feature.Geometry.AsText()}: "); | |
Console.WriteLine(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Csv.OpenLayer(dataDir + "geometries.csv", | |
new CsvOptions() | |
{ | |
ColumnX = "x" , | |
ColumnY = "y", | |
ColumnZ = "z", | |
ColumnM = "m" | |
})) | |
{ | |
// print geometry in wkt format | |
foreach (var feature in layer) | |
{ | |
Console.Write($"'{feature.Geometry.AsText()}: "); | |
Console.WriteLine(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// apply a custom delimiter and a column for geometry. | |
var options = new CsvOptions() | |
{ | |
ColumnWkt = "geom_data", | |
Delimiter = ';' | |
}; | |
// create a new CSV layer | |
using (var layer = Drivers.Csv.CreateLayer(dataDir + "csv_out.csv", options)) | |
{ | |
layer.Attributes.Add(new FeatureAttribute("string_data", AttributeDataType.String)); | |
layer.Attributes.Add(new FeatureAttribute("int_data", AttributeDataType.Integer)); | |
layer.Attributes.Add(new FeatureAttribute("bool_data", AttributeDataType.Boolean)); | |
layer.Attributes.Add(new FeatureAttribute("float_data", AttributeDataType.Double)); | |
Feature feature = layer.ConstructFeature(); | |
feature.SetValue("string_data", "string value"); | |
feature.SetValue("int_data", 10); | |
feature.SetValue("bool_data", true); | |
feature.SetValue("float_data", 3.14); | |
feature.Geometry = new LineString(new[] { new Point(0, 0), new Point(1, 1) }); | |
layer.Add(feature); | |
Feature feature2 = layer.ConstructFeature(); | |
feature2.SetValue("string_data", "string value2"); | |
feature2.SetValue("int_data", 100); | |
feature2.SetValue("bool_data", false); | |
feature2.SetValue("float_data", 3.1415); | |
feature2.Geometry = Geometry.Null; | |
layer.Add(feature2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Kml.EditLayer(Path.Combine(workFolder, "edit_me_out.kml"))) | |
{ | |
// add | |
Feature featureToAdd = layer.ConstructFeature(); | |
featureToAdd.SetValue("string_field", "new_value"); | |
featureToAdd.Geometry = new Point(5, 5); | |
layer.Add(featureToAdd); | |
// update | |
Feature featureToReplace = layer.ConstructFeature(); | |
featureToReplace.SetValue("string_field", "updated_value"); | |
featureToReplace.Geometry = new Point(12, 12); | |
layer.ReplaceAt(1, featureToReplace); | |
// remove | |
layer.RemoveAt(0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer inputLayer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile)) | |
{ | |
using (VectorLayer outputLayer = VectorLayer.Create(dataDir + "ExtractFeaturesFromShapeFileToGeoJSON_out.json", Drivers.GeoJson)) | |
{ | |
outputLayer.CopyAttributes(inputLayer); | |
foreach (Feature inputFeature in inputLayer) | |
{ | |
DateTime? date = inputFeature.GetValue<DateTime?>("dob"); | |
if (date == null || date < new DateTime(1982, 1, 1)) | |
{ | |
continue; | |
} | |
//Construct a new feature | |
Feature outputFeature = outputLayer.ConstructFeature(); | |
outputFeature.Geometry = inputFeature.Geometry; | |
outputFeature.CopyValues(inputFeature); | |
outputLayer.Add(outputFeature); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile)) | |
{ | |
// all features with the date value in the attribute "dob" later than 1982-01-01. | |
foreach (Feature feature in layer.WhereGreater("dob", new DateTime(1982, 1, 1, 0, 0, 0))) | |
{ | |
Console.WriteLine(feature.GetValue<DateTime>("dob").ToShortDateString()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = VectorLayer.Open(citiesPath, Drivers.GeoJson)) | |
{ | |
// Select features based on values of the attribute. This code enumerates all features in the layer | |
// and selects all features that match a condition. | |
var features = layer.WhereGreaterOrEqual("population", 2000).WhereSmaller("population", 5000); | |
// Print results. | |
Console.WriteLine("Cities where population >= 2000 and population < 5000:"); | |
foreach (var feature in features) | |
{ | |
var name = feature.GetValue<string>("name"); | |
var population = feature.GetValue<int>("population"); | |
Console.WriteLine(name + ", " + population); | |
} | |
Console.WriteLine(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = VectorLayer.Open(path, Drivers.GeoJson)) | |
{ | |
// Use spatial index to speed up spatial queries. | |
// Aspose.GIS builds a new index if it doesn't exist, otherwise existing index is reused. | |
// Any path can be used. | |
var spatialIndexPath = Path.ChangeExtension(path, ".spatial_out.ix"); | |
layer.UseSpatialIndex(spatialIndexPath); | |
var point = new Point(12.30, 50.33); | |
// Since we use spatial index, nearest-to finds the closest feature much faster. | |
var nearest = layer.NearestTo(point); | |
Console.WriteLine("City nearest to (12.30 50.33) is " + nearest.GetValue<string>("name")); | |
Console.WriteLine(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = VectorLayer.Open(path, Drivers.GeoJson)) | |
{ | |
// Use spatial index to speed up 'WhereIntersects'. | |
var spatialIndexPath = Path.ChangeExtension(path, ".spatial_out.ix"); | |
layer.UseSpatialIndex(spatialIndexPath); | |
var polygon = Geometry.FromText("Polygon((12.30 50.33, 22.49 54.87, 21.92 42.53, 12.30 50.33))"); | |
var intersecting = layer.WhereIntersects(polygon); | |
Console.WriteLine("Cities within " + polygon.AsText() + ":"); | |
foreach (var feature in intersecting) | |
{ | |
var name = feature.GetValue<string>("name"); | |
var location = (IPoint) feature.Geometry; | |
Console.WriteLine($"{name} at ({location.X}, {location.Y})"); | |
} | |
Console.WriteLine(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = VectorLayer.Open(citiesPath, Drivers.GeoJson)) | |
{ | |
// Use attribute index to speed up search by 'population' attribute. | |
// Aspose.GIS builds a new index if it doesn't exist, otherwise existing index is reused. | |
// Any path can be used. | |
var attributeIndexPath = Path.ChangeExtension(citiesPath, "population_out.ix"); | |
layer.UseAttributesIndex(attributeIndexPath, "population"); | |
// Select features based on values of the attribute. Since we use attribute index it is not necessary to | |
// test all features of the layer and filtering time is reduced significantly. | |
var towns = layer.WhereGreaterOrEqual("population", 2000).WhereSmaller("population", 5000); | |
// Print results. | |
Console.WriteLine("Cities where population >= 2000 and population < 5000:"); | |
foreach (var town in towns) | |
{ | |
var name = town.GetValue<string>("name"); | |
var population = town.GetValue<int>("population"); | |
Console.WriteLine(name + ", " + population); | |
} | |
Console.WriteLine(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(600, 400)) | |
using (var cities = VectorLayer.Open(citiesPath, Drivers.GeoJson)) | |
{ | |
map.Padding = 20; | |
// Use attribute index to speed up search by 'population' attribute. | |
var attributeIndexPath = Path.ChangeExtension(citiesPath, "population_out.ix"); | |
cities.UseAttributesIndex(attributeIndexPath, "population"); | |
// Render all cities with population greater than 2000. | |
map.Add(cities.WhereGreater("population", 2000), new SimpleMarker { FillColor = Color.Red }); | |
map.Render(outputPath, Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = VectorLayer.Open(citiesPath, Drivers.GeoJson)) | |
{ | |
// Use attribute index to speed up search by 'population' attribute. | |
var attributeIndexPath = Path.ChangeExtension(citiesPath, "population_out.ix"); | |
layer.UseAttributesIndex(attributeIndexPath, "population"); | |
// Save all features with population between 2000 and 5000 to the output file. | |
layer.WhereGreaterOrEqual("population", 2000) | |
.WhereSmaller("population", 5000) | |
.SaveTo(DataDir + "towns_out.shp", Drivers.Shapefile); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile)) | |
{ | |
Console.WriteLine("Total Features in this file: " + layer.Count); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile)) | |
{ | |
Console.WriteLine("The layer has {0} attributes defined.\n", layer.Attributes.Count); | |
foreach (FeatureAttribute attribute in layer.Attributes) | |
{ | |
Console.WriteLine("Name: {0}", attribute.Name); | |
Console.WriteLine("Data type: {0}", attribute.DataType); | |
Console.WriteLine("Can be null: {0}", attribute.CanBeNull); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile)) | |
{ | |
for (int i = 0; i < layer.Count; i++) | |
{ | |
Feature feature = layer[i]; | |
Console.WriteLine("Entry {0} information\n ========================", i); | |
// case 1 | |
string nameValue = feature.GetValue<string>("name"); // attribute name is case-sensitive | |
int ageValue = feature.GetValue<int>("age"); | |
string dobValue = feature.GetValue<DateTime>("dob").ToString(); | |
Console.WriteLine("Attribute value for feature #{0} is: {1}, {2}", nameValue, ageValue, dobValue); | |
// case 2 | |
var objName = feature.GetValue("name"); // attribute name is case-sensitive | |
var objAge = feature.GetValue("age"); | |
var objDob = feature.GetValue("dob"); | |
Console.WriteLine("Attribute object for feature #{0} is: {1}, {2}", objName, objAge, objDob); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile)) | |
{ | |
int index = 0; | |
foreach (Feature feature in layer) | |
{ | |
DateTime? date = feature.GetValue<DateTime?>("dob"); | |
Console.WriteLine("Feature #{0}", index); | |
Console.WriteLine("\tAttribute value present: {0}", date.HasValue); | |
if (date.HasValue) | |
{ | |
Console.WriteLine("\tAttribute value: {0}", date.Value); | |
} | |
index++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
//You can set default value for a feature of attribute in a layer | |
using (var layer = Drivers.GeoJson.CreateLayer(dataDir + "data1_out.json")) | |
{ | |
var attribute = new FeatureAttribute("attribute", AttributeDataType.Integer); | |
attribute.CanBeNull = true; | |
attribute.CanBeUnset = true; | |
layer.Attributes.Add(attribute); | |
Feature feature = layer.ConstructFeature(); | |
int? nullValue = feature.GetValueOrDefault<int?>("attribute"); // value == null | |
var defValue1 = feature.GetValueOrDefault<int?>("attribute", 10); // value == 10 | |
var defValue2 = feature.GetValueOrDefault("attribute", 25); // value == 10 | |
Console.WriteLine($"'{nullValue}' vs '{defValue1}' vs '{defValue2}'"); | |
} | |
//Another example where we set the default value to 100 | |
using (var layer = Drivers.GeoJson.CreateLayer(dataDir + "data2_out.json")) | |
{ | |
var attribute = new FeatureAttribute("attribute", AttributeDataType.Double); | |
attribute.CanBeNull = false; | |
attribute.CanBeUnset = false; | |
attribute.DefaultValue = 100; | |
layer.Attributes.Add(attribute); | |
Feature feature = layer.ConstructFeature(); | |
double defValue1 = feature.GetValueOrDefault<double>("attribute"); // value == 100 | |
var defValue2 = feature.GetValueOrDefault("attribute"); // value == 100 | |
feature.SetValue("attribute", 50); | |
var newValue = feature.GetValueOrDefault<double>("attribute"); // value == 50 | |
Console.WriteLine($"'{defValue1}' vs '{defValue2}' vs '{newValue}'"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile)) | |
{ | |
foreach (var feature in layer) | |
{ | |
// reads all the attributes into an array. | |
object[] all = new object[3]; | |
feature.GetValues(all); | |
Console.WriteLine("all : {0}, {1}, {2}", all); | |
// reads several the attributes into an array. | |
object[] several = new object[2]; | |
feature.GetValues(several); | |
Console.WriteLine("several: {0}, {1}", several); | |
// reads the attributes as dump of objects. | |
var dump = feature.GetValuesDump(); | |
Console.WriteLine("dump : {0}, {1}, {2}", dump); | |
Console.WriteLine(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var options = new GpxOptions { MAttribute = "speed" }; | |
using (var layer = Drivers.Gpx.OpenLayer(dataDir + "schiehallion.gpx")) | |
{ | |
var routeFeature = layer.Single(feature => feature.Geometry.GeometryType == GeometryType.LineString); | |
var routeGeometry = (ILineString)routeFeature.Geometry; | |
// some route points might miss "speed", we filter them out. | |
var pointsWithSpeed = routeGeometry.Where(point => point.HasM); | |
// since we specified MAttribute = "speed", M coordinate of points is set to "<speed>" GPX attribute. | |
double averageSpeed = pointsWithSpeed.Average(point => point.M); | |
Console.WriteLine("Average Speed: " + averageSpeed); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Gpx.OpenLayer(dataDir + "schiehallion.gpx")) | |
{ | |
foreach (var feature in layer) | |
{ | |
switch (feature.Geometry.GeometryType) | |
{ | |
// GPX waypoints are exported as features with point geometry. | |
case GeometryType.Point: | |
Console.WriteLine(feature.Geometry.Dimension); | |
//HandleGpxWaypoint(feature); | |
break; | |
// GPX routes are exported as features with line string geometry. | |
case GeometryType.LineString: | |
//HandleGpxRoute(feature); | |
LineString ls = (LineString)feature.Geometry; | |
foreach (var point in ls) | |
{ | |
Console.WriteLine(point.AsText()); | |
} | |
break; | |
// GPX tracks are exported as features with multi line string geometry. | |
// Every track segment is line string. | |
case GeometryType.MultiLineString: | |
//HandleGpxTrack(feature); | |
Console.WriteLine(feature.Geometry.AsText()); | |
break; | |
default: break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// specify option | |
GpxOptions options = new GpxOptions() | |
{ | |
ReadNestedAttributes = true | |
}; | |
// open GPX layer to read features | |
using (var layer = Drivers.Gpx.OpenLayer(dataDir + "nested_data.gpx", options)) | |
{ | |
foreach (var feature in layer) | |
{ | |
if (feature.Geometry.GeometryType == GeometryType.MultiLineString) | |
{ | |
// read segment | |
var lines = (MultiLineString) feature.Geometry; | |
for (int i = 0; i < lines.Count; i++) | |
{ | |
Console.WriteLine($"....segment({i})......"); | |
var segment = (LineString)lines[i]; | |
// read points in segment | |
for (int j = 0; j < segment.Count; j++) | |
{ | |
// look for attribute | |
string attributeName = $"name__{i}__{j}"; | |
if (layer.Attributes.Contains(attributeName) && feature.IsValueSet(attributeName)) | |
{ | |
// print a point and attribute | |
var value = feature.GetValue<string>(attributeName); | |
Console.WriteLine($"{segment[j].AsText()} - {attributeName}: {value}, "); | |
} | |
else | |
{ | |
// print a point only | |
Console.WriteLine(segment[j].AsText()); | |
} | |
} | |
} | |
Console.WriteLine(".........."); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Gpx.CreateLayer(dataDir + "lines_out.gpx", new GpxOptions() | |
{ | |
WritePolygonsAsLines = true | |
})) | |
{ | |
// The GPX format does not support polygons, | |
// but we use the WritePolygonsAsLines options to resolve this issue. | |
Feature feature = layer.ConstructFeature(); | |
feature.Geometry = Geometry.FromText("POLYGON((1 2, 1 4, 3 4, 3 2))"); | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// First, we create the connection to the PostgreSQL with Npgsql library (https://www.nuget.org/packages/Npgsql/) | |
using (var connection = new NpgsqlConnection(postgreSqlConnectionString)) | |
{ | |
connection.Open(); | |
// Then, we pass this connection to Dataset.Open method in order to access tables in the PostgreSQL. | |
using (var ds = Dataset.Open(connection, Drivers.PostGis)) | |
{ | |
// create table with the name "features_table" and fill it with data. | |
using (var layer = ds.CreateLayer("features_table")) | |
{ | |
layer.Attributes.Add(new FeatureAttribute("name", AttributeDataType.String) { Width = 50 }); | |
var feature = layer.ConstructFeature(); | |
feature.SetValue("name", "Name1"); | |
feature.Geometry = Geometry.FromText("POINT (10 20 30)"); | |
layer.Add(feature); | |
feature = layer.ConstructFeature(); | |
feature.SetValue("name", "Name2"); | |
feature.Geometry = Geometry.FromText("POINT (-10 -20 -30)"); | |
layer.Add(feature); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var outputPath = Path.Combine(RunExamples.GetDataDir(), "postgres_out.shp"); | |
// First, we create the connection to the PostgreSQL with Npgsql library (https://www.nuget.org/packages/Npgsql/) | |
// Then, we pass this connection to Dataset.Open method in order to access tables in the PostgreSQL. | |
using (var connection = new NpgsqlConnection(postgreSqlConnectionString)) | |
{ | |
connection.Open(); | |
using (var ds = Dataset.Open(connection, Drivers.PostGis)) | |
{ | |
// open table with the name "features_table" in Postgres database and save it to the shapefile. | |
using (var table = ds.OpenLayer("features_table")) | |
{ | |
table.SaveTo(outputPath, Drivers.Shapefile); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// First, we create the connection to the PostgreSQL with Npgsql library (https://www.nuget.org/packages/Npgsql/) | |
// Then, we pass this connection to Dataset.Open method in order to access tables in the PostgreSQL. | |
using (var connection = new NpgsqlConnection(postgreSqlConnectionString)) | |
{ | |
connection.Open(); | |
using (var ds = Dataset.Open(connection, Drivers.PostGis)) | |
{ | |
// Only spatial tables are exported as layers, so the following code will list all tables | |
// that have geometry column. | |
for (int i = 0; i < ds.LayersCount; ++i) | |
{ | |
Console.WriteLine(ds.GetLayerName(i)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string filesPath = RunExamples.GetDataDir(); | |
using (var layer = Drivers.GeoTiff.OpenLayer(Path.Combine(filesPath, "raster50x50.tif"))) | |
{ | |
// read and print raster | |
var cellSize = layer.CellSize; | |
var extent = layer.GetExtent(); | |
var spatialRefSys = layer.SpatialReferenceSystem; | |
var code = spatialRefSys == null ? "'no srs'" : spatialRefSys.EpsgCode.ToString(); | |
var bounds = layer.Bounds; | |
var bandCount = layer.BandCount; | |
Console.WriteLine($"cellSize: {cellSize}"); | |
Console.WriteLine($"extent: {extent}"); | |
Console.WriteLine($"spatialRefSys: {code}"); | |
Console.WriteLine($"bounds: {bounds}"); | |
Console.WriteLine($"bandCount: {bandCount}"); | |
// read and print bands | |
for (int i = 0; i < layer.BandCount; i++) | |
{ | |
var dataType = layer.GetBand(i).DataType; | |
var hasNoData = !layer.NoDataValues.IsNull(); | |
var statistics = layer.GetStatistics(i); | |
Console.WriteLine(); | |
Console.WriteLine($"Band: {i}"); | |
Console.WriteLine($"dataType: {dataType}"); | |
Console.WriteLine($"statistics: {statistics}"); | |
Console.WriteLine($"hasNoData: {hasNoData}"); | |
if (hasNoData) | |
Console.WriteLine($"noData: {layer.NoDataValues[i]}"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// First, we create the connection to the SQL Server. | |
using (var connection = new SqlConnection(connectionString)) | |
{ | |
connection.Open(); | |
// Then, we pass this connection to Dataset.Open method in order to access tables in the SQL Server. | |
using (var ds = Dataset.Open(connection, Drivers.SqlServer)) | |
{ | |
// create table with the name "features_table" and fill it with data. | |
using (var layer = ds.CreateLayer("features_table")) | |
{ | |
layer.Attributes.Add(new FeatureAttribute("name", AttributeDataType.String) { Width = 50 }); | |
var feature = layer.ConstructFeature(); | |
feature.SetValue("name", "Name1"); | |
feature.Geometry = Geometry.FromText("POINT (10 20 30)"); | |
layer.Add(feature); | |
feature = layer.ConstructFeature(); | |
feature.SetValue("name", "Name2"); | |
feature.Geometry = Geometry.FromText("POINT (-10 -20 -30)"); | |
layer.Add(feature); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var outputPath = Path.Combine(RunExamples.GetDataDir(), "sql_server_out.kml"); | |
// First, we create the connection to the SQL Server. | |
using (var connection = new SqlConnection(connectionString)) | |
{ | |
connection.Open(); | |
// Then, we pass this connection to Dataset.Open method in order to access tables in the SQL Server. | |
using (var ds = Dataset.Open(connection, Drivers.SqlServer)) | |
{ | |
// open table with the name "features_table" in SQL Server database and save it to the Kml. | |
using (var table = ds.OpenLayer("features_table")) | |
{ | |
table.SaveTo(outputPath, Drivers.Kml); | |
} | |
Console.WriteLine("\nExport complete: " + outputPath); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// First, we create the connection to the SQL Server. | |
using (var connection = new SqlConnection(connectionString)) | |
{ | |
connection.Open(); | |
// Then, we pass this connection to Dataset.Open method in order to access tables in the SQL Server. | |
using (var ds = Dataset.Open(connection, Drivers.SqlServer)) | |
{ | |
// Only spatial tables are exported as layers, so the following code will list all tables | |
// that have geometry column. | |
for (int i = 0; i < ds.LayersCount; ++i) | |
{ | |
Console.WriteLine(ds.GetLayerName(i)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// First, we create the connection to the SQL Server. | |
using (var connection = new SqlConnection(connectionString)) | |
{ | |
connection.Open(); | |
// Then, we pass this connection to Dataset.Open method in order to access tables in the SQL Server. | |
using (var ds = Dataset.Open(connection, Drivers.SqlServer)) | |
{ | |
// remove table with the name "features_table". | |
// It possible remove a table with geospatial data only. | |
// An exception isn't thrown if the table doesn't exist. | |
ds.RemoveLayer("features_table"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile)) | |
{ | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.Geometry.AsText()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
private class InsensitiveComparer : IEqualityComparer<object> | |
{ | |
bool IEqualityComparer<object>.Equals(object x, object y) | |
{ | |
if (x == null || y == null) | |
{ | |
return x == y; | |
} | |
var xString = x.ToString(); | |
var yString = y.ToString(); | |
return xString.Equals(yString, StringComparison.InvariantCultureIgnoreCase); | |
} | |
public int GetHashCode(object obj) | |
{ | |
return obj.ToString().ToLower().GetHashCode(); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
//one-to-one left join two layers by 'city' attribute | |
var options = new JoinOptions | |
{ | |
JoinAttributeName = "city", | |
TargetAttributeName = "city" | |
}; | |
using (var main = Drivers.Kml.OpenLayer(Path.Combine(workFolder, "main.kml"))) | |
using (var second = Drivers.Kml.OpenLayer(Path.Combine(workFolder, "second.kml"))) | |
using (var joined = main.Join(second, options)) | |
{ | |
// read and print joined | |
var featuresCount = joined.Count; | |
var attributesCount = joined.Attributes.Count; | |
var spatialRefSys = joined.SpatialReferenceSystem; | |
var code = spatialRefSys == null ? "'no srs'" : spatialRefSys.EpsgCode.ToString(); | |
var joinedTempValue = joined[0].GetValue("joined_temp"); | |
Console.WriteLine($"featuresCount: {featuresCount}"); | |
Console.WriteLine($"attributesCount: {attributesCount}"); | |
Console.WriteLine($"spatialRefSys: {code}"); | |
Console.WriteLine($"joinedTempValue: {joinedTempValue}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
//one-to-one left join two layers by 'city' attribute | |
var options = new JoinOptions | |
{ | |
JoinAttributeName = "city", | |
TargetAttributeName = "city", | |
//define attributes to join | |
JoinAttributeNames = new List<string> { "temp", "date" } | |
}; | |
using (var main = Drivers.Kml.OpenLayer(Path.Combine(workFolder, "main.kml"))) | |
using (var second = Drivers.Kml.OpenLayer(Path.Combine(workFolder, "second.kml"))) | |
using (var joined = main.Join(second, options)) | |
{ | |
// read and print joined | |
var featuresCount = joined.Count; | |
var attributesCount = joined.Attributes.Count; | |
var spatialRefSys = joined.SpatialReferenceSystem; | |
var code = spatialRefSys == null ? "'no srs'" : spatialRefSys.EpsgCode.ToString(); | |
Console.WriteLine($"featuresCount: {featuresCount}"); | |
Console.WriteLine($"attributesCount: {attributesCount}"); | |
Console.WriteLine($"spatialRefSys: {code}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
//one-to-one left join two layers by 'city' attribute | |
var options = new JoinOptions | |
{ | |
JoinAttributeName = "city", | |
TargetAttributeName = "city", | |
//use custom comparer | |
ConditionComparer = new InsensitiveComparer() | |
}; | |
using (var main = Drivers.Kml.OpenLayer(Path.Combine(workFolder, "main.kml"))) | |
using (var second = Drivers.Kml.OpenLayer(Path.Combine(workFolder, "second.kml"))) | |
using (var joined = main.Join(second, options)) | |
{ | |
// read and print joined | |
var featuresCount = joined.Count; | |
var attributesCount = joined.Attributes.Count; | |
var spatialRefSys = joined.SpatialReferenceSystem; | |
var code = spatialRefSys == null ? "'no srs'" : spatialRefSys.EpsgCode.ToString(); | |
var cityValue = joined[4].GetValue("city"); | |
var joinedCityValue = joined[4].GetValue("joined_city"); | |
Console.WriteLine($"featuresCount: {featuresCount}"); | |
Console.WriteLine($"attributesCount: {attributesCount}"); | |
Console.WriteLine($"spatialRefSys: {code}"); | |
Console.WriteLine($"cityValue: {cityValue}"); | |
Console.WriteLine($"joinedCityValue: {joinedCityValue}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Kml.CreateLayer(dataDir + "Kml_File_out.kml")) | |
{ | |
layer.Attributes.Add(new FeatureAttribute("string_data", AttributeDataType.String)); | |
layer.Attributes.Add(new FeatureAttribute("int_data", AttributeDataType.Integer)); | |
layer.Attributes.Add(new FeatureAttribute("bool_data", AttributeDataType.Boolean)); | |
layer.Attributes.Add(new FeatureAttribute("float_data", AttributeDataType.Double)); | |
Feature feature = layer.ConstructFeature(); | |
feature.SetValue("string_data", "string value"); | |
feature.SetValue("int_data", 10); | |
feature.SetValue("bool_data", true); | |
feature.SetValue("float_data", 3.14); | |
feature.Geometry = new LineString(new[] { new Point(0, 0), new Point(1, 1) }); | |
layer.Add(feature); | |
Feature feature2 = layer.ConstructFeature(); | |
feature2.SetValue("string_data", "string value2"); | |
feature2.SetValue("int_data", 100); | |
feature2.SetValue("bool_data", false); | |
feature2.SetValue("float_data", 3.1415); | |
feature2.Geometry = Geometry.Null; | |
layer.Add(feature2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Kml.CreateLayer(dataDir + "Kml_Styles_out.kml")) | |
{ | |
var style = new KmlFeatureStyle | |
{ | |
Line = new KmlLineStyle() { Width = 2.0 }, | |
Polygon = new KmlPolygonStyle() { Outline = false }, | |
Icon = new KmlIconStyle() { Resource = new KmlIconResource() { Href = "url" } }, | |
Label = new KmlLabelStyle() { Color = Color.Green }, | |
Balloon = new KmlBalloonStyle() { BackgroundColor = Color.Aqua, Text = "Example" }, | |
List = new KmlListStyle() { ItemType = KmlItemTypes.RadioFolder }, | |
}; | |
Feature feature = layer.ConstructFeature(); | |
feature.Geometry = new LineString(new[] { new Point(0, 0), new Point(1, 1) }); | |
layer.Add(feature, style); | |
Feature feature2 = layer.ConstructFeature(); | |
feature2.Geometry = new Point(5, 5); | |
layer.Add(feature2, style); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var path = dataDir + "kml_invalid_chars.kml"; | |
using (var layer = Drivers.Kml.OpenLayer(path, new KmlOptions() { SymbolToReplaceInvalidChars = '_' } )) | |
{ | |
foreach (var feature in layer) | |
{ | |
Console.WriteLine(feature.GetValue("name")); | |
Console.WriteLine(feature.GetValue("description")); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.Kml.OpenLayer(dataDir + "kml_file.kml")) | |
{ | |
// get feratures count | |
int count = layer.Count; | |
// get feature at index 1 | |
Feature featureAtIndex1 = layer[0]; | |
Console.WriteLine(featureAtIndex1.GetValue<string>("string_data")); | |
Feature featureAtIndex2 = layer[1]; | |
Console.WriteLine(featureAtIndex2.GetValue<string>("string_data")); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string path = Path.Combine(dataDir, "point_xyz_out", "point_xyz.shp"); | |
using (var layer = Drivers.Shapefile.EditLayer(path)) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.SetValue<int>("ID", 5); | |
feature.Geometry = new Point(-5, 5) {Z = 2}; | |
layer.Add(feature); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (Dataset dataset = Dataset.Open(datasetPath, Drivers.FileGdb)) | |
{ | |
using (var source = dataset.OpenLayer("layer2")) | |
using (var result = dataset.CreateLayer("modified", source.SpatialReferenceSystem)) | |
{ | |
result.CopyAttributes(source); | |
foreach (var feature in source) | |
{ | |
// modify the geometry | |
var modifiedGeometry = feature.Geometry.GetBuffer(2.0); | |
feature.Geometry = modifiedGeometry; | |
// modify a feature attribute | |
var attributeValue = feature.GetValue<double>("Value"); | |
var modifiedAttributeValue = attributeValue * 2; | |
feature.SetValue("Value", modifiedAttributeValue); | |
result.Add(feature); | |
} | |
} | |
// optional: remove the source layer from the dataset | |
dataset.RemoveLayer("layer2"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string sourcePath = Path.Combine(dataDir, "InputShapeFile.shp"); | |
string resultPath = Path.Combine(dataDir, "modified_out.shp"); | |
using (var source = VectorLayer.Open(sourcePath, Drivers.Shapefile)) | |
using (var result = VectorLayer.Create(resultPath, | |
Drivers.Shapefile, | |
source.SpatialReferenceSystem)) | |
{ | |
result.CopyAttributes(source); | |
foreach (var feature in source) | |
{ | |
// modify the geometry | |
var modifiedGeometry = feature.Geometry.GetBuffer(2.0); | |
feature.Geometry = modifiedGeometry; | |
// modify a feature attribute | |
var attributeValue = feature.GetValue<string>("name"); | |
var modifiedAttributeValue = attributeValue.ToUpper(); | |
feature.SetValue("name", modifiedAttributeValue); | |
result.Add(feature); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
GmlOptions options = new GmlOptions | |
{ | |
// In this example we specify custom schemaLocation, since there is no 'schemaLocation' in GML file. | |
SchemaLocation = "http://www.aspose.com schema.xsd", | |
LoadSchemasFromInternet = false, | |
}; | |
Console.WriteLine(""); | |
Console.WriteLine("custom schema location..."); | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "file_without_schema_location.gml", Drivers.Gml, options)) | |
{ | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.GetValue<string>("attribute")); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Case 1: we try to load schema from Internet. | |
// first, we create an instance of GmlOptions class. | |
GmlOptions options = new GmlOptions | |
{ | |
// In order to read GML layers features description, Aspose.GIS reads XML schema attached to it. | |
// Usually, it is specified in GML files root tag as 'schemaLocation' attribute. If it is not, you need to specify GML schema location | |
// youself. In this examples we don't specify it (keep it null), so Aspose.GIS will try to read schema location from XML file. | |
SchemaLocation = null, | |
// 'schemaLocation' may contain references to schemas located on the Internet. In this case, you need to set this property to 'true' in | |
// order to allow Aspose.GIS to load schemas from internet. | |
// Basically, if you don't mind Aspose.GIS using internet, you can always keep this true. | |
LoadSchemasFromInternet = true, | |
}; | |
// then, we pass it to 'VectorLayer.Open' | |
Console.WriteLine("from internet loading..."); | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "file.gml", Drivers.Gml, options)) | |
{ | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.GetValue<string>("attribute")); | |
} | |
} | |
// Case 2: we try to restore the attributes schema by data in file. | |
Console.WriteLine(""); | |
Console.WriteLine("restoration by file data..."); | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "file.gml", Drivers.Gml, new GmlOptions(){RestoreSchema = true})) | |
{ | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.GetValue<string>("attribute")); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string dataDir = RunExamples.GetDataDir(); | |
using (var layer = Drivers.MapInfoInterchange.OpenLayer(Path.Combine(dataDir, "data.mif"))) | |
{ | |
Console.WriteLine($"Number of features is {layer.Count}."); | |
var lastGeometry = layer[layer.Count - 1].Geometry; | |
Console.WriteLine($"Last geometry is {lastGeometry.AsText()}."); | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.Geometry.AsText()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string TestDataPath = RunExamples.GetDataDir(); | |
using (var layer = Drivers.MapInfoTab.OpenLayer(Path.Combine(TestDataPath, "data.tab"))) | |
{ | |
Console.WriteLine($"Number of features is {layer.Count}."); | |
var lastGeometry = layer[layer.Count - 1].Geometry; | |
Console.WriteLine($"Last geometry is {lastGeometry.AsText()}."); | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.Geometry.AsText()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var layer = Drivers.OsmXml.OpenLayer(dataDir + "fountain.osm")) | |
{ | |
// get feratures count | |
int count = layer.Count; | |
Console.WriteLine("Layer count: " + count); | |
// get feature at index 2 | |
Feature featureAtIndex2 = layer[2]; | |
// iterate through all features. | |
foreach (Feature feature in layer) | |
{ | |
// handle feature | |
Console.WriteLine(feature.Geometry.AsText()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
const string geoJson = @"{""type"":""FeatureCollection"",""features"":[ | |
{""type"":""Feature"",""geometry"":{""type"":""Point"",""coordinates"":[0, 1]},""properties"":{""name"":""John""}}, | |
{""type"":""Feature"",""geometry"":{""type"":""Point"",""coordinates"":[2, 3]},""properties"":{""name"":""Mary""}} | |
]}"; | |
using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(geoJson))) | |
using (var layer = VectorLayer.Open(AbstractPath.FromStream(memoryStream), Drivers.GeoJson)) | |
{ | |
Console.WriteLine(layer.Count); // 2 | |
Console.WriteLine(layer[1].GetValue<string>("name")); // Mary | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
//This will convert FileGDB dataset with three layers into single layered GeoJSON. | |
VectorLayer.Convert(dataDir + "ThreeLayers.gdb", Drivers.FileGdb, dataDir + "ThreeLayers_out.json", Drivers.GeoJson); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
//File GDB is a multi layer format. This example shows how to open File GDB as a dataset (collection of layers) and access layers in it. | |
using (var dataset = Dataset.Open(dataDir + "ThreeLayers.gdb", Drivers.FileGdb)) | |
{ | |
Console.WriteLine("FileGDB has {0} layers", dataset.LayersCount); | |
for (int i = 0; i < dataset.LayersCount; ++i) | |
{ | |
Console.WriteLine("Layer {0} name: {1}", i, dataset.GetLayerName(i)); | |
using (var layer = dataset.OpenLayerAt(i)) | |
{ | |
Console.WriteLine("Layer has {0} features", layer.Count); | |
foreach (var feature in layer) | |
{ | |
Console.WriteLine(feature.Geometry.AsText()); | |
} | |
} | |
Console.WriteLine(""); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
//FileGDB can still be opened as a single layer. In this case, the opened layer will merge all layers inside FileGDB. | |
using (var layer = VectorLayer.Open(dataDir + "ThreeLayers.gdb", Drivers.FileGdb)) | |
{ | |
Console.WriteLine("All layers in FileGDB has {0} features", layer.Count); | |
foreach (var feature in layer) | |
{ | |
Console.WriteLine(feature.Geometry.AsText()); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
//By the moment the only multi layer file format we support is FileGDB. But you can open files of other formats as datasets. | |
//In this case, the dataset will have one layer. | |
using (var dataset = Dataset.Open(dataDir + "PolygonShapeFile.shp", Drivers.Shapefile)) | |
{ | |
Console.WriteLine(dataset.LayersCount); // 1 | |
Console.WriteLine(dataset.GetLayerName(0)); // "point" | |
using (var layer = dataset.OpenLayerAt(0)) | |
// this 'using' is equivalent to | |
// using(var layer = VectorLayer.Open("point.shp", Drivrs.Shapefile)) | |
{ | |
foreach (var feature in layer) | |
{ | |
Console.WriteLine(feature.Geometry.AsText()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var dataset = Dataset.Open(path, Drivers.FileGdb)) | |
using (var layer = dataset.OpenLayer("layer")) | |
{ | |
foreach (var feature in layer) | |
{ | |
Console.WriteLine(feature.GetValue<int>("OBJECTID")); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// -- copy test dataset, to avoid modification of test data. | |
//var datasetPath = GetOutputPath(".gdb"); | |
var path = RunExamples.GetDataDir() + "ThreeLayers.gdb"; | |
var datasetPath = RunExamples.GetDataDir() + "RemoveLayersFromFileGdbDataset_out.gdb"; | |
RunExamples.CopyDirectory(path, datasetPath); | |
// -- | |
using (var dataset = Dataset.Open(datasetPath, Drivers.FileGdb)) | |
{ | |
Console.WriteLine(dataset.CanRemoveLayers); // True | |
Console.WriteLine(dataset.LayersCount); // 3 | |
// remove layer by index | |
dataset.RemoveLayerAt(2); | |
Console.WriteLine(dataset.LayersCount); // 2 | |
// remove layer by name | |
dataset.RemoveLayer("layer1"); | |
Console.WriteLine(dataset.LayersCount); // 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (VectorLayer layer = VectorLayer.Create(dataDir + "SpecifyAttributeValueLength_out.shp", Drivers.Shapefile)) | |
{ | |
// add attributes before adding features | |
FeatureAttribute attribute = new FeatureAttribute("wide", AttributeDataType.String); | |
attribute.Width = 120; | |
layer.Attributes.Add(attribute); | |
Feature feature = layer.ConstructFeature(); | |
feature.SetValue("wide", "this string can be up to 120 characters long now."); | |
layer.Add(feature); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var srs = SpatialReferenceSystem.CreateFromEpsg(26918); | |
using (VectorLayer layer = VectorLayer.Create(path, Drivers.Shapefile, srs)) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.Geometry = new Point(60, 24); | |
layer.Add(feature); | |
} | |
using (VectorLayer layer = VectorLayer.Open(path, Drivers.Shapefile)) | |
{ | |
Console.WriteLine(layer.SpatialReferenceSystem.EpsgCode); // 26918 | |
Console.WriteLine(layer.SpatialReferenceSystem.Name); // NAD83_UTM_zone_18N | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var path = RunExamples.GetDataDir() + "NamesOfObjectIdAndGeometryFields_out.gdb"; | |
using (var dataset = Dataset.Create(path, Drivers.FileGdb)) | |
{ | |
var options = new FileGdbOptions | |
{ | |
// name object ID field 'OID' rather than the default 'OBJECTID'. | |
ObjectIdFieldName = "OID", | |
// name geometry field 'POINT' rather than the default 'SHAPE'. | |
GeometryFieldName = "POINT", | |
}; | |
using (var layer = dataset.CreateLayer("layer_name", options, SpatialReferenceSystem.Wgs84)) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.Geometry = new Point(12.32, 34.21); | |
layer.Add(feature); | |
} | |
using (var layer = dataset.OpenLayer("layer_name")) | |
{ | |
var feature = layer[0]; | |
Console.WriteLine(feature.GetValue<int>("OID")); // 1 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var path = RunExamples.GetDataDir() + "PrecisionGrid_out.gdb"; | |
using (var dataset = Dataset.Create(path, Drivers.FileGdb)) | |
{ | |
var options = new FileGdbOptions | |
{ | |
// specify coordinate precision grid parameters (origins and scales for coordinates) | |
CoordinatePrecisionGrid = new FileGdbCoordinatePrecisionGrid | |
{ | |
// all our coordinates must be more than (-400, -400) point | |
XOrigin = -400, | |
YOrigin = -400, | |
// the write precision is 10 digits after the decimal point | |
XYScale = 1e10, | |
// M values are started at 0 and precision is 4 digits after the decimal point | |
MOrigin = 0, | |
MScale = 1e4, | |
}, | |
// throw whenever an attempt to write coordinate that does not fit precision grid is detected | |
EnsureValidCoordinatesRange = true, | |
}; | |
using (var layer = dataset.CreateLayer("layer_name", options, SpatialReferenceSystem.Wgs84)) | |
{ | |
var feature = layer.ConstructFeature(); | |
feature.Geometry = new Point(10, 20) { M = 10.1282 }; | |
layer.Add(feature); | |
feature = layer.ConstructFeature(); | |
// X == -410 is less than XOrigin, so an exception is thrown | |
feature.Geometry = new Point(-410, 0) { M = 20.2343 }; | |
try | |
{ | |
layer.Add(feature); | |
} | |
catch (GisException e) | |
{ | |
Console.WriteLine(e.Message); // X value -410 is out of valid range. | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var path = RunExamples.GetDataDir() + "TolerancesForFileGdbLayer_out.gdb"; | |
using (var dataset = Dataset.Create(path, Drivers.FileGdb)) | |
{ | |
var options = new FileGdbOptions | |
{ | |
XYTolerance = 0.001, | |
ZTolerance = 0.1, | |
MTolerance = 0.1, | |
}; | |
using (var layer = dataset.CreateLayer("layer_name", options)) | |
{ | |
// layer is created with the provided tolerances and some ArcGIS features/tools will use it | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string filesPath = RunExamples.GetDataDir(); | |
using (var layer = Drivers.GeoTiff.OpenLayer(Path.Combine(filesPath, "raster_float32.tif"))) | |
{ | |
Extent sourceExtent = layer.GetExtent(); | |
var newExtent = new Extent( | |
sourceExtent.XMin, | |
sourceExtent.YMin, | |
sourceExtent.XMin + sourceExtent.Width * 0.5, | |
sourceExtent.YMax + sourceExtent.Height * 0.5, | |
layer.SpatialReferenceSystem); | |
using (var warped = layer.Warp(new WarpOptions() { CellWidth = 120, CellHeight = 120, TargetExtent = newExtent })) | |
{ | |
// read and print raster | |
var cellSize = warped.CellSize; | |
var extent = warped.GetExtent(); | |
var spatialRefSys = warped.SpatialReferenceSystem; | |
var code = spatialRefSys == null ? "'no srs'" : spatialRefSys.EpsgCode.ToString(); | |
var bounds = warped.Bounds; | |
Console.WriteLine($"cellSize: {cellSize}"); | |
Console.WriteLine($"source extent: {sourceExtent}"); | |
Console.WriteLine($"target extent: {extent}"); | |
Console.WriteLine($"spatialRefSys: {code}"); | |
Console.WriteLine($"bounds: {bounds}"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string filesPath = RunExamples.GetDataDir(); | |
using (var layer = Drivers.GeoTiff.OpenLayer(Path.Combine(filesPath, "raster_float32.tif"))) | |
using (var warped = layer.Warp(new WarpOptions(){Height = 40, Width = 40, TargetSpatialReferenceSystem = SpatialReferenceSystem.Wgs84})) | |
{ | |
// read and print raster | |
var cellSize = warped.CellSize; | |
var extent = warped.GetExtent(); | |
var spatialRefSys = warped.SpatialReferenceSystem; | |
var code = spatialRefSys == null ? "'no srs'" : spatialRefSys.EpsgCode.ToString(); | |
var bounds = warped.Bounds; | |
var bandCount = warped.BandCount; | |
Console.WriteLine($"cellSize: {cellSize}"); | |
Console.WriteLine($"extent: {extent}"); | |
Console.WriteLine($"spatialRefSys: {code}"); | |
Console.WriteLine($"bounds: {bounds}"); | |
Console.WriteLine($"bandCount: {bandCount}"); | |
// read and print bands | |
for (int i = 0; i < warped.BandCount; i++) | |
{ | |
var dataType = warped.GetBand(i).DataType; | |
var hasNoData = !warped.NoDataValues.IsNull(); | |
var statistics = warped.GetStatistics(i); | |
Console.WriteLine(); | |
Console.WriteLine($"Band: {i}"); | |
Console.WriteLine($"dataType: {dataType}"); | |
Console.WriteLine($"statistics: {statistics}"); | |
Console.WriteLine($"hasNoData: {hasNoData}"); | |
if (hasNoData) | |
Console.WriteLine($"noData: {warped.NoDataValues[i]}"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var outputPath = RunExamples.GetDataDir() + "sample_out.topojson"; | |
using (VectorLayer layer = VectorLayer.Create(outputPath, Drivers.TopoJson)) | |
{ | |
// add attributes that we are going to set | |
layer.Attributes.Add(new FeatureAttribute("name", AttributeDataType.String)); | |
layer.Attributes.Add(new FeatureAttribute("measurement", AttributeDataType.Double)); | |
layer.Attributes.Add(new FeatureAttribute("id", AttributeDataType.Integer)); | |
var feature0 = layer.ConstructFeature(); | |
feature0.SetValue("name", "name_0"); | |
feature0.SetValue("measurement", 1.03); | |
feature0.SetValue("id", 0); | |
feature0.Geometry = new Point(1.3, 2.3); | |
layer.Add(feature0); | |
var feature1 = layer.ConstructFeature(); | |
feature1.SetValue("name", "name_1"); | |
feature1.SetValue("measurement", 10.03); | |
feature1.SetValue("id", 1); | |
feature1.Geometry = new Point(241.32, 23.2); | |
layer.Add(feature1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var memoryStream = new MemoryStream()) | |
{ | |
using (var layer = VectorLayer.Create(AbstractPath.FromStream(memoryStream), Drivers.GeoJson)) | |
{ | |
layer.Attributes.Add(new FeatureAttribute("name", AttributeDataType.String)); | |
layer.Attributes.Add(new FeatureAttribute("age", AttributeDataType.Integer)); | |
Feature firstFeature = layer.ConstructFeature(); | |
firstFeature.Geometry = new Point(33.97, -118.25); | |
firstFeature.SetValue("name", "John"); | |
firstFeature.SetValue("age", 23); | |
layer.Add(firstFeature); | |
Feature secondFeature = layer.ConstructFeature(); | |
secondFeature.Geometry = new Point(35.81, -96.28); | |
secondFeature.SetValue("name", "Mary"); | |
secondFeature.SetValue("age", 54); | |
layer.Add(secondFeature); | |
} | |
Console.WriteLine(Encoding.UTF8.GetString(memoryStream.ToArray())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 320)) | |
{ | |
// open a layer containing the data | |
var layer = VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson); | |
// create a map layer (a styled representation of the data) | |
var mapLayer = new VectorMapLayer(layer); | |
// import a style from an SLD document | |
mapLayer.ImportSld(dataDir + "lines.sld"); | |
// add the styled layer to the map and render it | |
map.Add(mapLayer); | |
map.Render(dataDir + "lines_sld_style_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(1000, 634)) | |
{ | |
var symbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xAE, 0xD9, 0xFD) }; | |
var labeling = new SimpleLabeling(labelAttribute: "name"); | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer, labeling); | |
map.Padding = 50; | |
map.Render(dataDir + "lines_labeling_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(1000, 634)) | |
{ | |
var symbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xAE, 0xD9, 0xFD) }; | |
var labeling = new SimpleLabeling(labelAttribute: "name") | |
{ | |
HaloSize = 1, | |
Placement = new LineLabelPlacement | |
{ | |
Alignment = LineLabelAlignment.Curved, | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer, labeling); | |
map.Padding = 50; | |
map.Render(dataDir + "lines_labeling_curved_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(1000, 634)) | |
{ | |
var symbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xAE, 0xD9, 0xFD) }; | |
var labeling = new SimpleLabeling(labelAttribute: "name") | |
{ | |
HaloSize = 1, | |
Placement = new LineLabelPlacement | |
{ | |
Alignment = LineLabelAlignment.Curved, | |
Offset = 5, | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer, labeling); | |
map.Padding = 50; | |
map.Render(dataDir + "lines_labeling_curved_offset_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(1000, 634)) | |
{ | |
var lineSymbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xae, 0xd9, 0xfd) }; | |
lineSymbolizer.FeatureBasedConfiguration = (feature, symbolizer) => | |
{ | |
if (feature.GetValue<string>("NAM") == "UNK") | |
{ | |
symbolizer.Width = 1; | |
symbolizer.Style = StrokeStyle.Dash; | |
} | |
}; | |
var lineLabeling = new SimpleLabeling(labelAttribute: "name") | |
{ | |
HaloSize = 1, | |
Placement = new LineLabelPlacement | |
{ | |
Alignment = LineLabelAlignment.Parallel, | |
}, | |
FontSize = 20, | |
FeatureBasedConfiguration = (feature, labeling) => | |
{ | |
if (feature.GetValue<string>("NAM") == "UNK") | |
{ | |
// change labeling properties for some features. | |
labeling.FontStyle = FontStyle.Italic; | |
labeling.FontSize = 10; | |
labeling.Priority = -1; | |
var placement = (LineLabelPlacement) labeling.Placement; | |
placement.Alignment = LineLabelAlignment.Curved; | |
placement.Offset = 5; | |
} | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), lineSymbolizer, lineLabeling); | |
map.Padding = 50; | |
map.Render(dataDir + "lines_labeling_feature_based_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(1000, 634)) | |
{ | |
var symbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xAE, 0xD9, 0xFD) }; | |
var labeling = new SimpleLabeling(labelAttribute: "name") | |
{ | |
HaloSize = 1, | |
Placement = new LineLabelPlacement | |
{ | |
Alignment = LineLabelAlignment.Parallel, | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer, labeling); | |
map.Padding = 50; | |
map.Render(dataDir + "lines_labeling_parallel_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new SimpleMarker | |
{ | |
FillColor = Color.LightGray, | |
StrokeStyle = StrokeStyle.None | |
}; | |
var labeling = new SimpleLabeling(labelAttribute: "name"); | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol, labeling); | |
map.Padding = 50; | |
map.Render(dataDir + "points_labeling_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var pointLabeling = new SimpleLabeling("name") | |
{ | |
HaloSize = 1, | |
Placement = new PointLabelPlacement | |
{ | |
VerticalAnchorPoint = VerticalAnchor.Bottom, | |
HorizontalAnchorPoint = HorizontalAnchor.Left, | |
VerticalOffset = 4, | |
HorizontalOffset = 4, | |
}, | |
FeatureBasedConfiguration = (feature, labeling) => | |
{ | |
// Retrieve population from the feature. | |
var population = feature.GetValue<int>("population"); | |
// Font size is computed and is based on the population. | |
labeling.FontSize = Math.Min(20, 5 * population / 1000); | |
// Priority of the label is also based on the population. | |
// The greater the priority is, the more likely label will appear on the output image. | |
labeling.Priority = population; | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), new SimpleMarker(), pointLabeling); | |
map.Padding = 50; | |
map.Render(dataDir + "points_labeling_feature_based_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new SimpleMarker | |
{ | |
FillColor = Color.LightGray, | |
StrokeStyle = StrokeStyle.None | |
}; | |
var labeling = new SimpleLabeling(labelAttribute: "name") | |
{ | |
HaloSize = 1, | |
Placement = new PointLabelPlacement | |
{ | |
VerticalAnchorPoint = VerticalAnchor.Bottom, | |
HorizontalAnchorPoint = HorizontalAnchor.Left, | |
HorizontalOffset = 2, | |
VerticalOffset = 2, | |
Rotation = 10, | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol, labeling); | |
map.Padding = 50; | |
map.Render(dataDir + "points_labeling_placed_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new SimpleMarker | |
{ | |
FillColor = Color.LightGray, | |
StrokeStyle = StrokeStyle.None | |
}; | |
var labeling = new SimpleLabeling(labelAttribute: "name") | |
{ | |
HaloSize = 2, | |
HaloColor = Color.LightGray, | |
FontSize = 15, | |
FontStyle = FontStyle.Italic, | |
}; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol, labeling); | |
map.Padding = 50; | |
map.Render(dataDir + "points_labeling_styled_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbolizer = new SimpleMarker {FillColor = Color.LightGray, StrokeStyle = StrokeStyle.None}; | |
var labeling = new RuleBasedLabeling(); | |
// Set labeling to be used for small cities. | |
labeling.Add(f => f.GetValue<int>("population") <= 2500, new SimpleLabeling("name") | |
{ | |
FontStyle = FontStyle.Italic, | |
HaloSize = 1, | |
FontSize = 10, | |
FontColor = Color.Green, | |
Priority = 1, | |
Placement = new PointLabelPlacement | |
{ | |
VerticalAnchorPoint = VerticalAnchor.Bottom, | |
HorizontalAnchorPoint = HorizontalAnchor.Center, | |
} | |
}); | |
// Set labeling to be used for all other cities. | |
labeling.AddElseRule(new SimpleLabeling("name") | |
{ | |
HaloSize = 1, | |
FontSize = 15, | |
FontColor = Color.Red, | |
Priority = 2, | |
Placement = new PointLabelPlacement | |
{ | |
VerticalAnchorPoint = VerticalAnchor.Bottom, | |
HorizontalAnchorPoint = HorizontalAnchor.Center, | |
} | |
}); | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbolizer, labeling); | |
map.Padding = 40; | |
map.Render(dataDir + "rule_based_labeling_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var mapPath = Path.Combine(RunExamples.GetDataDir(), "out_osm_tile.png"); | |
// we use the osm tile server | |
string url = "http://tile.openstreetmap.org/{z}/{x}/{y}.png"; | |
using (var layer = Drivers.XyzTiles.OpenLayer(new XyzConnection(url))) | |
{ | |
// print tile info | |
var tile = layer.GetTile(2, 3, 1); | |
Console.WriteLine($"CellX: {tile.CellX}, CellY: {tile.CellY}" ); | |
Console.WriteLine($"Path: {tile.AsPath()}"); | |
// render tile | |
var resampling = new RasterMapResampling() { Height = 256, Width = 256 }; | |
using (var map = new Map(800, 800)) | |
{ | |
var raster = tile.AsRaster(); | |
map.Add(new RasterMapLayer(raster){Resampling = resampling}); | |
map.Render(mapPath, Renderers.Png); | |
} | |
Console.WriteLine($"Rendered Map: {mapPath}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var mapPath = Path.Combine(RunExamples.GetDataDir(), "out_osm_tiles.png"); | |
// we use the osm tile server | |
string url = "http://tile.openstreetmap.org/{z}/{x}/{y}.png"; | |
using (var layer = Drivers.XyzTiles.OpenLayer(new XyzConnection(url))) | |
{ | |
// print tiles info | |
var extent = new Extent(-90, -40, 90, 40) {SpatialReferenceSystem = SpatialReferenceSystem.Wgs84}; | |
var tiles = layer.GetTiles(2, extent).ToList(); | |
// render tiles | |
var resampling = new RasterMapResampling() { Height = 800, Width = 800 }; | |
using (var map = new Map(800, 800)) | |
{ | |
foreach (var tile in tiles) | |
{ | |
var raster = tile.AsRaster(); | |
map.Add(new RasterMapLayer(raster) { Resampling = resampling }); | |
} | |
map.Render(mapPath, Renderers.Png); | |
} | |
Console.WriteLine($"Rendered Map: {mapPath}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string url = "C://tiles/{z}/{x}/{y}.png"; | |
using (var layer = Drivers.XyzTiles.OpenLayer(new XyzConnection(url))) | |
{ | |
// print tile info | |
var tile = layer.GetTile(0, 0, 0); | |
Console.WriteLine($"CellX: {tile.CellX}, CellY: {tile.CellY}"); | |
Console.WriteLine($"Path: {tile.AsPath()}"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(800, 476)) | |
{ | |
var baseMapSymbolizer = new SimpleFill { FillColor = Color.Salmon, StrokeWidth = 0.75 }; | |
map.Add(VectorLayer.Open(dataDir + "basemap.shp", Drivers.Shapefile), baseMapSymbolizer); | |
var citiesSymbolizer = new SimpleMarker() { FillColor = Color.LightBlue }; | |
citiesSymbolizer.FeatureBasedConfiguration = (feature, symbolizer) => | |
{ | |
var population = feature.GetValue<int>("population"); | |
symbolizer.Size = 10 * population / 1000; | |
if (population < 2500) | |
{ | |
symbolizer.FillColor = Color.GreenYellow; | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), citiesSymbolizer); | |
map.Render(dataDir + "cities_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 450)) | |
{ | |
var symbolizer = new SimpleFill { FillColor = Color.Azure, StrokeColor = Color.Brown }; | |
map.Add(VectorLayer.Open(dataDir + "polygons.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "polygons_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 317)) | |
{ | |
var symbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xAE, 0xD9, 0xFD) }; | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "lines_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 317)) | |
{ | |
var lineSymbolizer = new SimpleLine { Width = 1.5, Color = Color.FromArgb(0xae, 0xd9, 0xfd) }; | |
lineSymbolizer.FeatureBasedConfiguration = (feature, symbolizer) => | |
{ | |
if (feature.GetValue<string>("NAM") == "UNK") | |
{ | |
symbolizer.Width = 1; | |
symbolizer.Style = StrokeStyle.Dash; | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), lineSymbolizer); | |
map.Render(dataDir + "lines_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new SimpleMarker() { Size = 7, StrokeWidth = 1, FillColor = Color.Red }; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol); | |
map.Padding = 20; | |
map.Render(dataDir + "points_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new SimpleMarker() { FillColor = Color.LightBlue }; | |
symbol.FeatureBasedConfiguration = (feature, symbolizer) => | |
{ | |
// retirieve city population (in thousands) from a feature attribute | |
var population = feature.GetValue<int>("population"); | |
// let's increase circle radius by 5 pixels for each million people | |
symbolizer.Size = 5 * population / 1000; | |
// and let's draw cities with less than 2.5M people in green | |
if (population < 2500) | |
{ | |
symbolizer.FillColor = Color.GreenYellow; | |
} | |
}; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol); | |
map.Padding = 20; | |
map.Render(dataDir + "points_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new SimpleMarker() | |
{ | |
Size = 15, | |
FillColor = Color.DarkMagenta, | |
StrokeStyle = StrokeStyle.None, | |
ShapeType = MarkerShapeType.Triangle, | |
Rotation = 90 | |
}; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol); | |
map.Padding = 20; | |
map.Render(dataDir + "points_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 300)) | |
{ | |
// take only part of the word | |
map.Extent = new Extent(-100, -60, 100, 60){SpatialReferenceSystem = SpatialReferenceSystem.Wgs84}; | |
// use difference colors for nested cluster points. | |
Color[] colors = new Color[] { Color.Green, Color.Aquamarine, Color.Gold, Color.Fuchsia, Color.Red, Color.Blue, Color.Brown, Color.Thistle, Color.Cyan, }; | |
var count = 0; | |
// create a cluster symbolizer and setup a cluster size | |
var symbolizer = new MarkerCluster(Measurement.Pixels(15)) | |
{ | |
// use own a style for each a cluster | |
FeaturesBasedConfiguration = (features, cluster) => | |
{ | |
// use more size for more points | |
var itemsInCluster = features.Count(); | |
cluster.Marker = new SimpleMarker() {FillColor = Color.Red, Size = 3 + itemsInCluster % 10}; | |
// allow draw inner cluster points (by default is none) | |
cluster.NestedMarker = new SimpleMarker() {FillColor = colors[count % colors.Length], Size = 3, StrokeStyle = StrokeStyle.None }; | |
count++; | |
}, | |
}; | |
map.Add(VectorLayer.Open(dataDir + "land.shp", Drivers.Shapefile)); | |
map.Add(VectorLayer.Open(dataDir + "places.shp", Drivers.Shapefile), symbolizer); | |
map.Padding = 20; | |
map.Render(dataDir + "out_cluster_countries.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 300)) | |
{ | |
// take only part of the word | |
map.Extent = new Extent(-100, -60, 100, 60) { SpatialReferenceSystem = SpatialReferenceSystem.Wgs84 }; | |
// create a cluster symbolizer and setup a cluster size | |
var clusterSymbolizer = new MarkerCluster(Measurement.Pixels(25)) | |
{ | |
// Use own a style for each a cluster | |
FeaturesBasedConfiguration = (features, cluster) => | |
{ | |
var itemsInCluster = features.Count(); | |
// First, we create an image with a drawn number for the cluster. This code not optimized of memory using. | |
// It is better to load prepare pictures from your file system. | |
var digitText = itemsInCluster.ToString(); | |
Stream memoryStream; | |
using (Bitmap digitBitmap = new Bitmap(40, 40)) | |
{ | |
using (Graphics graphics = Graphics.FromImage(digitBitmap)) | |
{ | |
// increase text quality | |
graphics.SmoothingMode = SmoothingMode.AntiAlias; | |
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; | |
if (digitText.Length == 1) | |
{ | |
graphics.DrawString(digitText, new Font("Arial", 30, GraphicsUnit.Pixel), | |
new SolidBrush(Color.Black), 5, 3); | |
} | |
else | |
{ | |
graphics.DrawString(digitText, new Font("Arial", 30, GraphicsUnit.Pixel), | |
new SolidBrush(Color.Black), -4, 3); | |
} | |
graphics.Flush(); | |
} | |
// store the bitmap to a stream | |
memoryStream = new MemoryStream(); | |
digitBitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png); | |
} | |
var pathToDigit = AbstractPath.FromStream(memoryStream); | |
// Secondly, we use RasterImageMarker which renders our image (bitmap). | |
var symbolizer = new RasterImageMarker(pathToDigit) | |
{ | |
Width = Measurement.Pixels(12), | |
Height = Measurement.Pixels(12), | |
VerticalAnchorPoint = VerticalAnchor.Center, | |
HorizontalAnchorPoint = HorizontalAnchor.Center | |
}; | |
// As result, we create a complex symbolizer to join a background circle and the drawn digit. | |
var complexMarker = new LayeredSymbolizer(); | |
complexMarker.Add(new SimpleMarker() {Size = Measurement.Pixels(16), FillColor = Color.Azure}); | |
complexMarker.Add(symbolizer); | |
cluster.Marker = complexMarker; | |
}, | |
}; | |
// add layers with symbolizers | |
map.Padding = 20; | |
map.Add(VectorLayer.Open(dataDir + "land.shp", Drivers.Shapefile), new SimpleLine(){Width = 0.5 }); | |
map.Add(VectorLayer.Open(dataDir + "places.shp", Drivers.Shapefile), clusterSymbolizer); | |
// complete our map creation | |
map.Render(dataDir + "out_cluster_texts.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 450)) | |
{ | |
var symbolizer = new SimpleFill(); | |
map.Add(VectorLayer.Open(dataDir + "polygons.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "polygons_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 317)) | |
{ | |
var symbolizer = new SimpleLine(); | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "lines_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new SimpleMarker(); | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol); | |
map.Padding = 20; | |
map.Render(dataDir + "points_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(200, 200)) | |
{ | |
var symbolizer = new LayeredSymbolizer(RenderingOrder.ByFeatures); | |
symbolizer.Add(new SimpleLine { Width = 10, Color = Color.Black }); | |
symbolizer.Add(new SimpleLine { Width = 8, Color = Color.White }); | |
map.Add(VectorLayer.Open(dataDir + "intersection.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "intersection_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(200, 200)) | |
{ | |
var symbolizer = new LayeredSymbolizer(RenderingOrder.ByLayers); | |
symbolizer.Add(new SimpleLine { Width = 10, Color = Color.Black }); | |
symbolizer.Add(new SimpleLine { Width = 8, Color = Color.White }); | |
map.Add(VectorLayer.Open(dataDir + "intersection.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "intersection_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new GeometryGenerator | |
{ | |
Expression = f => | |
{ | |
return f.Geometry.GetBuffer(30_000); | |
}, | |
Symbolizer = new SimpleFill | |
{ | |
FillColor = Color.LightBlue, | |
StrokeColor = Color.Blue, | |
}, | |
}; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol); | |
map.Padding = 20; | |
map.SpatialReferenceSystem = SpatialReferenceSystem.WebMercator; | |
map.Render(dataDir + "geometry_generator_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 450)) | |
{ | |
var symbolizer = new MarkerPatternFill | |
{ | |
Marker = new SimpleMarker | |
{ | |
ShapeType = MarkerShapeType.Triangle, | |
FillColor = Color.Red, | |
Size = 5 | |
}, | |
HorizontalInterval = 10, | |
VerticalInterval = 10 | |
}; | |
map.Add(VectorLayer.Open(dataDir + "polygons.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "polygons_marker_fill_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 317)) | |
{ | |
var symbolizer = new MarkerLine | |
{ | |
Marker = new SimpleMarker | |
{ | |
ShapeType = MarkerShapeType.Circle, | |
FillColor = Color.Coral, | |
Size = 4 | |
}, | |
Interval = 10 | |
}; | |
map.Add(VectorLayer.Open(dataDir + "lines.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "marker_line_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 210)) | |
{ | |
var symbolizer = new MixedGeometrySymbolizer(); | |
symbolizer.PointSymbolizer = new SimpleMarker { FillColor = Color.Red, Size = 10 }; | |
symbolizer.LineSymbolizer = new SimpleLine { Color = Color.Blue }; | |
symbolizer.PolygonSymbolizer = new SimpleFill { FillColor = Color.Green }; | |
map.Add(VectorLayer.Open(dataDir + "mixed.geojson", Drivers.GeoJson), symbolizer); | |
map.Render(dataDir + "mixed_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(500, 200)) | |
{ | |
var symbol = new RasterImageMarker(imagePath: dataDir + "cross.png") | |
{ | |
Width = 30, | |
Height = 30, | |
Rotation = 45, | |
}; | |
map.Add(VectorLayer.Open(dataDir + "points.geojson", Drivers.GeoJson), symbol); | |
map.Padding = 20; | |
map.Render(dataDir + "raster_marker_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(800, 400)) | |
{ | |
map.Add(VectorLayer.Open(dataDir + "land.shp", Drivers.Shapefile)); | |
map.SpatialReferenceSystem = SpatialReferenceSystem.CreateFromEpsg(54024); // World Bonne | |
map.Render(dataDir + "land_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(800, 400)) | |
{ | |
map.Add(VectorLayer.Open(dataDir + "land.shp", Drivers.Shapefile)); | |
map.Render(dataDir + "land_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
using (var map = new Map(600, 400)) | |
{ | |
var symbolizer = new RuleBasedSymbolizer(); | |
symbolizer.Add(f => f.GetValue<string>("sov_a3") == "CAN", new SimpleLine { Color = Color.FromArgb(213, 43, 30) }); | |
symbolizer.Add(f => f.GetValue<string>("sov_a3") == "USA", new SimpleLine { Color = Color.FromArgb(15, 71, 175) }); | |
symbolizer.Add(f => f.GetValue<string>("sov_a3") == "MEX", new SimpleLine { Color = Color.FromArgb(0, 104, 71) }); | |
symbolizer.Add(f => f.GetValue<string>("sov_a3") == "CUB", new SimpleLine { Color = Color.FromArgb(255, 215, 0) }); | |
map.Add(VectorLayer.Open(dataDir + "railroads.shp", Drivers.Shapefile), symbolizer); | |
map.Render(dataDir + "railroads_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string filesPath = RunExamples.GetDataDir(); | |
// make own multi colorizer it works faster than auto-detection | |
var colorizer = new MultiBandColor() | |
{ | |
RedBand = new BandColor() { BandIndex = 0, Min = 0, Max = 255 }, | |
GreenBand = new BandColor() { BandIndex = 1, Min = 0, Max = 255 }, | |
BlueBand = new BandColor() { BandIndex = 2, Min = 0, Max = 255 } | |
}; | |
using (var map = new Map(500, 500)) | |
{ | |
// setup the polar extent and coordinate system (gnomonic spatial reference) | |
map.SpatialReferenceSystem = SpatialReferenceSystem.CreateFromEpsg(102034); | |
map.Extent = new Extent(-180, 60, 180, 90) { SpatialReferenceSystem = SpatialReferenceSystem.Wgs84 }; | |
map.BackgroundColor = Color.Azure; | |
// open geo-tiff | |
var layer = Drivers.GeoTiff.OpenLayer(Path.Combine(filesPath, "raster_countries.tif")); | |
// draw | |
map.Add(layer, colorizer); | |
map.Render(filesPath + "raster_countries_gnomonic_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string filesPath = RunExamples.GetDataDir(); | |
using (var map = new Map(500, 500)) | |
{ | |
var layer = Drivers.GeoTiff.OpenLayer(Path.Combine(filesPath, "raster_float32.tif")); | |
// Conversion to colors is detected automatically. | |
// The maximum and minimum values are calculated and linear interpolation is used. | |
map.Add(layer); | |
map.Render(filesPath + "raster_float32_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string filesPath = RunExamples.GetDataDir(); | |
using (var map = new Map(500, 500)) | |
{ | |
// use background color | |
map.BackgroundColor = Color.Azure; | |
var layer = Drivers.GeoTiff.OpenLayer(Path.Combine(filesPath, "raster_skew.tif")); | |
// Conversion to colors is detected automatically. | |
// The maximum and minimum values are calculated and linear interpolation is used. | |
map.Add(layer); | |
map.Render(filesPath + "raster_skew_out.svg", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs72); // true | |
Drivers.GeoJson.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84); // true | |
Drivers.GeoJson.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs72); // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string wkt = @" | |
GEOGCS[""WGS 84"", | |
DATUM[""WGS_1984"", | |
SPHEROID[""WGS 84"",6378137,298.257223563, | |
AUTHORITY[""EPSG"",""7030""]], | |
AUTHORITY[""EPSG"",""6326""]], | |
PRIMEM[""Greenwich"",0, | |
AUTHORITY[""EPSG"",""8901""]], | |
UNIT[""degree"",0.01745329251994328, | |
AUTHORITY[""EPSG"",""9122""]], | |
AUTHORITY[""EPSG"",""4326""]] | |
"; | |
var srs = SpatialReferenceSystem.CreateFromWkt(wkt); | |
srs.IsEquivalent(SpatialReferenceSystem.Wgs84); // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var srs = SpatialReferenceSystem.CreateFromEpsg(26918); | |
Console.WriteLine("SRS Name: {0}", srs.Name); // NAD83 / UTM zone 18N | |
Console.WriteLine("SRS EPSG code: {0}", srs.EpsgCode); // 26918 | |
Console.WriteLine("Datum name: {0}", srs.GeographicDatum.Name); // North_American_Datum_1983 | |
Console.WriteLine("Datum EPSG code: {0}", srs.GeographicDatum.EpsgCode); // 6269 | |
Console.WriteLine("Ellipsoid name: {0}", srs.GeographicDatum.Ellipsoid.Name); // GRS 1980 | |
Console.WriteLine("Ellipsoid EPSG code: {0}", srs.GeographicDatum.EpsgCode); // 6269 | |
Console.WriteLine("Type: {0}", srs.Type); // Projected | |
Console.WriteLine("Dimensions count: {0}", srs.DimensionsCount); // 2 | |
Console.WriteLine("First dimension name: {0}", srs.GetAxis(0).Name); // X | |
Console.WriteLine("First dimension direction: {0}", srs.GetAxis(0).Direction); // East | |
Console.WriteLine("Second dimension name: {0}", srs.GetAxis(1).Name); // Y | |
Console.WriteLine("Second dimension direction: {0}", srs.GetAxis(1).Direction); // North | |
Console.WriteLine("First dimension unit: {0}, {1}", srs.GetUnit(0).Name, srs.GetUnit(0).Factor); // metre, 1 | |
Console.WriteLine("Second dimension unit: {0}, {1}", srs.GetUnit(1).Name, srs.GetUnit(1).Factor); // metre, 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
string wkt = @" | |
GEOGCS[""WGS 84"", | |
DATUM[""WGS_1984"", | |
SPHEROID[""WGS 84"",6378137,298.257223563, | |
AUTHORITY[""EPSG"",""7030""]], | |
AUTHORITY[""EPSG"",""6326""]], | |
PRIMEM[""Greenwich"",0, | |
AUTHORITY[""EPSG"",""8901""]], | |
UNIT[""degree"",0.01745329251994328, | |
AUTHORITY[""EPSG"",""9122""]], | |
AUTHORITY[""EPSG"",""4326""]] | |
"; | |
var srs = SpatialReferenceSystem.CreateFromWkt(wkt); | |
Console.WriteLine("SRS Name: {0}", srs.Name); // WGS 84 | |
Console.WriteLine("SRS EPSG code: {0}", srs.EpsgCode); // 4326 | |
Console.WriteLine("Datum name: {0}", srs.GeographicDatum.Name); // WGS_1984 | |
Console.WriteLine("Datum EPSG code: {0}", srs.GeographicDatum.EpsgCode); // 6326 | |
Console.WriteLine("Ellipsoid name: {0}", srs.GeographicDatum.Ellipsoid.Name); // WGS 84 | |
Console.WriteLine("Ellipsoid EPSG code: {0}", srs.GeographicDatum.EpsgCode); // 7030 | |
Console.WriteLine("Type: {0}", srs.Type); // Geographic | |
Console.WriteLine("Dimensions count: {0}", srs.DimensionsCount); // 2 | |
Console.WriteLine("First dimension name: {0}", srs.GetAxis(0).Name); // Longitude | |
Console.WriteLine("First dimension direction: {0}", srs.GetAxis(0).Direction); // EAST | |
Console.WriteLine("Second dimension name: {0}", srs.GetAxis(1).Name); // Latitude | |
Console.WriteLine("Second dimension direction: {0}", srs.GetAxis(1).Direction); // NORTH | |
Console.WriteLine("First dimension unit: {0}, {1}", srs.GetUnit(0).Name, srs.GetUnit(0).Factor); // degree, 0.01745... | |
Console.WriteLine("Second dimension unit: {0}, {1}", srs.GetUnit(1).Name, srs.GetUnit(1).Factor); // degree, 0.01745... | |
var geogSrs = srs.AsGeographic; | |
Console.WriteLine("Angular unit: {0}, {1}", geogSrs.AngularUnit.Name, geogSrs.AngularUnit.Factor); // degree, 0.01745... | |
Console.WriteLine("Prime meridian: {0}, {1}", geogSrs.PrimeMeridian.Name, geogSrs.PrimeMeridian.Longitude); // Greenwich, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var parameters = new ProjectedSpatialReferenceSystemParameters | |
{ | |
Name = "WGS 84 / World Mercator", | |
Base = SpatialReferenceSystem.Wgs84, | |
ProjectionMethodName = "Mercator_1SP", | |
LinearUnit = Unit.Meter, | |
XAxis = new Axis("Easting", AxisDirection.East), | |
YAxis = new Axis("Northing", AxisDirection.North), | |
AxisesOrder = ProjectedAxisesOrder.XY, | |
}; | |
parameters.AddProjectionParameter("central_meridian", 0); | |
parameters.AddProjectionParameter("scale_factor", 1); | |
parameters.AddProjectionParameter("false_easting", 100); | |
parameters.AddProjectionParameter("false_northing", 100); | |
var projectedSrs = SpatialReferenceSystem.CreateProjected(parameters, Identifier.Epsg(3395)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var parameters = new ProjectedSpatialReferenceSystemParameters | |
{ | |
Name = "WGS 84 / World Mercator", | |
Base = SpatialReferenceSystem.Wgs84, | |
ProjectionMethodName = "Mercator_1SP", | |
LinearUnit = Unit.Meter, | |
XAxis = new Axis("Easting", AxisDirection.East), | |
YAxis = new Axis("Northing", AxisDirection.North), | |
AxisesOrder = ProjectedAxisesOrder.XY, | |
}; | |
parameters.AddProjectionParameter("central_meridian", 0); | |
parameters.AddProjectionParameter("scale_factor", 1); | |
parameters.AddProjectionParameter("false_easting", 0); | |
parameters.AddProjectionParameter("false_northing", 0); | |
var projectedSrs = SpatialReferenceSystem.CreateProjected(parameters, Identifier.Epsg(3395)); | |
string wkt = projectedSrs.ExportToWkt(); | |
Console.WriteLine(wkt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
var point = new Point(2, 3); | |
point.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
var srs = point.SpatialReferenceSystem; // WGS 84 | |
var line = new LineString(); | |
srs = line.SpatialReferenceSystem; // null | |
line.AddPoint(point); // line takes SRS from point. | |
srs = line.SpatialReferenceSystem; // WGS 84 | |
line.AddPoint(new Point(3, 4)); // point takes SRS of line. | |
srs = line[1].SpatialReferenceSystem; // WGS84 | |
try | |
{ | |
point = new Point(3, 4); | |
point.SpatialReferenceSystem = SpatialReferenceSystem.Wgs72; | |
line.AddPoint(point); // point has different non null SRS, exception is thrown | |
} | |
catch (ArgumentException e) | |
{ | |
Console.WriteLine(e.Message); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format to CSV. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.csv", Drivers.Csv, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Calculate a position in a Decimal Degrees (DD) format | |
var position = GeoConvert.AsPointText(74.84, 172.13, PointFormats.DecimalDegrees); | |
Console.WriteLine(position); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Calculate a position in a Decimal Degree Minutes (DDM) format | |
var position = GeoConvert.AsPointText(74.84, 172.13, PointFormats.DegreeDecimalMinutes); | |
Console.WriteLine(position); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Calculate a position in a Degree Minute Seconds (DMS) format | |
var position = GeoConvert.AsPointText(74.84, 172.13, PointFormats.DegreeMinutesSeconds); | |
Console.WriteLine(position); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format to GeoJSON. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Calculate a position in a World Geographic Reference System (GeoRef) format | |
var position = GeoConvert.AsPointText(74.84, 172.13, PointFormats.GeoRef); | |
Console.WriteLine(position); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format to GPX. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format to KML. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // Any | |
int epsgTo = 4326; // lat long | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // Any | |
int epsgTo = 3857; // mercator | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Calculate a position in a Military Grid Reference System (MGRS) format | |
var position = GeoConvert.AsPointText(74.84, 172.13, PointFormats.Mgrs); | |
Console.WriteLine(position); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // Any | |
int epsgTo = 4269; // nad83 | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // Any | |
int epsgTo = 4683; // prs92 | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format to Shapefile. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format to SHP. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format to TopoJSON. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.topojson", Drivers.TopoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Calculate a position in a United States National Grid (USNG) format | |
var position = GeoConvert.AsPointText(74.84, 172.13, PointFormats.Usng); | |
Console.WriteLine(position); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // Any | |
int epsgTo = 32631; // utm | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // Any | |
int epsgTo = 4326; // lat long | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from CSV to GDB. | |
VectorLayer.Convert("source.csv", Drivers.Csv, "destination.gdbtable", Drivers.FileGdb, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from CSV to GeoJSON. | |
VectorLayer.Convert("source.csv", Drivers.Csv, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from CSV to GPX. | |
VectorLayer.Convert("source.csv", Drivers.Csv, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from CSV to KML. | |
VectorLayer.Convert("source.csv", Drivers.Csv, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from CSV to SHP. | |
VectorLayer.Convert("source.csv", Drivers.Csv, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.asc", Drivers.EsriAscii), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GDB to CSV. | |
VectorLayer.Convert("source.gdbtable", Drivers.FileGdb, "destination.csv", Drivers.Csv, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GDB to GPX. | |
VectorLayer.Convert("source.gdbtable", Drivers.FileGdb, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GDB to KML. | |
VectorLayer.Convert("source.gdbtable", Drivers.FileGdb, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GDB to SHP. | |
VectorLayer.Convert("source.gdbtable", Drivers.FileGdb, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.gdbtable", Drivers.FileGdb), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GeoJSON to CSV. | |
VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.csv", Drivers.Csv, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GeoJSON to GPX. | |
VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.geojson", Drivers.GeoJson), symbolizer); | |
// Render the map to Jpeg format | |
map.Render("land_out.png", Renderers.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GeoJSON to KML. | |
VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.geojson", Drivers.GeoJson), symbolizer); | |
// Render the map to Png format | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GeoJSON to SHP. | |
VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.geojson", Drivers.GeoJson), symbolizer); | |
// Render the map to Svg format | |
map.Render("land_out.png", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.geojson", Drivers.GeoJson), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.tif", Drivers.GeoTiff), symbolizer); | |
// Render the map to Jpeg format | |
map.Render("land_out.png", Renderers.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.tif", Drivers.GeoTiff), symbolizer); | |
// Render the map to Png format | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.tif", Drivers.GeoTiff), symbolizer); | |
// Render the map to Svg format | |
map.Render("land_out.png", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.tif", Drivers.GeoTiff), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GML to CSV. | |
VectorLayer.Convert("source.gml", Drivers.Gml, "destination.csv", Drivers.Csv, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GML to GeoJSON. | |
VectorLayer.Convert("source.gml", Drivers.Gml, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GML to GPX. | |
VectorLayer.Convert("source.gml", Drivers.Gml, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GML to JSON. | |
VectorLayer.Convert("source.gml", Drivers.Gml, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GML to KML. | |
VectorLayer.Convert("source.gml", Drivers.Gml, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GML to SHP. | |
VectorLayer.Convert("source.gml", Drivers.Gml, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.gml", Drivers.Gml), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GPX to CSV. | |
VectorLayer.Convert("source.gpx", Drivers.Gpx, "destination.csv", Drivers.Csv, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GPX to GeoJSON. | |
VectorLayer.Convert("source.gpx", Drivers.Gpx, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.gpx", Drivers.Gpx), symbolizer); | |
// Render the map to Jpeg format | |
map.Render("land_out.png", Renderers.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GPX to JSON. | |
VectorLayer.Convert("source.gpx", Drivers.Gpx, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GPX to KML. | |
VectorLayer.Convert("source.gpx", Drivers.Gpx, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.gpx", Drivers.Gpx), symbolizer); | |
// Render the map to Png format | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GPX to Shapefile. | |
VectorLayer.Convert("source.gpx", Drivers.Gpx, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GPX to SHP. | |
VectorLayer.Convert("source.gpx", Drivers.Gpx, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.gpx", Drivers.Gpx), symbolizer); | |
// Render the map to Svg format | |
map.Render("land_out.png", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from GPX to TopoJSON. | |
VectorLayer.Convert("source.gpx", Drivers.Gpx, "destination.topojson", Drivers.TopoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.gpx", Drivers.Gpx), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from JSON to GeoJSON. | |
VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from JSON to GPX. | |
VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from JSON to KML. | |
VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from JSON to Shapefile. | |
VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from KML to CSV. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.csv", Drivers.Csv, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from KML to GeoJSON. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from KML to GPX. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.kml", Drivers.Kml), symbolizer); | |
// Render the map to Jpeg format | |
map.Render("land_out.png", Renderers.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from KML to GeoJSON. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.kml", Drivers.Kml), symbolizer); | |
// Render the map to Png format | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from KML to Shapefile. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from KML to SHP. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.kml", Drivers.Kml), symbolizer); | |
// Render the map to Svg format | |
map.Render("land_out.png", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from KML to TopoJSON. | |
VectorLayer.Convert("source.kml", Drivers.Kml, "destination.topojson", Drivers.TopoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.kml", Drivers.Kml), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // LAT LONG | |
int epsgTo = 3857; // MERCATOR | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // LAT LONG | |
int epsgTo = 32631; // UTM | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.mid", Drivers.MapInfoInterchange), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from MapInfo-TAB to GPX. | |
VectorLayer.Convert("source.tab", Drivers.MapInfoTab, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.tab", Drivers.MapInfoTab), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 3857; // MERCATOR | |
int epsgTo = 32631; // UTM | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 3857; // MERCATOR | |
int epsgTo = 4326; // WGS84 | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4269; // NAD83 | |
int epsgTo = 4326; // WGS84 | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from OSM to CSV. | |
VectorLayer.Convert("source.osm", Drivers.OsmXml, "destination.csv", Drivers.Csv, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from OSM to GPX. | |
VectorLayer.Convert("source.osm", Drivers.OsmXml, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.osm", Drivers.OsmXml), symbolizer); | |
// Render the map to Jpeg format | |
map.Render("land_out.png", Renderers.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from OSM to KML. | |
VectorLayer.Convert("source.osm", Drivers.OsmXml, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.osm", Drivers.OsmXml), symbolizer); | |
// Render the map to Png format | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from OSM to SHP. | |
VectorLayer.Convert("source.osm", Drivers.OsmXml, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.osm", Drivers.OsmXml), symbolizer); | |
// Render the map to Svg format | |
map.Render("land_out.png", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.osm", Drivers.OsmXml), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from Shapefile to GeoJSON. | |
VectorLayer.Convert("source.shp", Drivers.Shapefile, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.shp", Drivers.Shapefile), symbolizer); | |
// Render the map to Jpeg format | |
map.Render("land_out.png", Renderers.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from Shapefile to JSON. | |
VectorLayer.Convert("source.shp", Drivers.Shapefile, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from Shapefile to KML. | |
VectorLayer.Convert("source.shp", Drivers.Shapefile, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.shp", Drivers.Shapefile), symbolizer); | |
// Render the map to Png format | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.shp", Drivers.Shapefile), symbolizer); | |
// Render the map to Svg format | |
map.Render("land_out.png", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from Shapefile to TopoJSON. | |
VectorLayer.Convert("source.shp", Drivers.Shapefile, "destination.topojson", Drivers.TopoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from SHP to CSV. | |
VectorLayer.Convert("source.shp", Drivers.Shapefile, "destination.csv", Drivers.Csv, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from SHP to GPX. | |
VectorLayer.Convert("source.shp", Drivers.Shapefile, "destination.gpx", Drivers.Gpx, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.shp", Drivers.Shapefile), symbolizer); | |
// Render the map to Jpeg format | |
map.Render("land_out.png", Renderers.Jpeg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from SHP to KML. | |
VectorLayer.Convert("source.shp", Drivers.Shapefile, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.shp", Drivers.Shapefile), symbolizer); | |
// Render the map to Png format | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.shp", Drivers.Shapefile), symbolizer); | |
// Render the map to Svg format | |
map.Render("land_out.png", Renderers.Svg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.shp", Drivers.Shapefile), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from TopoJSON to GeoJSON. | |
VectorLayer.Convert("source.topojson", Drivers.TopoJson, "destination.geojson", Drivers.GeoJson, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from TopoJSON to KML. | |
VectorLayer.Convert("source.topojson", Drivers.TopoJson, "destination.kml", Drivers.Kml, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Specify conversion settings if necessary. It is optional. | |
ConversionOptions options = null; | |
// This options assigns Wgs84 to the destination layer. | |
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check. | |
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)) | |
{ | |
options = new ConversionOptions() | |
{ | |
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84, | |
}; | |
} | |
// Convert file format from TopoJSON to Shapefile. | |
VectorLayer.Convert("source.topojson", Drivers.TopoJson, "destination.shp", Drivers.Shapefile, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Create a map | |
using (var map = new Map(800, 400)) | |
{ | |
// Use the specified SRS | |
map.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84; | |
// Use the specified style to draw lines | |
// We also have styles for points, lines, and surfaces. | |
var symbolizer = new SimpleLine() {Width = Measurement.Pixels(2)}; | |
// Open a layer and add to the map | |
map.Add(VectorLayer.Open("land.topojson", Drivers.TopoJson), symbolizer); | |
// Render the map | |
map.Render("land_out.png", Renderers.Png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 32631; // UTM | |
int epsgTo = 4326; // LAT LONG | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 32631; // UTM | |
int epsgTo = 4269; // NAD83 | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // WGS84 | |
int epsgTo = 4269; // NAD83 | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // WGS84 | |
int epsgTo = 4683; // PRS92 | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// create transformation | |
int epsgFrom = 4326; // WGS84 | |
int epsgTo = 32631; // UTM | |
var fromSrs = SpatialReferenceSystem.CreateFromEpsg(epsgFrom); | |
var toSrs = SpatialReferenceSystem.CreateFromEpsg(epsgTo); | |
var transformation = fromSrs.CreateTransformationTo(toSrs); | |
// transform geometry such as a point | |
var fromGeometry = new Point(0, 0); | |
var toGeometry = transformation.Transform(fromGeometry); | |
Console.WriteLine(toGeometry.GetCentroid().AsText()); | |
Console.WriteLine(toGeometry.AsText()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment