14
votes
converting/parsing geojson into com.vividsolutions.jts geometry
For a much more lightweight alternative to GeoTools, check out jts2geojson:
GeoJSONReader reader = new GeoJSONReader();
Geometry geometry = reader.read(json);
7
votes
Accepted
Geotools: unexpected difference between CRS.decode("EPSG:4326") and DefaultGeographicCRS.WGS84
I stumbled over a common pitfall.
for EPSG:4326 the coordinate order should be latitude, longitude
the javdoc for DefaultGeographicCRS.WGS84 state that the coordinate order should be longitude ...
7
votes
Accepted
Closing shapefile using org.geotools.data.shapefile.ShapefileFeatureReader gives warning?
You must close the iterators sfi and sfi2 after their respective loops.
SimpleFeatureIterator sfi = fs.getFeatures().features();
double sum = 0;
while (sfi.hasNext()) {
SimpleFeature sf = sfi....
7
votes
Accepted
Unable to build a custom GeoServer WPS
The repository moved, and we were unable to get maven to handle a redirect.
See the GeoTools Blog for more details.
So now you need this in your pom.xml files:
<repositories>
<repository&...
6
votes
Why are date vaules displaying a trailing 'Z' when layers are published with Geoserver and a PostGIS data store?
It appears you were/are on the right track as the 'Z' is used for a timezone indicator, here is the source I found that best answers your question
"Z" is kind of a unique case for DateTimes. The ...
6
votes
Accepted
Exporting WFS to shapefile?
The most likely reason to not see a geometry column in a Shapefile is that your column name is not the_geom. This is required by the ShapeFile standard - in an ideal world GeoTools would be smart ...
6
votes
Accepted
Using Math in SLD file - wkt
You can do math in SLD in most places, but a WellKnownMark element is not one of them.
This is what the standard says, GeoServer has a custom extension allowing to stick a CQL expression in the ...
6
votes
Accepted
Understanding gdalwarp reprojection
Just display your raster in a GIS software in UTM 32N:
You see that the raster is rotated in the new CRS, and the former Lower Left point is not the most southward point anymore.
Since gdalwarp ...
6
votes
Geometry from wkt/polygon using geotools
From the documentation use a WKTReader:
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
WKTReader reader = new WKTReader(geometryFactory);
Point point = (Point) ...
6
votes
Accepted
Which algorithm (Vincenty or Haversine) is used to calculate distance in GeoTools?
GeoTools uses Karney's GeographicLib, if you check the code you'll see it uses the Geodesic.Direct method.
6
votes
How to create shapefile size greater than 2GB using GeoTools
As everyone said in the comments - you can't. Shapefiles use a 32bit pointer internally and it breaks if you go over 2Gb. Switch to a GeoPackage, fortunately as Datastores are interchangeable all you ...
5
votes
Accepted
Create shapefile based on geojson data with geotools (Java)
Short answer: Your feature type doesn't match the Shapefile standard so the illegal bits get dropped by GeoTools. I have a utility class to fix this -
try {
String url = "geojson.json";
...
5
votes
Difference between Envelope and BoundingBox
The main difference is that a bounding box is 2 dimensional while an envelope has 2 or more dimensions. A dimension is a "direction" so for a bounding box there are 2 (North and East or X and Y) while ...
5
votes
Java library to break up a big polygon into many parts
JTS saved the day! I wrote my own subroutine to do this by recursively subdividing a big geometry into pieces until each piece is less than a user-specified size. It goes like this:
public static ...
5
votes
Accepted
How to combine LineStrings using JTS
I think your problem is that none of your strings overlap so there is nothing for the union to do.
I've tried the following code:
SimpleFeatureIterator itr = features.features();
ArrayList<...
5
votes
Accepted
Renaming column (attribute) name using GeoTools and shapefile:
You need to create a new FeatureType (schema) for your output DataStore with the new column names and then copy the features to the new type and write them out.
Something like this will do it:
...
5
votes
Looking for the simplest way to get elevation for a give wgs84 coordinate
You can download elevation data in raster format from this url
Load each tif into postgres with:-
raster2pgsql -d -s 4326 -t 50x50 <TIFF>.tif <YOUR TABLE> | psql -n <YOUR DATABASE>...
5
votes
Accepted
Reproject features with geotools
This code works for me:
public static void main(String[] args) throws IOException, NoSuchAuthorityCodeException, FactoryException {
if(args.length==0) {
System.err.println("usage: ...
5
votes
SLD - break in hatch
The solution is to use something similar to something you already used in the past (for reference Using Math in SLD file - wkt),
<PolygonSymbolizer>
<Fill>
<GraphicFill>...
5
votes
GeoJSON to KML conversion
GeoTools will read GeoJSON and write KML quite easily:
URL url = URLs.fileToUrl(new File("/home/ian/Data/states/states.geojson"));
HashMap<String, Object> params = new HashMap<>();
params....
5
votes
Specifying EPSG transformation method in GeoTools?
First you need to download the NTv2 file you need (e.g. from your national mapping agency), you then need to save the .gsb file in src/main/resources/org/geotools/referencing/factory/gridshift and ...
5
votes
Accepted
Convert shapefile to PNG using GeoTools
To export any type of GeoTools feature type to an image the process is the same - you read in the features (or coverage) using a DataStore, you then render these features using a Style (often read ...
5
votes
Accepted
How can I determine point coordinate sysystem?
On the IPUMS NHGIS website they say:
"We project the data into Esri's USA Contiguous Albers Equal Area Conic Projected Coordinate System"
So that would be ESRI:102003 NAD 1983 Albers ...
4
votes
Unit of Geotools' getArea function
As all of the questions you have linked to say JTS does not care about the units of your data and treats them all alike - so the answer to your question is square degrees. Now that is rarely (if ever) ...
4
votes
converting/parsing geojson into com.vividsolutions.jts geometry
There seems to be nowadays also native GeoJSON reader/writer code in JTS trunk:
https://sourceforge.net/p/jts-topo-suite/code/HEAD/tree/trunk/jtsio/src/main/java/com/vividsolutions/jts/io/geojson/
...
4
votes
Accepted
Exporting Shapefile to SVG using Java & GeoTools?
Have a look at the code referenced in my blog post which shows how to do exactly this, including styling the layer.
Here is the actual code:
private void exportSVG(File file) {
Dimension ...
4
votes
Getting started with Geotools?
You can start with GeoTools tutorials, which is helpful for beginners. It provides an introduction to GIS workshop making use of examples from GeoTools and other Java libraries.
4
votes
Accepted
geotools cql full syntax and examples
The CQL is defined by the OGC as part of the catalogue service (i.e. CSW) model specification. See http://docs.opengeospatial.org/is/12-168r6/12-168r6.html for the current (as of July 2016) version. ...
4
votes
Exporting WFS to shapefile?
You can request a Shapefile via the WFS request to GeoServer.
http://docs.geoserver.org/latest/en/user/services/wfs/outputformats.html
States, WFS returns features and feature information in a ...
4
votes
Accepted
Modifying feature attributes of a shapefile in geotools
The only way to make these changes persistent is to write them out to disk (in any format you like). There is nothing to stop you using the same filename as you read in (if you feel brave) but making ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
geotools × 748java × 271
shapefile × 93
coordinate-system × 81
geoserver × 71
geotiff-tiff × 57
jts-topology-suite × 43
postgis × 39
geojson × 26
wfs × 24
gml × 24
raster × 23
gdal × 19
geometry × 17
kml × 17
epsg × 16
sld × 15
polygon × 13
features × 13
postgresql × 12
convert × 11
rendering × 11
openlayers-2 × 9
wms × 9
style × 9