101 lines
3.3 KiB
Markdown
101 lines
3.3 KiB
Markdown
|
---
|
|||
|
title: 发布shapefile文件
|
|||
|
date: 2020-02-25
|
|||
|
author: ac
|
|||
|
tags:
|
|||
|
- GeoServer
|
|||
|
- shapefile
|
|||
|
categories:
|
|||
|
- GIS
|
|||
|
---
|
|||
|
|
|||
|
## 发布shapefile文件
|
|||
|
|
|||
|
### 一、shapefile 文件
|
|||
|
|
|||
|
ESRI Shapefile(shp),或简称shapefile,是美国环境系统研究所公司(ESRI)开发的一种空间数据开放格式,用于描述几何体对象:点,折线与多边形,仅仅能够存储几何体的位置数据,没法存储地理数据的拓扑信息,也无法在一个文件之中同时存储这些几何体的属性数据。所以Shapefile还必须附带一个二维表用于存储Shapefile中每个几何体的属性信息。
|
|||
|
|
|||
|
Shapefile文件指的是一种文件存储的方法,实际上该种文件格式是由多个文件组成:
|
|||
|
|
|||
|
1. .shp文件:主文件,用于保存几何实体
|
|||
|
2. .shx文件:索引文件,保存每个记录包含对应主文件记录离主文件头开始的偏移
|
|||
|
3. .dbf文件(dBASE表):保存实体的属性信息
|
|||
|
4. .prj文件:用于保存地理坐标系统与投影信息,是一个存储well-known text投影描述符的文本文件。
|
|||
|
5. .shp.xml文件:以XML格式保存元数据。
|
|||
|
6. .cpg文件:用于描述.dbf文件的代码页,指明其使用的字符编码
|
|||
|
|
|||
|
> 一个Shapefile,".shp", ".shx"与 ".dbf"三个文件是必不可少的。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
|
|||
|
|
|||
|
### 二、发布shapefile文件
|
|||
|
|
|||
|
**数据准备**
|
|||
|
|
|||
|
将要发布服务的数据拷贝到`<<GEOSERVER_DATA_DIR>/data`下面,即数据目录中的data文件夹下。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
**创建新的工作区**
|
|||
|
|
|||
|
也可以选择已存在的工作区
|
|||
|
|
|||
|

|
|||
|
|
|||
|
> Name:工作空间名称,不得超过十个字符
|
|||
|
>
|
|||
|
> Namespace URI:命名空间URI通常可以是与项目关联的URL,并添加了指示空间的尾随标识符, 不需要解析实际有效的Web地址
|
|||
|
|
|||
|
|
|||
|
|
|||
|
**创建数据源**
|
|||
|
|
|||
|
数据存储/添加新的数据存储/Shapefile;
|
|||
|
|
|||
|
> 需要根据shapefile文件的cpg文件中指明的字符编码,设置字符集。
|
|||
|
|
|||
|

|
|||
|
|
|||
|
**发布图层**
|
|||
|
|
|||
|
在创建完数据存储后,会有一个创建图层界面,点击后出现编辑图层
|
|||
|
|
|||
|
- 编辑图层:“数据”tabs,填写基本信息、边框选择‘从数据中计算’
|
|||
|
|
|||
|
- "发布" 的tab页中设置WMS的Default Style为line,和显示样式,保存即发布成功
|
|||
|
|
|||
|

|
|||
|
|
|||
|
|
|||
|
|
|||
|

|
|||
|
|
|||
|
|
|||
|
|
|||
|

|
|||
|
|
|||
|
|
|||
|
|
|||
|
保存后就发布成功了,可以在图层预览中查看图层:
|
|||
|
|
|||
|

|
|||
|
|
|||
|

|
|||
|
|
|||
|
### 三、乱码问题
|
|||
|
|
|||
|
数据源中设置的dbf文件的字符集编码与实际不符,所以导致属性信息出现乱码
|
|||
|
|
|||
|
注意:shapefile文件的版本
|
|||
|
|
|||
|
- 在 ArcGIS 10.2.1 之前的版本,创建 shapefile 的时候,其编码类型是由操作系统的语言区域设置(language locale)决定的。
|
|||
|
- 而从 ArcGIS Desktop 10.2.1 版本以及之后的版本,产生的shapefile都是 UTF-8 编码的。
|
|||
|
- desktop能识别utf-8的shape文件,其它工具(如QGIS)默认是GBK编码所以会出现乱码的情况。
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|