Select to view content in your preferred language

ShapeFiles And Text files

1040
3
10-26-2010 06:02 AM
jonataspovoas
Regular Contributor
Hi,

in my application, i need to load points and polygons through text files on runtime, like these
11,12;MyPointNamed
-35,51;-36,80;-100,42;-40,18;-35,51
-127,51;-84,2;0,0;-2,-40
11,16
11,20
11,24
11,28
11,32
21,32
31,32
41,32
51,32
61,42
71,52
81,62


I also need to load shapefiles on runtime. How do i do it?
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
You need to parse the text file, create a PointCollection of MapPoints based on the (lat, lon) values. This PointCollection will be added to the ring(s) of your Polygon, which will become the Graphic's Geometry.

 PointCollection pts = new PointCollection();
 
 // replace these points with the proper values
 pts.Add(new MapPoint(-35,51));  
 pts.Add(new MapPoint(-36,80));
 
 Polygon p = new Polygon();
 p.Rings.Add(pts);
 Graphic g = new Graphic() { Geometry = p };
0 Kudos
jonataspovoas
Regular Contributor
You need to parse the text file, create a PointCollection of MapPoints based on the (lat, lon) values. This PointCollection will be added to the ring(s) of your Polygon, which will become the Graphic's Geometry.

 PointCollection pts = new PointCollection();
 
 // replace these points with the proper values
 pts.Add(new MapPoint(-35,51));  
 pts.Add(new MapPoint(-36,80));
 
 Polygon p = new Polygon();
 p.Rings.Add(pts);
 Graphic g = new Graphic() { Geometry = p };


That should work for the Text Files, But how do I load A shapeFile into the application?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
There is a sample of a shapefile reader here : http://esrislcontrib.codeplex.com/
0 Kudos