场景

Geoserver简介

GeoServer是OGC Web服务器规范的J2EE实现,利用GeoServer可以方便地发布地图数据,允许用户对特征数据进行更新、删除、插入操作,通过GeoServer可以比较容易地在用户之间迅速共享空间地理信息。GeoServer是开源软件。

GeoServer 是基于 Java 的软件服务器,允许用户查看和编辑地理空间数据。使用开放地理空间联盟(OGC)提出的开放标准,GeoServer 在地图创建和数据共享方面具有极大的灵活性。

GeoServer允许您向世界显示您的空间信息。实施Web地图服务(WMS)标准,GeoServer可以创建各种输出格式的地图。一个免费的地图库OpenLayers已集成到GeoServer中,从而使地图生成快速简便。GeoServer基于GeoTools(一种开放源Java GIS工具包)构建。

Geoserver官网

http://geoserver.org/

注:

博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

Geoserver下载

进入官网,点击Stable下版本标签进入下载页面

然后选择二进制文件进行下载,也可以选择后面的war包下载部署到Tomcat中运行

下载解压之后的目录如下

修改Geoserver端口号

找到解压目录下start.ini,右键编辑,找到jetty.port,这里将端口号修改为8000

启动Geoserver

找到bin下的startup.bat,双击启动,如果控制台没有报错,则保持命令行开启

登录Geoserver

打开浏览器输入

http://localhost:8000/geoserver

登录用户名密码

admin

geoserver

获取地图数据文件

在发布之前,需要有地图数据源文件,这里可以从官方示例文档中进行下载

https://docs.geoserver.org/stable/en/user/_downloads/30e405b790e068c43354367cb08e71bc/nyc_roads.zip

将数据源解压后

就能看到我们所需要的shp文件。

将解压后的整个目录放在前面Geoserver解压目录下data_dir/data下

完整路径

geoserver/data_dir/data/nyc_roads

新建工作区

点击工作区-添加新的工作区

然后配置工作区信息

注意:

工作区名称是描述项目的标识符。它不能超过10个字符或包含空格。名称空间URI(统一资源标识符)通常可以是与项目相关联的URL,其中添加了一个表示工作区的尾随标识符。归档的名称空间URI不需要解析为实际的有效web地址。

然后勾选上将其设置为默认工作区(可选),点击保存。

创建一个数据存储

点击数据存储-添加新的数据存储

然后选择矢量数据源下的第一个Directory of spatial files(shapefiles)

选择上面新建的工作区,以及选择shapefiles文件的目录

这里的目录就是上面放在data下的shape的目录。

注意这里只能选择到shp文件所在的目录,而后面shp文件的全名称需要在选择后手动添加上

比如这里选择完成之后的路径为

点击保存

发布图层

在新建图层页面,点击上面新建图层,然后点击添加图层的下拉框,选择上面新建的数据源,然后在下面会出现图层,点击后面的发布,会进入图层发布前的编辑

然后往下拉找打计算边界的两个地方

点击从数据中计算和Compute from natice  bounds

然后再点击上面的发布标签下

将这里的WMS Settings下的Default Style修改为Line,默认就是如此。

然后点击保存

图层预览

然后找到菜单中Layer Preview,找到上面刚保存的图层

点击后面的OpenLayers

然后就会在新标签页中显示地图的预览

其中地址栏中的

http://localhost:8000/geoserver/nyc/wms

就可以用来给前端OpenLayers的url进行使用

官方文档原文

以上所有发布shapefile的过程可参照官方文档

https://docs.geoserver.org/stable/en/user/gettingstarted/shapefile-quickstart/index.html

  • GeoServer 2.18.x User Manual »
  • Getting started »
  • Publishing a shapefile
  • modules
  • next|
  • previous|

Publishing a shapefile

This tutorial walks through the steps of publishing a Shapefile with GeoServer.

Note

This tutorial assumes that GeoServer is running at http://localhost:8080/geoserver.

Data preparation

First let’s gather that the data that we’ll be publishing.

  1. Download the file nyc_roads.zip. This archive contains a shapefile of roads from New York City that will be used during in this tutorial.

  2. Unzip the nyc_roads.zip into a new directory named nyc_roads. The archive contains the following four files:

    nyc_roads.shp
    nyc_roads.shx
    nyc_roads.dbf
    nyc_roads.prj
    
  3. Move the nyc_roads directory into <GEOSERVER_DATA_DIR>/data, where <GEOSERVER_DATA_DIR> is the root of the GeoServer data directory. If no changes have been made to the GeoServer file structure, the path is geoserver/data_dir/data/nyc_roads.

