当前位置:网站首页>How to configure GDAL under idea
How to configure GDAL under idea
2022-07-03 07:50:00 【A reserved and calm man】
1. download gdal Compress and unzip the package
2. Reference in project gdal.jar


3. quote dll file


take dll Copy the file to the root directory of the project 
4. take shpfile File transfer out geojson file
public static void main(String[] args) {
// Register all drivers
ogr.RegisterAll();
// In order to support Chinese path , Please add the following code
gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8","YES");
// In order to make the property sheet fields support Chinese , Please add the following sentence
gdal.SetConfigOption("SHAPE_ENCODING","");
//shp File location
String strVectorFile = "C:\\Users\\10469\\Desktop\\ Township \\ Township .shp";
// Open the data
DataSource ds = ogr.Open(strVectorFile,0);
if (ds == null)
{
System.out.println(" fail to open file !" );
return;
}
System.out.println(" File opened successfully !" );
Driver dv = ogr.GetDriverByName("GeoJSON");
if (dv == null)
{
System.out.println(" Failed to open driver !" );
return;
}
System.out.println(" Turn on the driver successfully !" );
// Output geojson Location and file name of
dv.CopyDataSource(ds, "C:\\Users\\10469\\Desktop\\ Township \\ Township .json");
System.out.println(" Conversion success !" );
System.out.println(System.getProperty("java.library.path"));
}
5. take geojson File transfer out shpfile file
public static void main(String[] args) {
// Register all drivers
ogr.RegisterAll();
// In order to support Chinese path , Please add the following code
gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8","YES");
// In order to make the property sheet fields support Chinese , Please add the following sentence
gdal.SetConfigOption("SHAPE_ENCODING","");
//shp File location
String strVectorFile = "E:\\opt\\trans.json";
// Open the data
DataSource ds = ogr.Open(strVectorFile,0);
if (ds == null)
{
System.out.println(" fail to open file !" );
return;
}
System.out.println(" File opened successfully " );
String strDriverName = "ESRI Shapefile";
org.gdal.ogr.Driver dv = ogr.GetDriverByName(strDriverName);
if (dv == null)
{
System.out.println(" Failed to open driver !" );
return;
}
System.out.println(" Turn on the driver successfully !" );
// Output geojson Location and file name of
dv.CopyDataSource(ds, "E:\\opt\\trans\\test.shp");
System.out.println(" Conversion success !" );
}
边栏推荐
猜你喜欢

Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select

技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型

Go language foundation ----- 09 ----- exception handling (error, panic, recover)

OSPF experiment

Go language foundation ------ 12 ------ JSON

Screenshot tool snipaste

技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务

研究显示乳腺癌细胞更容易在患者睡觉时进入血液

An article for you to understand - Manchester code

技术干货|昇思MindSpore创新模型EPP-MVSNet-高精高效的三维重建
随机推荐
s7700设备如何清除console密码
Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction
Go language foundation ----- 07 ----- method
GoLang之结构体
When did you find out that youth was over
Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer
yarn link 是如何帮助开发者对 NPM 包进行 debug 的?
PAT甲级 1029 Median
【LeetCode】4. Best Time to Buy and Sell Stock·股票买卖最佳时机
go语言-循环语句
Go language foundation ----- 13 ----- file
[at] ABC 258g - Triangle triples reachable - violence
Technical dry goods | Bert model for the migration of mindspore NLP model - text matching task (2): training and evaluation
Huawei switch: configure Telnet, SSH and web access
Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
哪一刻你才发现青春结束了
What is a data type? What is the use of data types?
Technical dry goods Shengsi mindspire elementary course online: from basic concepts to practical operation, 1 hour to start!
Research shows that breast cancer cells are more likely to enter the blood when patients sleep