POST
|
Thank you Joshua, I can get wkt strings for shape geometries, but I need wkt for the coordinate system used. Otherwise I can not transform the x/y to lat/long coodinates. Preferrably a function from a C# class library.
... View more
12-09-2020
11:45 PM
|
0
|
1
|
128
|
POST
|
I am trying to read coordinates from a shapefile. But I get wrong coordinates. I am not sure if I use the correct wkt strings. Is there any function i can use to get the wkt string for a given shapefile? I use these librarys: using NetTopologySuite.IO; using ProjNet.CoordinateSystems; using ProjNet.CoordinateSystems.Transformations; And this is my code: CoordinateSystemFactory coordinateSystemFactory = new CoordinateSystemFactory(); string UTMWGS84_WKT2 = "PROJCS[\"WGS 84 / UTM zone 32N\", 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\"]], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], PROJECTION[\"Transverse_Mercator\"], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", 9], PARAMETER[\"scale_factor\", 0.9996], PARAMETER[\"false_easting\", 500000], PARAMETER[\"false_northing\", 0], AUTHORITY[\"EPSG\", \"32632\"], AXIS[\"Easting\", EAST], AXIS[\"Northing\", NORTH]]"; CoordinateSystem source = coordinateSystemFactory.CreateFromWkt(@UTMWGS84_WKT2); string UTMWGS84_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\"]]," + "PROJECTION[\"Transverse_Mercator\"]," + "PARAMETER[\"latitude_of_origin\",0]," + "PARAMETER[\"central_meridian\",9]," + "PARAMETER[\"scale_factor\",0.9996]," + "PARAMETER[\"false_easting\",500000]," + "PARAMETER[\"false_northing\",0]," + "UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]]"; CoordinateSystem target = coordinateSystemFactory.CreateFromWkt(UTMWGS84_WKT); CoordinateSystem target2 = coordinateSystemFactory.CreateFromWkt(UTMWGS84_WKT); CoordinateTransformationFactory trf = new CoordinateTransformationFactory(); CoordinateTransformation tr = (CoordinateTransformation)trf.CreateFromCoordinateSystems(source, target); var filename = @"C:\\myshapefile.shp"; using (var reader = new ShapefileDataReader(filename, NetTopologySuite.Geometries.GeometryFactory.Default)) { for (var i = 0; i < dbaseHeader.NumRecords; i++) { reader.Read(); string id = reader.GetString(1); NetTopologySuite.Geometries.Geometry geometry = reader.Geometry; NetTopologySuite.Geometries.Coordinate coordinate = new NetTopologySuite.Geometries.Coordinate(); NetTopologySuite.IO.WKTWriter wktWrirer = new NetTopologySuite.IO.WKTWriter(); coordinate = geometry.Coordinate; Console.WriteLine("Id " + i + ": " + id); Console.WriteLine("X Mercator " + i + ": " + coordinate.X); Console.WriteLine("Y Mercator " + i + ": " + coordinate.Y); double[] coordinateMercator = new double[] { coordinate.X, coordinate.Y }; double[] coordinateWGS84 = tr.MathTransform.Transform(coordinateMercator); Console.WriteLine("X WGS84 " + i + ": " + coordinateWGS84[0]); Console.WriteLine("Y WGS84 " + i + ": " + coordinateWGS84[1]); } }
... View more
12-09-2020
08:13 AM
|
0
|
4
|
146
|
POST
|
I would like to create routes along walk or drive paths. Can you please advise how to create the variable 'credential' that is sent as a parameter below: var routeTask = await RouteTask.CreateAsync(routeSourceUri, credential); For routes in an example in San Diego I used the URL below. But I assume other URLs are needed to draw routes in other areas (e.g. in Europe) - how do I get such URL? var routeSourceUri = newUri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/Route"); Can you please advise about example code showing how to use the 'credential' variable?
... View more
11-30-2020
10:17 AM
|
0
|
0
|
60
|
POST
|
How to connect Events in C# to graphical objects e.g. Simple Marker Symbol or Poly Line? The main purpose is to move such objects I made myself. The following code I found does not work, please see error message in las 5 rows: Esri.ArcGISRuntime.UI.Graphic aGraphic = new Esri.ArcGISRuntime.UI.Graphic(); aGraphic.MouseRightButtonDown += Graphic_MouseRightButtonDown; void Graphic_MouseRightButtonDown( object sender, System.Windows.Input.MouseButtonEventArgs e) { // Do something } Severity Code Description Project File Line Suppression State Error CS1061 'Graphic' does not contain a definition for 'MouseRightButtonDown' and no accessible extension method 'MouseRightButtonDown' accepting a first argument of type 'Graphic' could be found(are you missing a using directive or an assembly reference ?) AccessOptimizer C:\Users\matti\Desktop\ArcGISApp\ArcGISApp\MapWindow.xaml.cs 219 Active
... View more
09-04-2020
02:32 AM
|
0
|
0
|
37
|
POST
|
How do I create an event for graphical objects, e.g. Simple Marker Symbols or Poly Lines? The purpose is to mark them and move them. This method does not work for me, please see error message in the last 5 rows: Esri.ArcGISRuntime.UI.Graphic aGraphic = new Esri.ArcGISRuntime.UI.Graphic(); aGraphic.MouseRightButtonDown += Graphic_MouseRightButtonDown; void Graphic_MouseRightButtonDown( object sender, System.Windows.Input.MouseButtonEventArgs e) { // Do something } Severity Code Description Project File Line Suppression State Error CS1061 'Graphic' does not contain a definition for 'MouseRightButtonDown' and no accessible extension method 'MouseRightButtonDown' accepting a first argument of type 'Graphic' could be found(are you missing a using directive or an assembly reference ?) AccessOptimizer C:\Users\matti\Desktop\ArcGISApp\ArcGISApp\MapWindow.xaml.cs 219 Active
... View more
09-04-2020
02:24 AM
|
0
|
1
|
84
|
Online Status |
Offline
|
Date Last Visited |
3 weeks ago
|