Creating a new workspace

The next step is to create a workspace for the shapefile. A workspace is a container used to group similar layers together.

Note

This step is optional if you’d like to use an existing workspace. Usually, a workspace is created for each project, which can include stores and layers that are related to each other.

  1. In a web browser, navigate to http://localhost:8080/geoserver.

  2. Log into GeoServer as described in the Logging In section.

  3. Navigate to Data ‣ Workspaces.

    Workspaces page

  4. Click the Add new workspace button.

  5. You will be prompted to enter a workspace Name and Namespace URI.

    Configure a new workspace

  6. Enter the Name as nyc and the Namespace URI as http://geoserver.org/nyc.

    Note

    A workspace name is a identifier describing your project. It must not exceed ten characters or contain spaces. A Namespace URI (Uniform Resource Identifier) can usually be a URL associated with your project with an added trailing identifier indicating the workspace. The Namespace URI filed does not need to resolve to an actual valid web address.

    nyc workspace

  7. Click the Submit button. The nyc workspace will be added to the Workspaces list.

Create a store

Once the workspace is created, we are ready to add a new store. The store tells GeoServer how to connect to the shapefile.

  1. Navigate to Data‣Stores.

  2. You should see a list of stores, including the type of store and the workspace that the store belongs to.

  3. In order to add the shapefile, you need to create a new store. Click the Add new Store button. You will be redirected to a list of the data sources supported by GeoServer. Note that the data sources are extensible, so your list may look slightly different.

    Stores

  4. Click Shapefile. The New Vector Data Source page will display.

  5. Begin by configuring the Basic Store Info.

    • Select the workspace nyc from the drop down menu.

    • Enter the Data Source Name as NYC Roads

    • Enter a brief Description (such as “Roads in New York City”).

  6. Under Connection Parameters, browse to the location URL of the shapefile, typically nyc_roads/nyc_roads.shp.

    Basic Store Info and Connection Parameters

  7. Click Save. You will be redirected to the New Layer page in order to configure the nyc_roads layer.

Creating a layer

Now that the store is loaded, we can publish the layer.

  1. On the New Layer page, click Publish beside the nyc_roads layer name.

    New layer

  2. The Edit Layer page defines the data and publishing parameters for a layer. Enter a short Title and an Abstract for the nyc_roads layer.

    Basic Resource Information

  3. Generate the layer’s bounding boxes by clicking the Compute from data and then Compute from native bounds links.

    Generating bounding boxes

  4. Click the Publishing tab at the top of the page.

  5. We can set the layer’s style here. Under WMS Settings, ensure that the Default Style is set to line.

    Select Default Style

  6. Finalize the layer configuration by scrolling to the bottom of the page and clicking Save.

Previewing the layer

In order to verify that the nyc_roads layer is published correctly, we can preview the layer.

  1. Navigate to the Layer Preview screen and find the nyc:nyc_roads layer.

    Layer Preview

  2. Click the OpenLayers link in the Common Formats column.

  3. An OpenLayers map will load in a new tab and display the shapefile data with the default line style. You can use this preview map to zoom and pan around the dataset, as well as display the attributes of features.

    Preview map of nyc_roads

