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);
12
votes
Accepted
GeoJSON java library
Geotools as a support for geojson. See here.
Otherwise, you could simply use a typical JSON parser (such as json-simple) together with the geoJSON spec, which is really easy to use.
The best ...
8
votes
Looking for an open-source Java based GeoTIFF library
Install OpenJUMP and study what all has been gathered into it
I have never really understood what all the alternatives are. ImageIO-ext is probably utilising native GDAL binaries if such are ...
8
votes
Accepted
Calculate distance with JTS
The short answer is you can't do that unless your points are very close together and you want the answer in degrees. JTS knows nothing about units or the curvature of the earth. So you need to pull in ...
7
votes
Reading each pixel of each band of multiband GeoTiff with GeoTools Java?
Mark's answer is great! It really helped me out.
Here's a slightly modified version of Mark's code. The major difference is that this code does not rely on the java.awt.image package to compute the ...
7
votes
Accepted
Looking for an open-source Java based GeoTIFF library
I believe that I have found an adequate solution that meets all of my requirements. Thanks to user30184's answer, which pointed me in the direction of ImageIO, I was able to find an alternative Java ...
7
votes
GeoJSON java library
To parse or deserialize geojson in Java REST webservice, i prefere to use geojson-jackson , which integrate itself very nicely with jackson.
7
votes
GeoJSON java library
Another alternative is GeoGson, which is built on top of Google's Gson:
Geometry geometry = new GsonBuilder()
.registerTypeAdapterFactory(new GeometryAdapterFactory())
.create()
...
7
votes
Accepted
How do I produce a GeoJSON with 1 point at a certain lon/lat?
You need to import the GeoJSON plugn
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<version>${geotools.version}</...
6
votes
Avoiding GeoServer/Java out of heap space error?
I've had the same error message on a Windows Server with GeoServer using Jetty. After some research I found the file C:\Program Files (x86)\GeoServer 2.10.1\wrapper\wrapper.conf where I edited these ...
6
votes
How can I find closest point on a polygon from a point
You can get it with JSTS.
Check DistanceOp.js.
6
votes
Accepted
Reading each pixel of each band of multiband GeoTiff with GeoTools Java?
I finally figured it out... this code assumes that the geotif is in wgs84 (4326) proj, but it works well for getting the lat long for each pixel, and the band values for each pixel (formatted as a csv ...
6
votes
Converting shapefile to CSV file using GeoTools in Java?
I had same problem.
I solved the problem.
My solution:
StringBuffer tmpStr = new StringBuffer();
tmpStr.append("ID,date,tstamp,X_prj,Y_prj,NEAR_FID,NEAR_DIST\n");
SimpleFeature f = null;
int index ...
6
votes
Accepted
Given a GeoJSON file how do I calculate the area of the embedded features?
GeoTools is a Java library which can read and write GeoJSON and provides access to features like area via the JTS library. It will also help you to reproject the geometries from the lat/lon of GeoJSON ...
6
votes
Remove/Fill holes in Polygons from a MultiPolygon using JTS Topology Suite programmatically
OpenJUMP has a "remove holes" tool (and an advanced "remove small holes" tool as well). OpenJUMP often uses JTS rather directly but I am not sure about this case. The source code of the function is at ...
5
votes
How can I find closest point on a polygon from a point
A very simple solution: solve an equasion for each pair of poly vertices.
An algorithm for one segment of the polygon (gray in the picture) with points a and b:
vector A is just point a coordinates
...
5
votes
How to Read&Write .tiff images in java using GDAL library
I guess you have gdal and the bindings installed, and some coding ability, so I'll just provide an outline:
import org.gdal.gdal.gdal;
import org.gdal.gdal.Band;
import org.gdal.gdal.Dataset;
...
...
5
votes
How to calculate the distance between a line and a point (using lat/lon coordinates)
you can't really convert convert distances in degrees into meters as the size of a degree varies as you approach the poles. convert your locations into a projected coordinate system, then calculate ...
5
votes
Testing if Geometry is convex using JTS?
OK, my original answer was wrong (see user30184's comment). Here's another:
The polygon is convex if each interior angle is 180 degrees or less. You can check this in O(n) time, iterating over the ...
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
Given a GeoJSON file how do I calculate the area of the embedded features?
You can do this several ways,
I think that the easiest (if you only have a few GIS things to do) is to use Turf
see here
There are also a couple of GIS library whom are a bit
heavier (size wise)
...
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
Convert geojson to png
If you chose GeoTools it is a fairly simple process, fetch your geojson from somewhere:
URL states = new URL("http://geojson.xyz/naturalearth-3.3.0/ne_110m_admin_1_states_provinces.geojson");
...
5
votes
Accepted
SQL injection with ST_geomFromGeoJson
It depends on what your library is actually doing with that query. If it's taking your GeoJSON input and slamming it all into a SQL string, then yes, it's an injection vector, but then so would any ...
5
votes
Accepted
Remove/Fill holes in Polygons from a MultiPolygon using JTS Topology Suite programmatically
Basically, you need to create a new Polygon from the ExteriorRing of the input Polygon.
gf.createPolygon(p.getExteriorRing().getCoordinateSequence());
There is a little more work with MultiPolygons ...
5
votes
Accepted
How to convert GeoJSON to GeoTIFF
With the command line, https://gdal.org/programs/gdal_rasterize.html
With Python, you can use gdal.RasterizeLayer like in the tests from GDAL e.g https://github.com/OSGeo/gdal/blob/master/autotest/alg/...
5
votes
Accepted
PSQLException: ERROR: operator does not exist: public.geometry && public.geometry
Thanks @CL for Hint, search_path in java solved the problem, you can add comma separated multiple schema in currentSchema connection string parameter
old connection url
url: jdbc:postgresql://...
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
Point to Line Calculations
I would recommend to rely on GeographicLib implemented by Charles Karney which uses Gnomonic projection for point to line projections in WGS-84 (http://geographiclib.sourceforge.net/). This solution ...
4
votes
Accepted
Difference between ArcObjects SDK for Java and ArcGIS Runtime for Java?
With ArcGIS Runtime SDK for Java, you can write standalone applications, viewing / editing mostly ArcGIS Online data
With the ArcObjects java SDK, you can do almost everything ArcMap can do. In fact, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
java × 832geotools × 259
geoserver × 64
postgis × 62
arcobjects × 58
shapefile × 55
gdal × 54
openstreetmap × 42
coordinate-system × 40
jts-topology-suite × 39
geojson × 36
geotiff-tiff × 36
raster × 29
postgresql × 28
openlayers-2 × 23
javascript × 21
android × 21
geometry × 20
software-recommendations × 20
wfs × 18
python × 17
tomcat × 17
arcgis-desktop × 16
arcgis-server × 15
wms × 15