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
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");
...
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
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
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
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://...
5
votes
Accepted
Cannot compile code against latest stable GeoTools/GeoServer version
The org.opengis packages are gone in GeoTools 30.x, see the upgrade guide for that series: https://docs.geotools.org/stable/userguide/welcome/upgrade.html
Along with the GeoTools 30.0 release ...
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
Error in using GDAL Java binding
To overcome unsatisfiedlinkerror in gdal you need to check that your program is able to read the correct gdal environment variables and .dll files. Here is a brief procedure.
Now Follow the below ...
4
votes
Accepted
How to calculate cell tower polygon and get the coordinates in wkt format
This is a fairly simple operation in Java using GeoTools. All you need to do is start at the tower and travel out a distance (radius) in the direction (azimuth) - probably minus some width parameter, ...
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 ...
4
votes
GeoServer WPS source code
GeoServer is using GeoTools (and JTS) under the hood to provide those processes, there are 3 key modules all under unsupported:
Vector Processes
Geometry Processes
Raster Processes
4
votes
GeoServer deployment
You're running it under Apache and MySQL and PhP, but GeoServer is Java based.
What you want to do is to install Jetty or Tomcat, and then drop the .war into the appropriate place for that software ...
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 ...
4
votes
Convert geojson to png
I read points from a shapefile and burn in a png,
also with a color classification.
The recipe is in python, you need in java
but the structure is the same, only must to learn the
image java api:
...
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 ...
4
votes
JTS GeometricShapeFactory generate an ellipse properly
My first approach was giving me wrong results (wrong circle - a vertically elongated ellipse). It is not the right one because (to quote @whuber):
"Because Mercator projections are conformal, a ...
4
votes
Accepted
gt-geojson not able to read featurecollection
If your FeatureCollection is not homogenous (i.e. not all the same) the simple GeoJSON parser will not handle your collection, since it bases the schema on the first object.
To read a ...
4
votes
Accepted
Is there a Java API for in-memory geo indexes?
TL;DR; Don't bother, PostGIS is your friend and will be way faster than storing in memory and searching.
I did some tests with random bounding boxes on a relatively sparse data set (Electricity ...
4
votes
Accepted
Geotools JTS, find most distant points in polyline or polygon?
I think all of the JTS methods relating to distance are looking for the nearest or shortest. But providing you don't have too many vertices then you could do a brute force O(N*N) search:
...
4
votes
Accepted
Determining if route self intersects using Java?
A JTS LineString will return false for isSimple() if it intersects.
For these 2 lines (good on the left, bad on the right) the following code prints:
valid: true simple: true
valid: true simple: ...
4
votes
Accepted
gdal.jar cannot find gdalalljni on Ubuntu
1) First, you should download gdal sources (https://trac.osgeo.org/gdal/wiki/DownloadSource). I placed it to $HOME/gdal-version. Select appropriate version. For me 2.4.2 was installed on Ubuntu 18, ...
4
votes
Read GML using Java
You've imported the wrong GML and Version you want:
import org.geotools.wfs.GML;
import org.geotools.wfs.GML.Version;
To do this you will need to import gt-xsd-wfs using:
<dependency>
...
4
votes
Accepted
Not getting INFO-level messages from org.geotools.util.logging.Logging
I think you'll need to add a Logger to the DEFAULT_LOGGING.xml (or whichever level you are using) for your package, something like:
<Logger name="com.mytld.wps.pins" level="info&...
3
votes
Testing if Geometry is convex using JTS?
I am not sure if this is a more efficient way but you could also compare the area of the input polygon to the area of the convex hull of the same polygon.
The area of the convex hull of a concave ...
3
votes
Can I use GeoTools with Gradle?
Update for 2021:
repositories {
maven {
url "https://repo.osgeo.org/repository/release/"
}
}
dependencies {
implementation group: 'org.geotools', name: 'gt-shapefile', ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
java × 898geotools × 277
geoserver × 87
postgis × 68
gdal × 63
shapefile × 58
arcobjects × 58
coordinate-system × 45
jts-topology-suite × 44
openstreetmap × 40
geojson × 39
geotiff-tiff × 39
postgresql × 32
raster × 29
software-recommendations × 23
openlayers-2 × 22
javascript × 22
geometry × 22
tomcat × 22
android × 21
python × 19
wfs × 19
arcgis-desktop × 16
polygon × 16
wms × 16