json生成shp_解析shp文件生成geojson格式数据

这个Java程序演示了如何使用GeoTools库将SHP文件解析为GeoJSON格式。它首先读取SHAP文件,然后遍历其特征,提取城市名和几何信息。根据城市名从数据库获取县所属的市,将数据写入GeoJSON文件。
摘要由CSDN通过智能技术生成

package cn.ssk.geotools;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.net.URL;

import java.util.HashMap;

import org.geotools.data.FileDataStoreFinder;

import org.geotools.data.shapefile.ShapefileDataStore;

import org.geotools.data.simple.SimpleFeatureCollection;

import org.geotools.data.simple.SimpleFeatureIterator;

import org.geotools.data.simple.SimpleFeatureSource;

import org.geotools.factory.GeoTools;

import org.opengis.feature.simple.SimpleFeature;

import cn.ssk.mysql.AreaInfo;

import cn.ssk.mysql.MysqlUtils;

import sun.nio.cs.ext.GBK;

public class GeotoolDemo {

private static HashMap codeMap=MysqlUtils.getCodeMap();

private static HashMap jsonFiles=new HashMap<>();

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

URL url=GeoTools.class.getClassLoader().getResource("xian.shp");

File file=new File(url.toURI());

handleProcess(file);

}

public static void handleProcess(File shpfile)throws Exception{

ShapefileDataStore fdstore=(ShapefileDataStore)FileDataStoreFinder.getDataStore(shpfile);

fdst

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值