PostGIS

GIS基础知识

偶尔善良 提交于 2020-08-11 08:59:28
最近接手一个GIS项目,需要用到 PostGIS,GeoServer,OpenLayers 等工具组件,遇到一堆地理信息相关的术语名词,在这里做一个总结。 1. 大地测量学 (Geodesy) 大地测量学 是一门量测和描绘地球表面的学科,也包括确定地球重力场和海底地形。 1.1 大地水准面 (geoid) 大地水准面 是 海洋表面 在排除风力、潮汐等其它影响,只考虑重力和自转影响下的形状,这个形状延伸过陆地,生成一个密闭的曲面。虽然我们通常说地球是一个球体或者椭球体,但是由于地球引力分布不均(因为密度不同等原因),大地水准面是一个不规则的光滑曲面。虽然不规则,但是可以近似地表示为一个椭球体,这个椭球体被 称为 参考椭球体(Reference ellipsoid) 。大地水准面相对于参考椭球体的高度被称为 Undulation of the geoid 。这个波动并不是非常大,最高在冰岛为85m,最低在印度南部为 −106 m,一共不到200m。下图来自 维基百科 ,表示 EGM96 geoid 下不同地区的 Undulation。 1.2 参考椭球体(Reference ellipsoid) 参考椭球体(Reference ellipsoid) 是一个数学上定义的地球表面,它近似于大地水准面。因为是几何模型,可以用长半轴、短半轴和扁率来确定。我们通常所说的经度

How to get lng lat value from query results of geoalchemy2

落花浮王杯 提交于 2020-08-02 06:11:10
问题 For exammple, class Lake(Base): __tablename__ = 'lake' id = Column(Integer, primary_key=True) name = Column(String) geom = Column(Geometry('POLYGON')) point = Column(Geometry('Point')) lake = Lake(name='Orta', geom='POLYGON((3 0,6 0,6 3,3 3,3 0))', point="POINT(2 9)") query = session.query(Lake).filter(Lake.geom.ST_Contains('POINT(4 1)')) for lake in query: print lake.point it returned <WKBElement at 0x2720ed0; '010100000000000000000000400000000000002240'> I also tried to do lake.point.ST_X()

Postgis 地理函数使用

你。 提交于 2020-07-27 15:07:51
最近使用postgis的地理函数做一些区域查询判断,SQL代码如下: <sql id="region_condition_geo"> <if test="geog != null"> <if test="geog.type == 'circle' "> AND ST_Intersects ( ST_Buffer (ST_GeomFromText ('POINT(${geog.centerString})', ${geog.srid}) :: geography, ${geog.radiusMetre} ) :: geography, position ) </if> <if test="geog.type == 'rectangle' "> and ST_Intersects(ST_GeomFromText('POLYGON((${geog.pointArr}))', ${geog.srid})::geography, position ) </if> <if test="geog.type == 'polygon' "> and ST_Intersects(ST_GeomFromText('POLYGON((${geog.pointArr}))', ${geog.srid})::geography, position ) </if> </if> </sql> 执行时报错: bad

psycopg2 not detected by postgres django

限于喜欢 提交于 2020-07-10 10:32:45
问题 I am using PyCharm on Windows 10 and using Python 3.8 - 64 bit and Django 2.2. pip install psycopg2 successfully installed psycopg2-2.8.5. My database settings are as follows: settings.py, DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'my-database', 'USER': 'my-user', 'PASSWORD': 'my-password', 'HOST': 'localhost', 'PORT': '', } } my-user is the user that I am using and my-password is my password. However, python manage.py makemigrations causes a few

PostgreSQL: show trips within a bounding box

邮差的信 提交于 2020-07-10 10:24:29
问题 I have a trips table containing user's trip information, like so: select * from trips limit 10; trip_id | daily_user_id | session_ids | seconds_start | lat_start | lon_start | seconds_end | lat_end | lon_end | distance ---------+---------------+-------------+---------------+------------+------------+-------------+------------+------------+------------------ 594221 | 16772 | {170487} | 1561324555 | 41.1175475 | -8.6298934 | 1561325119 | 41.1554091 | -8.6283493 | 5875.39697884959 563097 | 7682

How to configure PostgreSQL with Postgis to calculate distances

时间秒杀一切 提交于 2020-07-10 01:56:34
问题 I know that it might be dumb question, but I'm searching for some time and can't find proper answer. I have PostgreSQL database with PostGIS installed. In one table I have entries with lon lat (let's assume that columns are place, lon, lat). What should I add to this table or/and what procedure I can use, to be able to count distance between those places in meters. I've read that it is necessary to know SRID of a place to be able to count distance. Is it possible to not know/use it and still

java.io.StreamCorruptedException: invalid stream header: 30313031 [duplicate]

江枫思渺然 提交于 2020-07-06 20:04:08
问题 This question already has answers here : java.io.StreamCorruptedException: invalid stream header: 54657374 (2 answers) Closed 14 days ago . This relates to Hibernate: Could not deserialize - invalid stream header. I could not make real use of the answers so I am creating this again (and maybe things have changed a bit). I am building a SpringBoot application and here are the libraries I use. org.springframework.boot:1.5.4.RELEASE hibernate-core:5.0.12 hibernate-spatial hibernate-jpa-2.1-api:1

java.io.StreamCorruptedException: invalid stream header: 30313031 [duplicate]

耗尽温柔 提交于 2020-07-06 20:00:06
问题 This question already has answers here : java.io.StreamCorruptedException: invalid stream header: 54657374 (2 answers) Closed 14 days ago . This relates to Hibernate: Could not deserialize - invalid stream header. I could not make real use of the answers so I am creating this again (and maybe things have changed a bit). I am building a SpringBoot application and here are the libraries I use. org.springframework.boot:1.5.4.RELEASE hibernate-core:5.0.12 hibernate-spatial hibernate-jpa-2.1-api:1

Running PostGIS with Django on Heroku

谁都会走 提交于 2020-06-27 15:11:49
问题 Trying to run a GeoDjango app on Heroku and it's being a really piece of work. After struggling through a variety of problems, I've come to one I can't seem to hack my way out of. File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 673, in db_parameters type_string = self.db_type(connection) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 105, in db_type return connection.ops.geo_db_type(self)

Running PostGIS with Django on Heroku

末鹿安然 提交于 2020-06-27 15:11:29
问题 Trying to run a GeoDjango app on Heroku and it's being a really piece of work. After struggling through a variety of problems, I've come to one I can't seem to hack my way out of. File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 673, in db_parameters type_string = self.db_type(connection) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 105, in db_type return connection.ops.geo_db_type(self)