Skip to main content
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 ...
evod's user avatar
  • 323
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....
JGH's user avatar
  • 42.3k
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&...
Ian Turton's user avatar
  • 82.2k
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 ...
Ian Turton's user avatar
  • 82.2k
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 ...
Andrea Aime's user avatar
  • 17.5k
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 ...
AndreJ's user avatar
  • 76.8k
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) ...
Ian Turton's user avatar
  • 82.2k
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.
Ian Turton's user avatar
  • 82.2k
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 ...
Ian Turton's user avatar
  • 82.2k
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<...
Ian Turton's user avatar
  • 82.2k
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: ...
Ian Turton's user avatar
  • 82.2k
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>...
CitizenFish's user avatar
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: ...
Ian Turton's user avatar
  • 82.2k
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>...
Miroslav Vujasinovic's user avatar
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....
Ian Turton's user avatar
  • 82.2k
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 ...
Ian Turton's user avatar
  • 82.2k
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 ...
Ian Turton's user avatar
  • 82.2k
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 ...
Pointdump's user avatar
  • 1,055
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) ...
Ian Turton's user avatar
  • 82.2k
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. ...
BradHards's user avatar
  • 12.9k
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 ...
maw269's user avatar
  • 500
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 ...
Ian Turton's user avatar
  • 82.2k
4 votes
Accepted

SLD polygon graphic fill - hatch

So the option you do not like would be to add this: <LineSymbolizer> <Stroke> <CssParameter name="stroke">#FFFFFF</CssParameter> <CssParameter name="...
JimT's user avatar
  • 2,383
4 votes

GeoTools compilation error

If you just want to build geotools jars you can do so by skipping tests: mvn clean install -Dall -DskipTests About doing a full build with tests, it has not worked for a long time. Patches to fix ...
Andrea Aime's user avatar
  • 17.5k
4 votes
Accepted

Latitude is too close to a pole while converting from EPSG:3857 to EPSG:4326

The reason your coordinates are giving you problems is you are putting your source coordinates in as degrees. It has nothing to do with proximity to the poles (the first problem point is in China and ...
MappaGnosis's user avatar
  • 33.9k
4 votes
Accepted

Java GeoTools: Creating Shapefile - FeatureCollections deprecated

The prefered solution is to use the gt-csv datastore to read in the features which will return you a feature collection directly, that you can then write out to a shapefile. If you really need to do ...
Ian Turton's user avatar
  • 82.2k
4 votes
Accepted

Why is the use of memory mapped buffers in shapefile data stores not recommended on Windows?

I believe it still applies, also, as far as I know, on Windows memory mapping actually reserves memory, while on Linux is just a direct conduit to the kernel without the OS actually loading the full ...
Andrea Aime's user avatar
  • 17.5k
4 votes
Accepted

WFS geotools Hashmap can not be parsed to SimpleFeature

At present, you are reliant on the version negotiation and are accepting the default output format. It may be better to force those to say 1.1.0 and "text/xml; subtype=gml/2.1.2" to limit the ...
Ian Turton's user avatar
  • 82.2k
4 votes
Accepted

Why does geotools DataStoreFinder return null jdbc dataStore

It correctly returns null because you have not made a DataStore available that can handle the parameters you have passed in. As you can see from the list of available datastores you can only create ...
Ian Turton's user avatar
  • 82.2k
4 votes
Accepted

Remove intersect/touch from polygons, to making one with JTS/GeoTools

You need to create a GeometryCollection of the polygons that you wish to join and then call .union() on it. So you'll need some code like: String lines = "/tmp/ian.shp"; GeometryFactory factory = ...
Ian Turton's user avatar
  • 82.2k

Only top scored, non community-wiki answers of a minimum length are eligible