简体   繁体   English

更改几何的SRID

[英]Change the SRID of a geometry

I would like to develop a python code that set the SRID(A Spatial Reference System Identifier (SRID) is a unique value used to unambiguously identify projected, unprojected, and local spatial coordinate system definitions. These coordinate systems form the heart of all GIS applications) of a geometry to a particular integer value, however i don't have a clue from where to start. 我想开发一个设置SRID的python代码(空间参考系统标识符(SRID)是一个唯一值,用于明确标识投影,未投影和局部空间坐标系定义。这些坐标系构成所有GIS应用程序的核心)的几何到一个特定的整数值,但是我不知道从哪里开始。

Any help will be very much appreciated. 任何帮助将不胜感激。

To implement such a function that mimics ST_SetSRID outside of PostGIS, you need to decide on the format you're willing to operate in. 要实现模仿PostGIS外部的ST_SetSRID的功能,您需要确定愿意使用的格式。

If you're looking at geometry in EWKT (Extended Well-Known Text), then SRID is stored in the beginning: 如果要查看EWKT(扩展的知名文本)中的几何图形,则SRID将存储在开头:

SRID=4326;POINT(10.23 10.41)

There it can be replaced using text manipulation functions. 可以使用文本操作功能替换它。

If you are looking at geom in EWKB (Extended Well-Known Binary), then SRID is stored as an integer after a header, if a header has a flag that it stores a SRID raised. 如果您正在查看EWKB(扩展的知名二进制文件)中的geom,则SRID将存储为标头后的整数,如果标头具有标记,则该标志存储了引发的SRID。

Here is how postgis stores a flag: https://sourcegraph.com/github.com/postgis/postgis/-/blob/liblwgeom/lwout_wkb.c#L145 这是postgis存储标志的方式: https ://sourcegraph.com/github.com/postgis/postgis/-/blob/liblwgeom/lwout_wkb.c#L145

Here is how it writes the SRID value: https://sourcegraph.com/github.com/postgis/postgis/-/blob/liblwgeom/lwout_wkb.c#L583 这是它写SRID值的方式: https : //sourcegraph.com/github.com/postgis/postgis/-/blob/liblwgeom/lwout_wkb.c#L583

If you are implementing it in Python, you may want to use something like WKBheader library to not manipulate the fields youself: https://github.com/MazeMap/wkbheader 如果要在Python中实现它,则可能要使用WKBheader库之类的东西来不操纵自己的字段: https : //github.com/MazeMap/wkbheader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM