Table of Contents
题记
系统需求
关键词
怎么使用
操作步骤
创建表
使用ArcSDE命令进行注册
插入数据
使用空间关系操作
查询几何图形实例的属性和行为
点数
维度
闭合
空间引用标识符 (SRID)
两种数据类型之间的差别
构造几何图形实例
Home Database Mysql Tutorial ArcSDE for SQLServer的SQL操作

ArcSDE for SQLServer的SQL操作

Jun 07, 2016 pm 03:20 PM
for sql sqlserver operate

题记 大家对Oracle数据库的SQL操作应该不陌生吧,也就是出于所谓的效率而言,使用SQL语句对ArcGIS对象(要素类)进行直接的读操作或写操作,目前来说在电信行业运用较广泛,这方面的知识我就不再赘述。那么可能会有人问,那么在SQL Server数据库是否可以使用

题记

大家对Oracle数据库的SQL操作应该不陌生吧,也就是出于所谓的效率而言,使用SQL语句对ArcGIS对象(要素类)进行直接的读操作或写操作,目前来说在电信行业运用较广泛,这方面的知识我就不再赘述。那么可能会有人问,那么在SQL Server数据库是否可以使用SQL语句直接操作ArcSDE的对象呢?以前不可以,但是现在可以了。

系统需求

为什么说上面故意卖个关子呢,也就是需要强调一下系统需求的重要性。也就是说从SQL Server 2008版本后,才可以的。自从2008版本之后,MS提供了为空间数据专有的也就是MS自己的存储:Geometry和Geogrphy。

关键词

ArcSDE 地理数据库支持使用 Microsoft 的几何类型和地理类型存储矢量数据。SQL Server 2008 中提供这些类型,因此无需单独安装即可使用。这个与比较繁杂的Oracle的SQL操作引用St_shapelib.dll来说就显得非常方便了。

Microsoft 几何类型(Geometry)与现有 GIS 空间数据类型相似:使用任意平面(如已定义的投影)内的坐标。

Microsoft 地理类型(Geometry)用于旋转椭球体上的数据,该数据与纬度和经度坐标一同存储。

geometry 和 geography 数据类型支持十一种空间数据对象或实例类型。但是,这些实例类型中只有七种“可实例化”;可以在数据库中创建并使用这些实例(或可对其进行实例化)。这些实例的某些属性由其父级数据类型派生而来,使其在 GeometryCollection 中区分为 Points、 LineStrings、Polygons 或多个 geometry 或 geography 实例。

ArcSDE for SQLServer的SQL操作

如图所示,geometry 和 geography 数据类型的七种可实例化类型为 Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon 和GeometryCollection。只要特定实例的格式正确,即使未显式定义该实例,geometry 和 geography 类型也可识别该实例。例如,如果您使用STPointFromText() 方法显式定义了一个 Point 实例,只要方法输入的格式正确,geometry 和 geography 便将该实例识别为 Point。如果您使用STGeomFromText() 方法定义了相同的实例,则 geometry 和 geography 数据类型都将该实例识别为 Point。

怎么使用

默认情况下,SQL Server 中的 ArcSDE 地理数据库使用 ArcSDE 压缩二进制类型,因此如果您要使用 Microsoft 几何或地理类型进行存储,必须

(1) 将 SDE_dbtune 表中 DEFAULTS 配置关键字下的 GEOMETRY_STORAGE 参数更改为 GEOMETRY 或 GEOGRAPHY

(2) 指定可在创建要素类时指定 GEOMETRY 或 GEOGRAPHY 的 GEOMETRY_STORAGE 参数的配置关键字。

如果多数用户在多数时候都使用几何或地理类型存储数据,则只应更改 DEFAULTS 关键字下的 GEOMETRY_STORAGE 参数。如果只有部分数据将以几何或地理类型进行存储,则应在创建要素类时指定一个单独的关键字。为您提供了两个关键字:GEOMETRY 和 GEOGRAPHY,也可以创建自己的自定义关键字。

用户在创建要素类或者导入要素类的过程中可以选择以上关键字,那么这些数据就已MS的几何或者地理类型进程存储了,那么用户也就可以使用SQL对数据进行操作了。

操作步骤

因为Geometry和Geogrphy基本类似,那么本文就已Geometry存储来演示一下怎么在ArcSDE的SQL Server使用SQL对空间数据进行操作

创建表

 

使用ArcSDE命令进行注册

 

插入数据

 

ArcSDE for SQLServer的SQL操作

使用空间关系操作

 

ArcSDE for SQLServer的SQL操作

微软为我们提供了丰富的空间关系操作符

 


大家可能都知道Oracle的一些关系操作符,有些走空间索引,有些不走空间索引,那么我们在使用这些关系操作符时一定要使用走空间索引的,那么对SQLServer来说也是一样的。

在特定条件下,空间索引支持以下面向集合的几何图形方法:STContains()、STDistance()、STEquals()、STIntersects()、STOverlaps()、STTouches() 和 STWithin()。若要使空间索引支持这些方法,必须在查询的 WHERE 或 JOIN ON 子句中使用这些方法,并且必须在采用如下常规形式的谓词中执行这些方法:

 

若要返回非 NULL 结果,geometry1 和 geometry2 必须具有相同的空间引用标识符 (SRID)。否则,该方法将返回 NULL。


查询几何图形实例的属性和行为

点数

所有非空 geometry 实例都由“点”组成。这些点表示在其上绘制几何图形的面的 X 和 Y 坐标。geometry 提供许多用于查询实例的点的内置方法。

 

维度

非空 geometry 实例可以为零维、一维或二维。零维 geometries(例如 Point 和 MultiPoint)没有长度或面积。一维对象(例如 LineString 和 MultiLineString)具有长度。二维实例(例如 Polygon 和 MultiPolygon)具有面积和长度。空实例将报告为 -1 维,并且GeometryCollection 将根据其内容类型报告一个面积。

 

闭合

“闭合的”geometry 实例是指起始点和终点相同的图形。Polygon 实例是闭合的。Point 实例不是闭合的。

环是一个简单、闭合的 LineString 实例。

 

空间引用标识符 (SRID)

空间引用标识符 (SRID) 是指定 geometry 实例所在的坐标系的标识符。两个拥有不同 SRID 的实例是不可比的。

 

此属性可以进行修改。

更多详见:http://msdn.microsoft.com/zh-cn/library/bb964708.aspx

两种数据类型之间的差别

两种空间数据类型的行为经常非常相似,但在数据存储方式和操作方式上存在某些重要的差别。

http://msdn.microsoft.com/zh-cn/library/bb964711.aspx

构造几何图形实例

http://msdn.microsoft.com/zh-cn/library/bb895335.aspx

 

-------------------------------------------------------------------------------------------------------

QQ一群:              78773981

QQ二群:            225989940

Blog:               http://blog.csdn.net/linghe301
Weibo:            http://www.weibo.com/linghe301
-------------------------------------------------------------------------------------------------------
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem that the object named already exists in the sqlserver database How to solve the problem that the object named already exists in the sqlserver database Apr 05, 2024 pm 09:42 PM

For objects with the same name that already exist in the SQL Server database, the following steps need to be taken: Confirm the object type (table, view, stored procedure). IF NOT EXISTS can be used to skip creation if the object is empty. If the object has data, use a different name or modify the structure. Use DROP to delete existing objects (use caution, backup recommended). Check for schema changes to make sure there are no references to deleted or renamed objects.

How to import mdf file into sqlserver How to import mdf file into sqlserver Apr 08, 2024 am 11:41 AM

The import steps are as follows: Copy the MDF file to SQL Server's data directory (usually C:\Program Files\Microsoft SQL Server\MSSQL\DATA). In SQL Server Management Studio (SSMS), open the database and select Attach. Click the Add button and select the MDF file. Confirm the database name and click the OK button.

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

What to do if the sqlserver service cannot be started What to do if the sqlserver service cannot be started Apr 05, 2024 pm 10:00 PM

When the SQL Server service fails to start, here are some steps to resolve: Check the error log to determine the root cause. Make sure the service account has permission to start the service. Check whether dependency services are running. Disable antivirus software. Repair SQL Server installation. If the repair does not work, reinstall SQL Server.

How to check sqlserver port number How to check sqlserver port number Apr 05, 2024 pm 09:57 PM

To view the SQL Server port number: Open SSMS and connect to the server. Find the server name in Object Explorer, right-click it and select Properties. In the Connection tab, view the TCP Port field.

How to recover accidentally deleted database in sqlserver How to recover accidentally deleted database in sqlserver Apr 05, 2024 pm 10:39 PM

If you accidentally delete a SQL Server database, you can take the following steps to recover: stop database activity; back up log files; check database logs; recovery options: restore from backup; restore from transaction log; use DBCC CHECKDB; use third-party tools. Please back up your database regularly and enable transaction logging to prevent data loss.

Where is the sqlserver database? Where is the sqlserver database? Apr 05, 2024 pm 08:21 PM

SQL Server database files are usually stored in the following default location: Windows: C:\Program Files\Microsoft SQL Server\MSSQL\DATALinux: /var/opt/mssql/data The database file location can be customized by modifying the database file path setting.

How to delete sqlserver if the installation fails? How to delete sqlserver if the installation fails? Apr 05, 2024 pm 11:27 PM

If the SQL Server installation fails, you can clean it up by following these steps: Uninstall SQL Server Delete registry keys Delete files and folders Restart the computer

See all articles