Sunday, February 22, 2015

Open Shape File Esri ArcObjects Snippets - Series

Esri ArcObjects Snippets - Series

Open Shape File




 //Open Shape file  
      public void openShapefile(String workspacePath, String shapefileName) {  
           /*  
            * In this code, the file extension, .shp is not used when specifying  
            * the name of the shapefile to be opened.  
            */  
           try {  
                ShapefileWorkspaceFactory wsf = new ShapefileWorkspaceFactory();  
                Workspace work = new Workspace(wsf.openFromFile(workspacePath, 0));  
                IFeatureClass featureClass = work.openFeatureClass(shapefileName);  
                FeatureLayer layer = new FeatureLayer();  
                layer.setFeatureClassByRef(featureClass);  
                layer.setName(featureClass.getAliasName());  
                mxDoc.getFocusMap().addLayer(layer);  
           } catch (Exception e) {  
                e.printStackTrace();  
           }  
      }  


This code has been made using ESRI Resources and other Help Content and is provided here just for educational purpose.

No comments:

Post a Comment