标签: geotools

GeoTools - 如何使用GeoTools类进行航位推算和课程计算

我目前正在使用GeoTools工具包对海洋船只数据进行计算,例如计算两个lon/lat点之间的Great Circle距离.我还有两个需要满足的要求,但我不确定在GeoTools中查找类来进行这些计算.

要求#1: 计算移动船舶的航位推算位置.

输入值:

  • 目前的经度
  • 目前的纬度
  • 当前速度(可以很容易地转换为距离,给定时间'T')
  • 当前课程

预期产量:

  • 在经过时间'T'之后估计经度/纬度位置

要求#2: 计算从位置'A'到位置'B'的路线.

输入值:

  • 经度'A'
  • 纬度'A'
  • 经度'B'
  • 纬度'B'

预期产量:

  • 当然直接从'A'指向'B'

任何人都可以指导我进入能够执行这些计算的GeoTools课程吗?我被GeoTools中的大量课程所震撼,我似乎无法找到我需要做的事情.

java geospatial dead-reckoning latitude-longitude geotools

3
推荐指数
1
解决办法
3007
查看次数

如何在geotools中获取要素的顶点

有人能告诉我如何通过java geotools api获取特征的顶点吗?

在我的情况下,我在postgis中有一个多边形图层,我可以查询该图层的所有特征,我需要知道每个特征的顶点.

        SimpleFeatureSource featureSource = pgDatastore.getFeatureSource("hb_thuadat");
        Filter filter = CQL.toFilter("sothua = 10");
        SimpleFeatureCollection collection = featureSource.getFeatures( filter );
        System.out.print("tong so:"+ collection.size());

        FeatureIterator iter=collection.features();
        while( iter.hasNext() ){
            Feature feature = iter.next();
            System.out.println( feature.getIdentifier());
            //how to get vertices of feature here???
        }
Run Code Online (Sandbox Code Playgroud)

任何帮助都很感激!谢谢!

geotools

3
推荐指数
1
解决办法
1355
查看次数

JTS:如何将多边形转换为MultiLineString

我有多边形形状,我想将其转换为MultiLineString.请注意,通常方向不同:使用GeometryFactory构建多边形从点,坐标,线等.我开始考虑GeometryTransformer,但很难理解那里的文档...所以我有这个:

import com.vividsolutions.jts.geom.*;
...
GeometryFactory gFactory = new GeometryFactory();
GeometryTransformer gTransform = new GeometryTransformer();
Polygon polygon = gFactory.createPolygon(someLinearRing, null);
MultiLineString mlString = polygon.TODO?
Run Code Online (Sandbox Code Playgroud)

如何继续TODO

java gis jts geotools

3
推荐指数
1
解决办法
1578
查看次数

将 ECQL 从 geotool 转换为 SQL

是否有用于将 ECQL(geotools) 转换为 SQL 的 java 库?

CQL 和 ECQL CQL(通用查询语言)是 OGC 为目录 Web 服务规范创建的查询语言。

java geoserver geotools

3
推荐指数
1
解决办法
153
查看次数

为什么此 GeoTool 片段不生成可见的 shapefile?

我正在创建一个简单的程序,它从 csv 文件中读取值并根据这些值创建一个 shp 文件。这是对这个例子的轻微修改

形状文件似乎已创建,但是当我使用另一个片段查看形状文件时我什么也没看到。我可以使用此程序查看其他示例 shapefile。

我的代码中缺少什么?

我的数据:

LAT1, LON1, LAT2, LON2, LAT3, LON3, LAT3, LON3, CITY, NUMBER
10, 10, 20, 20, 30, 30, 10, 10, Trento, 140
Run Code Online (Sandbox Code Playgroud)

我的代码:

public class ShapeReaderWriter {

