JGiscoTools

Maven Central

JGiscoTools is a Java library for the manipulation of geospatial and statistical data, with a focus on European data produced by Eurostat and Eurostat-GISCO. The main functionalities are listed here

JGiscoTools is mainly based on GeoTools, JTS Topology Suite and java4eurostat libraries.

Quick start

Load

To load geographical features from a GeoPackage, a Shapefile or a GeoJSON file, use:

Collection<Feature> featuresGPKG = GeoData.getFeatures("C:/myFile.gpkg");
Collection<Feature> featuresSHP = GeoData.getFeatures("C:/myFile.shp");
Collection<Feature> featuresGEOJSON = GeoData.getFeatures("C:/myFile.geojson");

Read

A Feature object has an identifier, a geometry and some attributes. This information can be accessed with:

//load features
Collection<Feature> features = ...;

//print number of features
System.out.println(features.size());

//go through features 
for(Feature f : features) {
	//print the feature identifier
	System.out.println(f.getID());
	//print the feature geometry
	System.out.println(f.getGeometry());
	//print the feature geometry area
	System.out.println(f.getGeometry().getArea());
	//print the feature geometry length
	System.out.println(f.getGeometry().getLength());
	//print the attribute names
	System.out.println(f.getAttributes().keySet());
	//print the attribute "myAttribute1"
	f.getAttribute("myAttribute1");
	//print the attribute "myAttribute2"
	f.getAttribute("myAttribute2");
	...
}

Modify

A Feature object can be modified directly. See for example how to change an attribute value and change the geometry with a buffer of 10m distance:

Feature f = ...
f.setAttribute("myAttribute1", "new value");
f.setGeometry( f.getGeometry().buffer(10) );

Save

To save data as a GeoPackage, a Shapefile or a GeoJSON file, use:

GeoData.save(features, "C:/myFile.gpkg", crs);
GeoData.save(features, "C:/myFile.shp", crs);
GeoData.save(features, "C:/myFile.geojson", crs);

The CRS (Coordinate Reference System) has to be specified, either from an input dataset, or from its EPSG code:

CoordinateReferenceSystem crs = GeoData.getCRS("C:/myFile.gpkg");
CoordinateReferenceSystem crsEPSG = CRS.decode("EPSG:3035")

More information

Setup

JGiscoTools uses Apache Maven. To use JGiscoTools, add it as a dependency to the pom.xml file:

<dependency>
	<groupId>eu.europa.ec.eurostat</groupId>
	<artifactId>jgiscotools</artifactId>
	<version>X.Y.Z</version>
</dependency>

Where X.Y.Z is the current version number, as available Maven central repository.

For more information on how to setup a coding environment based on Eclipse, see this page.

Documentation

See the Javadoc API.

Components

JGiscoTools allows:

Support and contribution

Feel free to ask support, fork the project or simply star it (it’s always a pleasure).