How to load data from a Shape File directly
Jump to navigation
Jump to search
An example that allows to load data stored in a Shapefile directly, without any GUI interactions:
String filename= "data/tigerline/2009_us_state/tl_2009_us_state.shp"; ShapefileReader reader = new ShapefileReader(); FeatureCollection fc = reader.read(new DriverProperties(filename)); List<Feature> features = fc.getFeatures();
The list of features can then be parsed and modified. You can also add the FeatureCollection as layer in OpenJUMP using:
context.addLayer(StandardCategoryNames.RESULT, "myLayerName" , fc );
Note, the context is a PlugInContext available in a PlugIn class.