    public static void main(String[] args) throws Exception {

        //read the xml file
        File file = FileUtils.getFile("D:\\workspaces\\Routeguard\\Xml2Shape\\src\\com\\meteogroup\\conversion\\locations.csv");

        List<String> lines = FileUtils.readLines(file, "utf-8");

        final SimpleFeatureType TYPE = createFeatureType();

        List<SimpleFeature> features = new ArrayList<SimpleFeature>();        

        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
        SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE); …
Run Code Online (Sandbox Code Playgroud)

java geotools

2
推荐指数
1
解决办法
1713
查看次数

使用Clojure中的Geotools - 未处理的java.lang.NoSuchFieldError METER

好的,所以问题的核心是我收到了这个错误:

 Unhandled java.lang.NoSuchFieldError
 METER
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

               Parser.java:  560  org.geotools.referencing.wkt.Parser/parseSpheroid
               Parser.java:  656  org.geotools.referencing.wkt.Parser/parseDatum
               Parser.java:  867  org.geotools.referencing.wkt.Parser/parseGeoGCS
               Parser.java:  224  org.geotools.referencing.wkt.Parser/parseCoordinateReferenceSystem
               Parser.java:  204  org.geotools.referencing.wkt.Parser/parseCoordinateReferenceSystem
ReferencingObjectFactory.java: 1090  org.geotools.referencing.factory.ReferencingObjectFactory/createFromWKT
        PrjFileReader.java:   94  org.geotools.data.PrjFileReader/<init>
        PrjFileReader.java:   68  org.geotools.data.PrjFileReader/<init>
  ShapefileSetManager.java:  106  org.geotools.data.shapefile.ShapefileSetManager/openPrjReader
ShapefileFeatureSource.java:  519  org.geotools.data.shapefile.ShapefileFeatureSource/readAttributes
ShapefileFeatureSource.java:  475  org.geotools.data.shapefile.ShapefileFeatureSource/buildFeatureType
ShapefileFeatureStore.java:  132  org.geotools.data.shapefile.ShapefileFeatureStore/buildFeatureType
 ContentFeatureSource.java:  343  org.geotools.data.store.ContentFeatureSource/getAbsoluteSchema
 ContentFeatureSource.java:  312  org.geotools.data.store.ContentFeatureSource/getSchema
     ContentDataStore.java:  345  org.geotools.data.store.ContentDataStore/getSchema
NativeMethodAccessorImpl.java:   -2  sun.reflect.NativeMethodAccessorImpl/invoke0
NativeMethodAccessorImpl.java:   62  sun.reflect.NativeMethodAccessorImpl/invoke
DelegatingMethodAccessorImpl.java:   43  sun.reflect.DelegatingMethodAccessorImpl/invoke
               Method.java:  483  java.lang.reflect.Method/invoke
            Reflector.java:   93  clojure.lang.Reflector/invokeMatchingMethod
            Reflector.java:   28  clojure.lang.Reflector/invokeInstanceMethod
              geometry.clj:   40  grafter.tabular.geometry/store->dataset
              geometry.clj:   39  grafter.tabular.geometry/store->dataset
              geometry.clj:   51  grafter.tabular.geometry/eval17505/fn
              MultiFn.java:  233  clojure.lang.MultiFn/invoke …
Run Code Online (Sandbox Code Playgroud)

java clojure geotools

2
推荐指数
1
解决办法
364
查看次数

Geotools 可以根据经纬度创建 Geohash 吗?

最近我一直在使用Geotools库(http://docs.geotools.org/latest/javadocs/)来处理一些简单的地理数据。然而,该库是如此强大,以至于令我惊讶的是它似乎没有提供从纬度和经度创建 geohash 的功能。任何人都可以向我指出有关如何使用 Geotools 库创建 geohash 的文档吗?

geohashing geotools

2
推荐指数
1
解决办法
1250
查看次数

如何分割 JTS 多边形

我有一个大多边形,我想找到与多边形相交的要素,但由于多边形太大,我遇到了超时异常。

我试图研究 JTS 方法,但不知道如何使用它。

final List<Coordinate> coordinates = List.of(new Coordinate(0, 0), new Coordinate(-1, 1),
        new Coordinate(1, 3), new Coordinate(2, 3), new Coordinate(3, 1), new Coordinate(0, 0));
final GeometryFactory factory = new GeometryFactory();
final Polygon polygon = factory.createPolygon(coordinates.toArray(new Coordinate[0]));
final Geometry envelope = polygon.getEnvelope();
Run Code Online (Sandbox Code Playgroud)

有人可以指导我如何分割多边形对象吗?

java jts geotools

2
推荐指数
1
解决办法
432
查看次数

如何在JTS中交换来自Lat,Long到Long,Lat的jts.geom.Geometry对象的坐标

我有一个类型的几何对象(com.vividsolutions.jts.geom.Geometry).它目前处于纬度,经度形式,我想翻转坐标使其经度纬度,以便我可以使用GeoJSON格式为mongodb.

我看到的约束是:a)我想要翻转坐标的输入是Geometry对象.b)Geometry对象可以是Polygon类型或Multipolygon.c)我想在类型转换为多边形/多边形之前翻转坐标

