如何将shape数据 导入到Postgresql数据库中(单个和批量)

PostgreSQL shapefile 导入导出 1.pgsql2shp & shp2pgsql 命令行工具方式导入导出 shapefile 2.QGIS工具导入导出 shapefile 3.OGC/EPSG/SRS/CRS 等相关概念 阅读详情
AI摘要

本文详细介绍了将shape数据导入PostgreSQL的各种方式,包括QGIS单次导入、PostGIS工具导入、pgAdmin2命令工具单次导入和Python脚本批量导入,对比了各自的特点和适用场景。

一. 背景

很多时候我们需要将shape数据导入到Postgresql数据库,将数据db化。
本文主要讲解四种方式:
使用QGIS工具导入(单个)、通过POSTGIS工具导入(单个或少量)、使用postgresql2 命令工具导入(单个)、使用python脚本批量导入shape数据(批量)。

导入数据的前提:在postgreSQL中创建PostGIS空间扩展模块,在连接数据库后执行下列sql:

CREATE EXTENSION postgis;

二. 使用QGIS工具导入(单个)

前提:安装QGIS

1. 使用QGIS工具打开需要导入的shp文件

打开shp文件方式可以参考博文:QGIS教程 加载shape数据 矢量数据(批量)

2.连接PG数据库

在QGIS工具的左侧工具部分,选择【PostgreSQL】右键点击 【New Connection】
在这里插入图片描述
输入对应的数据库相关信息,包括账号、密码、端口、数据库名等信息。最后点击【确定】如无报错即可成功创建数据库连接。
在这里插入图片描述

3.使用Database导入数据

点击上方菜单栏【Database】的【DB Manager】
在这里插入图片描述
可以看到对应数据库PG连接
在这里插入图片描述
选择对应数据库后,点击按钮【Import Layer/File】
在这里插入图片描述
然后即可选择对应shape文件,最后点击【确定】按钮,即导入成功。
在这里插入图片描述

在数据库中即可看到对应shape数据的表数据。

三. 通过PostGIS工具导入(单个或少量)

1.打开 应用PostGIS Bundle 3

在这里插入图片描述

2.AddFile 添加shape文件

点击【AddFile】按钮,选择对应需要导入的shape文件,可以选择单个或者多个
在这里插入图片描述

3.开始导入【import】

选择shape文件后,点击【import】,即可导入对应文件dbf或者shp到数据库中
在这里插入图片描述

GIS:shp文件导入到pgsql数据库,且将投影坐标转换为地图用的地理坐标 shp文件想导入到postgres数据库,并且需要把shp文件中的投影坐标(平面坐标)转换为地图可用的地理坐标。 阅读详情

相关推荐

QGIS操作PostGIS(PostgreSQL)中的数据

文章目录1. 连接数据库2. 加载数据2.1 从含有geometry/geography类型的表直接创建图层2.2 从普通表创建图层3. 编辑数据 1. 连接数据库 数据库必须安装了PostGIS extension,否则无法查看数据表。 (使用语句Create extension postgis添加该模块) 2. 加载数据 如图所示,test表含有geometry列,traj_0、traj_1等是普通表但含有经纬度数据。 2.1 从含有geometry/geography类型的表直接创建图层 直接从b

Yvelyne的博客 5439

使用Gdal将dwg文件导入到postgresql数据库

使用Gdal将dwg文件导入到postgresql数据库

qq_33305650的博客 1188

10.(地图工具篇)PostgreSQL导入shape数据

地图之家:cesium+leaflet+echart+地图数据+地图工具等相关内容的介绍 前置博客地址: 9.(地图工具篇)ArcMap处理路网数据成单线格式1、打开PostGIS专门的Shapefile导入工具 2、连接指定的数据库 3、选择shape文件 4、设置SRID为4326 5、点击import进行导入 出错原因: 你提供的路径中含有中文。不要在导入的文件内含有中文,另外数据库字符集格式要是utf-8 以上截图内容则导入成功 6、pgAdmin查看效果...

GIS之家家长 1566

PostgreSQL导入shape数据(地图工具篇.10)

听老人家说:多看美女会长寿 地图之家总目录(订阅之前建议先查看该博客) 1、打开PostGIS专门的Shapefile导入工具 2、连接指定的数据库 3、选择shape文件 4、设置SRID为4326 5、点击import进行导入 出错原因: 你提供的路径中含有中文。不要在导入的文件内含有中文,另外数据库字符集格式要是utf-8 以上截图内容则导入成功 6、pgAdmin查看效果 ...

地图之家 3488

将Shapefile数据导入PostgreSQL的桌面应用实现

