【问题标题】:Is possible to write a shape file with custom attributes definition using geotools?是否可以使用 geotools 编写具有自定义属性定义的形状文件?
【发布时间】:2020-02-21 14:06:20
【问题描述】:

我需要创建一个带有自定义属性的形状文件。特别是我的问题是关于像Number,33,31 这样写的Double,我需要Number,10,3

我使用SimpleFeatureTypeBuilder 来创建字段定义和方法buildFeatureType() 来构建它。

org.geotools 有机会吗?

    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.setName("Location");

    builder.setCRS(DefaultGeographicCRS.WGS84);
    java.lang.Class<?> colClass = java.lang.Class.forName(geometryClass);
    builder.add("the_geom", colClass);
    for (Entry<String, java.lang.Class<?>> m : map.entrySet()) {

        if (!GeometryConverter.isGeometryType(m.getValue().getClass())) {
            builder.add(m.getKey(), m.getValue());
        }

    }
    // build the type
    final SimpleFeatureType LOCATION = builder.buildFeatureType();
    return LOCATION;

【问题讨论】:

    标签: java shapefile geotools


    【解决方案1】:

    不,looking at the code 显示要硬编码到 DataStoreFactory 中的大小。

    我想如果您绝对必须更改格式,您可以覆盖 createDbaseHeader 这样做,但这似乎需要做很多工作而没有真正的好处。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      • 1970-01-01
      • 2019-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多