我试过geo.reverse()但它不起作用.

同样,我尝试过使用:CRSAuthorityFactory factory = CRS.getAuthorityFactory(true); CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4326");

另一种选择,我没有看到它的工作.

谢谢!

java jts geotools

1
推荐指数
1
解决办法
4394
查看次数

如何使用geoTools中的GeometricShapeFactory在地图上创建圆

我目前正在使用以下代码创建 GeoJson 多边形。这给我带来了一个无效的坏循环......

在本例中RADIUS = 1609.34 ,即 1 英里(以米为单位)。

        public  GeoJsonPolygon createRadiusPolygon(  Point point,double RADIUS) {       

              GeometricShapeFactory shapeFactory = new GeometricShapeFactory();
              shapeFactory.setNumPoints(32);
              shapeFactory.setCentre(new com.vividsolutions.jts.geom.Coordinate(point.getX(), point.getY()));
              shapeFactory.setSize(RADIUS * 2);
              com.vividsolutions.jts.geom.Geometry circle = shapeFactory.createCircle();
              List<Point> points = new ArrayList<Point>();
                for (com.vividsolutions.jts.geom.Coordinate coordinate : circle.getCoordinates()) {
                    Point lngLatAtl = new Point(coordinate.x, coordinate.y);
                    points.add(lngLatAtl);
                }
                Collections.reverse(points);
                return new GeoJsonPolygon(points);
            }
Run Code Online (Sandbox Code Playgroud)

参考: http ://docs.geotools.org/stable/userguide/library/jts/geometry.html

目前,如果我使用 Point(-73.87,40.84) RADIUS = 1609.34,我会得到以下链接。 https://gist.githubusercontent.com/VanitySoft/56c4ce0f5c1c7e7fe0461ed46fd5ed11/raw/94544750a140d81780ebe9206395a21ab88bb1f7/circle

===已解决== 来自@Ian 的回答:在他的回答中使用方法。RADIUS 以英里为单位,用于获取用于创建 GeoJson 的圆。

...
  com.vividsolutions.jts.geom.Point jtsPoint =  new GeometryFactory().createPoint(new com.vividsolutions.jts.geom.Coordinate(point.getY(), point.getX())); …
Run Code Online (Sandbox Code Playgroud)

java latitude-longitude geotools

1
推荐指数
1
解决办法
8049
查看次数

为什么在创建 CoordinateReferenceSystem 时会收到 NoSuchAuthorityCodeException?

我有一个 EPSG:3857 格式的坐标,需要将其转换为 EPSG:4326。对于转换,我使用 geotools。当查找我能找到的每个示例时,但我似乎得到了一个在任何地方都没有解释的异常。

这是我尝试做的事情。

    private CoordinateReferenceSystem sourceCRS;
    private CoordinateReferenceSystem targetCRS;

