geotools

Java GeoTools: how to find distance from a point to closest polygon in shape file

╄→尐↘猪︶ㄣ 提交于 2019-12-24 06:49:23
问题 So I have a shp-file containing a bunch of polygons. In this case, a polygon is a body of in-land water (like lakes and that kind of stuff). My system is tracking a moving object, so in order to determine what this object is, I would like to see if this object is in water or on land AND how far it is to NEAREST shore (yes, both if it's in or out of water). I will take a sample point from the object once in a while and test it. The system is written in Java, and I have imported GeoTools

Add new column attribute to the shapefile and save it to database using Geotools Java

≯℡__Kan透↙ 提交于 2019-12-23 01:29:11
问题 I am transforming a shapefile by adding a new column attributes. Since this task is performed using Java, the only option I know for now is using Geotools. I have 2 main concerns: 1. I am not able to figure out how do I actually add a new column variable. Is the feature.setAttribute("col","value") the answer? I see from this post just the example:https://gis.stackexchange.com/questions/215660/modifying-feature-attributes-of-a-shapefile-in-geotools but I dont get the solution. //Upload the

Add new column attribute to the shapefile and save it to database using Geotools Java

╄→гoц情女王★ 提交于 2019-12-23 01:29:09
问题 I am transforming a shapefile by adding a new column attributes. Since this task is performed using Java, the only option I know for now is using Geotools. I have 2 main concerns: 1. I am not able to figure out how do I actually add a new column variable. Is the feature.setAttribute("col","value") the answer? I see from this post just the example:https://gis.stackexchange.com/questions/215660/modifying-feature-attributes-of-a-shapefile-in-geotools but I dont get the solution. //Upload the

Reading an ESRI shapefile from a zip-file during Runtime in Java - DataStoreFinder.getDataStore(connectParameters) returns null

核能气质少年 提交于 2019-12-21 09:06:13
问题 We are building a service for uploading zip-files containing an ESRI-shapefile. The service should be able to read the shapefile and do stuff with its content. So I've built a class that unzips the zip-file to temporary folder (subfolder of System.getProperty("java.io.tmpdir")). Another class calls the unzip method from the Unzip-class and it then tries to read the unpacked shapefile using Geotools. It uses the Geotools DataStoreFinder.getDataStore(Map params) method to create a datastore

GeoTools: How to build a point? (imports issue)

╄→гoц情女王★ 提交于 2019-12-13 07:39:37
问题 I'm following the GeoTools documentation and found this: GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); Coordinate coord = new Coordinate(45, 15); Point point = geometryFactory.createPoint(coord); When I put it in intellij IDE, for each class there are several suggested imports to use. What import I need to select? Alternative way (with same issue) is: GeometryBuilder builder = new GeometryBuilder(DefaultGeographicCRS.WGS84); Point point = builder.createPoint(45,

Trying to convert kml to geojson and getting ArrayIndexOutOfBoundsException with geotools

回眸只為那壹抹淺笑 提交于 2019-12-13 04:16:54
问题 I am trying to convert a kml to geojson with geotools 20.5 and i am getting ArrayIndexOutOfBoundsException. The file i am trying to convert can be converted on other frameworks correctly but on geotools i had this error. I am using geotools 20.5 and java 8. Can someone help me? My code: try { reader = new FileInputStream("file.kml"); PullParser parser = new PullParser(new KMLConfiguration(), reader, SimpleFeature.class); FeatureJSON fjson = new FeatureJSON(); FileWriter tmp = new FileWriter(

Convert Kml with multiple features to Geojson

谁说我不能喝 提交于 2019-12-12 11:23:19
问题 I use this code to convert a kml file with a single feature to a GeoJson file. String kmlToGeoJson(String fileName) throws IOException, ParserConfigurationException, SAXException, XMLStreamException { FileInputStream reader = new FileInputStream(fileName); PullParser parser = new PullParser(new KMLConfiguration(),reader, SimpleFeature.class); FeatureJSON fjson = new FeatureJSON(); FileWriter tmp = new FileWriter(fileName + ".geojson"); BufferedWriter writer = new BufferedWriter(tmp);

Why can't this code produce a points layer in GeoTools

て烟熏妆下的殇ゞ 提交于 2019-12-12 06:17:21
问题 I am testing adding a collection of points to a map utilizing the Geotools API. I've been following this example as best I could Problem creating a point and adding it to FeatureCollection, as the example code is old, and things like FeatureCollections is deprecated. I tried using DefaultFeatureCollection instance instead, and I am not sure if I am using it correctly, and that is why the points do not appear on the map. What am I doing wrong? Here is some of my code: private void plotMarkers(

java.lang.ClassNotFoundException: it.geosolutions.jaiext.range.Range

会有一股神秘感。 提交于 2019-12-12 06:00:56
问题 I recently started my first program with GeoTools in which i was also using JAI- Java Advanced Imaging. I found following error Exception in thread "main" java.lang.NoClassDefFoundError: it/geosolutions/jaiext/range/Range at it.geosolutions.jaiext.crop.CropDescriptor.(CropDescriptor.java:62) at it.geosolutions.jaiext.crop.CropSpi.updateRegistry(CropSpi.java:56) at javax.media.jai.OperationRegistry.registerServices(OperationRegistry.java:2056) at javax.media.jai.ThreadSafeOperationRegistry

GeoTools - drawing points on image

烈酒焚心 提交于 2019-12-12 02:25:29
问题 I'm using geoTools 14.1 I'm trying to plot on an image some points This is the code I'm using: double[][] points = new double[8][2]; points[0] = new double[]{45.46433710338643, 9.190417528152478}; points[1] = new double[]{45.46195085146914, 9.189746320685355}; points[2] = new double[]{45.460062304163635, 9.19015527826191}; points[3] = new double[]{45.472950871127445, 9.17363731952788}; points[4] = new double[]{45.4737153001908,9.203728795018847}; points[5] = new double[]{45.4849795331724,9