wpf - Reading shapefile coordinates in c# -
i want draw polyline on "xaml map control" latitude/longitude, using content of shapefile.
i have 2 types of shapefile:
one .dbf, .prj, qpj, .shx , .shp file. one .shp filereading both type of files various libraries (net topology suite, , dotspatial) obtain list of coordinates (dotspatial.topology.coordinate) like:
x 456874.625438354 y 5145767.7929015327 how can convert latitude/longitude format? what current format? are files accompany .shp file useful?
you can utilize dotspatial reproject lat long. if reading in shapefile, , .prj file there projection known, need is:
shapefile sf = shapefile.openfile("c:\myshapefile.shp"); sf.reproject(dotspatial.projections.knowncoordinatesystems.geographic.world.wgs1984); if, .prj file missing, need first define projection like:
shapefile sf = shapefile.openfile("c:\myshapefile.shp"); sf.projection = dotspatial.projections.knowncoordinatesystems.projected.utmwgs1984.wgs1984utmzone32n; sf.reproject(dotspatial.projections.knowncoordinatesystems.geographic.world.wgs1984); but if, instance don't have shapefile , want reproject set of coordinates 1 projection another, can utilize reproject utility directly:
// interleaved x , y values, x1, y1, x2, y2 etc. double[] xy = new double[]{456874.625438354,5145767.7929015327}; // z values if any. typically 0. double[] z = new double[]{0}; // source projection information. projectioninfo source = dotspatial.projections.knowncoordinatesystems.projected.utmwgs1984.wgs1984utmzone32n; // destination projection information. projectioninfo dest = dotspatial.projections.knowncoordinatesystems.geographic.world.wgs1984; // phone call projection utility. dotspatial.projections.reproject.reprojectpoints(xy, z, source, dest, 0, 1); this lastly method uses array projection module can work without having direct reference info module.
c# wpf shapefile topography dotspatial
No comments:
Post a Comment