Shapefile(.shp)格式是一种广泛使用的矢量数据格式,由ESRI公司为支持其地理信息系统软件而开发。一个标准的Shapefile文件包含至少三个主要文件,分别用于存储几何数据、属性数据和索引数据。具体来说,.shp文件存储了实际的几何形状信息,.shx文件包含了形状索引,而*.dbf文件存储了与几何形状相关的属性数据。这些文件通常以相同的文件名存放,但扩展名不同。为了读取和处理Shapefile格式的数据,GIS专业人员通常会使用多种工具。

weixin_31974443的博客 868

如何在NVIDIA CX6 网卡和华为CE交换机上为RDMA协议使能DCQCN和PFC

【代码】如何在NVIDIA CX6 网卡和华为CE交换机上使能DCQCN和PFC。

Markchen7788的博客 5106

基于FPGA的ov5640摄像头简易图像采集装置详解

本文介绍一种基于FPGA的,通过流模式DDR实现OV5640摄像头数据采集并显示的方法。

qq_42230252的博客 1万+

uniapp [安卓苹果App端] - 详细实现下载文件保存到用户手机本地,指定文件存储位置路径及文件夹名称下载并保存,Uniapp app端将文件下载保存并储存到指定目录(手机系统存储空间权限检测)

uni-app,安卓Android,苹果ios,安卓app端,苹果App端,uniapp苹果安卓app,app端下载文件,移动端文件下载,并保存到手机本地存储空间,uniapp下载文件保存到手机本地,iOS下载文件怎么保存,系统读写存储空间权限,下载文件到本地详细流程及源代码,保存自定义目录,uniapp,实现下载文件并保存到本地,文件后缀,如何指定手机的存放目录路径url,点击下载文档到手机中并提示存储位置,如何在uniapp中实现文件下载功能,uniApp文件下载,怎么指定文件保存目录,下载报错,没反应

🏆 前端领域优质创作者 1万+

YOLOv11改进 | 损失函数改进篇 | MPDIoU、InnerMPDIoU助力细节涨点(二次创新 + 代码解析)

本文为读者详细介绍了YOLOv11模型的最新改进,带来的改进机制是最新的损失函数MPDIoU和融合了最新的Inner思想的InnerMPDIoU(效果打爆之前的所有的损失函数提升检测精度和处理细节方面的作用。通过深入探讨MPDIoU和InnerMPDIoU(全网首发)的工作原理和实际代码实现,本文旨在指导读者如何将这些先进的损失函数技术应用到YOLOv11模型中,以提高其性能和准确性。文章内容涵盖从理论基础、代码实现,到实际教你如何添加本文的机制到你的模型中。

Snu77的博客 4036

【蓝桥杯单片机组第八届省赛】— 基于单片机的电子钟程序设计与调试

1、初赛试题 1.1 基本要求 (1)使用 CT107D 单片机竞赛板, 完成“电子钟” 功能的程序设计与调试; (2)设计与调试过程中,可参考组委会提供的“资源数据包”; (3)Keil 工程文件以准考证号命名, 完成设计后, 提交完整、 可编译的 Keil工程文件到服务器。 1.2 硬件框图 1.3功能描述 1.3.1 初始化 (1)关闭蜂鸣器、继电器等无关外...

Fanjufei的博客 3661

【数据集处理】基于ERA5 气温/湿度数据计算湿球温度并判别湿热浪

【数据集处理】基于ERA5 气温/湿度数据计算湿球温度并判别湿热浪

WW、forever的博客 493

YOLOv8 改进有效涨点专栏目录 | 含卷积、主干、注意力机制、Neck、检测头、损失函数、二次创新C2PSA/C3k2等各种网络结构改进

YOLOv8在目标检测领域的地位与优势模型改进的意义与价值本专栏的特色与创新点读者学习路径建议关键改进点回顾不同场景的模型选型建议开源社区资源汇总持续学习路径指南YOLOv8在目标检测领域的地位与优势模型改进的意义与价值本专栏的特色与创新点读者学习路径建议关键改进点回顾不同场景的模型选型建议开源社区资源汇总持续学习路径指南。

weixin_39818775的博客 1075

零基础学simulink仿真建模--使用Simulink来构建一个混合动力无人机中燃料电池与锂电池协同控制的仿真模型

延长飞行时间:燃料电池的能量密度高于锂电池,适合长时间稳定供电。提高功率密度:锂电池能够快速响应瞬时高功率需求,比如起飞和加速阶段。优化能源管理:通过有效的能量管理系统,可以根据实际需求动态调整燃料电池和锂电池的工作状态,从而提高整体效率。通过上述步骤,我们简要介绍了如何基于Simulink实现混合动力无人机中燃料电池与锂电池协同控制的仿真模型。

amy_mhd的博客 193

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

上一篇: 在Postgresql 下安装QGIS
下一篇: Postgresql 怎么实现在局域网中访问
业余敲代码
博客等级 码龄9年 3751粉丝 145原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址