private GeoCoordinate transform(GeoCoordinate geoCoordinate)
    throws FactoryException,
    TransformException {
    CRSAuthorityFactory factory = CRS.getAuthorityFactory(true);
    this.sourceCRS = factory.createCoordinateReferenceSystem("EPSG:3857");
    this.targetCRS = factory.createCoordinateReferenceSystem("EPSG:4326");

    // Or i try to use the CRS directly, that does not change anything

    // this.targetCRS = CRS.decode("EPSG:4326");
    // this.sourceCRS = CRS.decode("EPSG:3857");

    MathTransform transform = CRS.findMathTransform(this.sourceCRS, this.targetCRS, false);
    GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
    Point point =
        geometryFactory.createPoint(new Coordinate(geoCoordinate.getLongitude(), geoCoordinate.getLatitude()));
    Point targetPoint = (Point) JTS.transform(point, transform);
    return new GeoCoordinate(targetPoint.getX(), …
Run Code Online (Sandbox Code Playgroud)

java openlayers geotools

1
推荐指数
1
解决办法
2986
查看次数

使用 GeoTools 计算两点之间的大距离

GeoTools 和 GIS 新手,我正在尝试使用 GeoTools 库计算孟买和德班之间的距离。我正在接近小距离的准确结果,但当我进行较大距离时,计算结果偏离了 2000 公里,我不完全理解 CRS 系统。下面是我计算孟买和德班之间距离的代码

    Coordinate source = new Coordinate(19.0760, 72.8777);   ///Mumbai Lat Long
    Coordinate destination1 = new Coordinate(-29.883333, 31.049999); //Durban Lat Long

    GeometryFactory geometryFactory = new GeometryFactory();
    Geometry point1 = geometryFactory.createPoint(source);
    Geometry point2 = geometryFactory.createPoint(destination1);

    CoordinateReferenceSystem auto = auto = CRS.decode("AUTO:42001,13.45,52.3");
    MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, auto);

    Geometry g3 = JTS.transform(point1, transform);
    Geometry g4 = JTS.transform(point2, transform);

    double distance = g3.distance(g4);
Run Code Online (Sandbox Code Playgroud)

gis geotools

1
推荐指数
1
解决办法
2496
查看次数

GeoJSON:检查地理坐标是否在多边形内

我有以下 GeoJSON 数据文件,其中包含一个带坐标的多边形。

[
    {
        "geometry": {
        "type": "Polygon",
        "coordinates": 
[
        [
          [
            9.137248,
            48.790411
          ],
          [
            9.137248,
            48.790263
          ],
          [
            9.13695,
            48.790263
          ],
          [
            9.137248,
            48.790411
          ]
        ]
      ]
    }
    }
  ]
Run Code Online (Sandbox Code Playgroud)

在 的帮助下org.geotools.geojson.geom.GeometryJSON,我正在解析com.vividsolutions.jts.geom.Polygon类中的 JSON 坐标,如下所示。并检查是否Coordinate(9.13710, 48.790360)在这个多边形内。

GeometryJSON g = new GeometryJSON();
         com.vividsolutions.jts.geom.Polygon polygon = g.readPolygon(new File(fileLocation));
         System.out.println("Type="+polygon.getGeometryType());

         GeometryFactory gf = new GeometryFactory();
         boolean pointIsInPolygon = polygon.contains(gf.createPoint(new Coordinate(9.13710, 48.790360)));
         System.out.println("Point is in polygon="+pointIsInPolygon);
Run Code Online (Sandbox Code Playgroud)

但是我的程序总是给我下面的结果,即给定的坐标不在多边形中。

结果

类型=多边形

点在多边形中=假

a) 你能看出为什么pointIsInPolygon是假的。我错过了什么吗?

b) 我应该在这里给出什么坐标,所以 …

java geometry point-in-polygon geojson geotools

0
推荐指数
1
解决办法
3029
查看次数