2024年实战 Java读取shp文件内容,Zookeeper一致性级别分析

最后

2020年在匆匆忙忙慌慌乱乱中就这么度过了,我们迎来了新一年,互联网的发展如此之快,技术日新月异,更新迭代成为了这个时代的代名词,坚持下来的技术体系会越来越健壮,JVM作为如今是跳槽大厂必备的技能,如果你还没掌握,更别提之后更新的新技术了。

更多JVM面试整理:

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

大坑,搞了半天沃日,去官网的指导文档下不下来,要换源

org.geotools

gt-shapefile

22-RC

重点重点重点 换成这个源

geotools

geotools

http://maven.icm.edu.pl/artifactory/repo/

true

实例代码


Map<String, Object> map = new HashMap<String, Object>();

File file = new File(“C:\Users\86182\Desktop\ziyuan\zj-dj\zj-dj.shp”);

map.put(“url”, file.toURI().toURL());// 必须是URL类型

ArrayList models = new ArrayList<>();

DataStore dataStore = DataStoreFinder.getDataStore(map);

//字符转码,防止中文乱码

((ShapefileDataStore) dataStore).setCharset(Charset.forName(“utf8”));

String typeName = dataStore.getTypeNames()[0];

FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);

FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures();

FeatureIterator features = collection.features();

while (features.hasNext()) {

// 迭代提取属性

SimpleFeature feature = features.next();

Iterator<? extends Property> iterator = feature.getValue().iterator();

String name = “”;

String type = “”;

String mapId = “”;

while (iterator.hasNext()) {

Property property = iterator.next();

// property 属性自己debug看下

// “the_geom” 点、线、面

if (property.getName().toString().equals(“type”)) {

type = property.getValue().toString();

}

if (property.getName().toString().equals(“name”)) {

name = property.getValue().toString();

}

if (property.getName().toString().equals(“id”)) {

最后

分布式技术专题+面试解析+相关的手写和学习的笔记pdf

还有更多Java笔记分享如下:

image

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)收录**

需要这份系统化的资料的朋友,可以点击这里获取

  • 27
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java可以使用一些库来读取和处理SHP文件,其中最常用的是开源库GeoTools。以下是一个简单的示例代码,展示了如何使用GeoTools读取SHP文件: ```java import org.geotools.data.FileDataStore; import org.geotools.data.FileDataStoreFinder; import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.data.simple.SimpleFeatureIterator; import org.opengis.feature.simple.SimpleFeature; public class SHPReader { public static void main(String[] args) { try { // 打开SHP文件 FileDataStore dataStore = FileDataStoreFinder.getDataStore(new File("path/to/your/file.shp")); // 获取SHP文件中的要素集合 SimpleFeatureCollection features = dataStore.getFeatureSource().getFeatures(); // 遍历要素集合 try (SimpleFeatureIterator iterator = features.features()) { while (iterator.hasNext()) { SimpleFeature feature = iterator.next(); // 处理每个要素的属性和几何信息 System.out.println("属性信息: " + feature.getAttribute("attributeName")); System.out.println("几何信息: " + feature.getDefaultGeometry()); } } // 关闭数据存储 dataStore.dispose(); } catch (Exception e) { e.printStackTrace(); } } } ``` 在代码中,你需要将`"path/to/your/file.shp"`替换为你实际的SHP文件路径。然后,你可以通过`feature.getAttribute("attributeName")`来获取每个要素的属性信息,`feature.getDefaultGeometry()`来获取几何信息。 请注意,这只是一个基本的示例,你可以根据自己的需求进一步扩展和处理SHP文件中的数据。同时,确保你已经将GeoTools库添加到你的项目中,并正确引入所需的依赖项。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值