GeoServer简介、下载、配置启动、发布shapefile全流程(图文实践)相关推荐

  1. Unity手机游戏开发:从搭建到发布上线全流程实战

    前言: 技术书籍是学习技术知识的重要资源之一.读技术书可以帮助我们学习新技能和知识,技术书籍提供了可靠的.全面的信息,帮助我们快速学习新技能和知识.同时技术书籍有助于保持你的竞争力,因为它们提供了最新 ...

  2. 鸿蒙系统新手教程,鸿蒙灭神决新手入门全流程图文攻略

    鸿蒙灭神决新手入门全流程图文攻略 2019-03-21 15:04:13来源:天天RPG编辑:野狐禅评论(0) 中后期 回归主题,如果还是打不过神器2,可以先到"中级挑战"这里完成 ...

  3. 鸿蒙新手教程,鸿蒙灭神决新手入门全流程图文攻略

    鸿蒙灭神决新手入门全流程图文攻略 2019-03-21 15:04:13来源:天天RPG编辑:野狐禅评论(0) <鸿蒙灭神决>是近日登陆平台的一张新图,这张图采用了修仙元素,很多小伙伴对这 ...

  4. Android-0.PMS简介及VirtualApp中安装App全流程

    文章目录 1.Package Manager简介 2.PackageInstaller简介 2.1 PackageInstaller初始化 2.2 PackageInstaller安装APK 3. P ...

  5. CentOS7 64位下载配置与安装教程(超详细图文教程)

    场景 CentOS官网: https://www.centos.org/download/ 但是目前官网最新版本是CentOS8,如果想要下载安装CenOS7的话可以在阿里镜像上下载 http://m ...

  6. VsCode安装和配置C++环境详细全流程

    目录 一.下载安装VsCode 1.下载VsCode 2.安装VsCode 3.下载安装中文插件(可选择性跳过) 二.MinGW编译器的下载和配置 1.下载MinGW 2.配置环境变量 3.检查环境变 ...

  7. java从github下载项目_在github下载的java项目通过idea打开(全流程图文,傻瓜式)

    今天从github把我以前写的一个小demo下载下来了,第一次下载项目,摸索了一个多小时,才运行起来. 下载有两种方法,通过git下载,或者直接压缩包下载,我选的时压缩包下载(因为还没学会git下载 ...

  8. kali(linux)配置apt国内源+全流程采坑

    使用了kali,kali内部安装软件的是apt,由于要修改apt的源文件,改成国内源的,我这边使用虚拟机,半天粘贴不进去,此处请参考我之前写的kali修改ssh权限,允许ssh登录,并启动ssh服务: ...

  9. flutter创建新项目或者接手老项目配置环境依赖等全流程

    1,下载android studio和flutter sdk(接收别人项目先看第9条,直接去官网下载正确的版本) 2,将android studio代理关闭: 打开as->File->Se ...

最新文章

  1. FineReport中如何用JavaScript自定义地图标签
  2. 疑问:关于Microsoft Office InfoPath 2003 Toolkit for Visual Studio 2005 Beta 2
  3. XML文件处理的思考
  4. ios 高德挪动地图获取经纬度_高德地图获取地理位置经纬度并将经维度转化为详细地址信息...
  5. crazy pony_My Little Pony的11个DevOps课程
  6. 利用jetson nano上自带的opencv实现多线程rtsp拉流、低延迟较稳定显示摄像头视频(c++)
  7. java反编译工具jd-gui-osx for mac M1芯片无法使用的两个问题场景
  8. Webx mvc 源码
  9. java 8 中文字体_jdk安装中文字体,解决Can't read the embedded font LNUHUF+SimSun
  10. opensips mysql_基于opensips mysql数据库用户管理
  11. flashcp: verification mismatch at 0x0
  12. pythonfor反向循环_python如何实现反向迭代
  13. php订单超过未支付,商城订单未支付30分钟自动取消
  14. 大学生活快要结束了,才想要珍惜~~~
  15. Moblin v2开发环境设置——创建一个新应用程序
  16. 【chrome】Chrome源码剖析、上--多线程模型、进程通信、进程模型
  17. Python列表(list)的添加元素方法 append、extend、insert-------(超级详细)
  18. 菜鸟学机器学习,Sklearn库主要模块功能简介
  19. SQL导入文本错误:大容量插入: 在数据文件中遇到意外的文件结尾 (EOF)。
  20. 廖雪峰Git简明教程整理

热门文章

  1. Just another board game 博弈-vector套vector
  2. 「后端小伙伴来学前端了」Vuex 基本使用及案例,快速上手,学会使用vuex
  3. bat脚本交互输入_测评 | 不使用powershell运行 PowerShell 脚本的工具汇总
  4. python中的用法_Python中使用@的理解
  5. ostream作为函数返回值_GO语言基础函数
  6. centos7下qt creator python配置
  7. thinkphp导入css失败,为什么用thinkphp总是提示css错误?
  8. apply_async进程不执行_c/c++面试精选题(八)简单回答,进程和线程关系及区别...
  9. android中获取mac地址8.0,关于Android8.0以下手机获取蓝牙Mac地址的问题和扫描周围的手机蓝牙问题 下篇...
  10. winform响应时间最长是多少分钟_了解这个,你的爬升勋章分分钟手到擒来!