PostGIS

Postgres create POSTGIS extension error with CentOS 6

天涯浪子 提交于 2019-12-24 14:26:32
问题 I am running PostgreSQL 9.3 with Postgis 2.0 on CentOS 6.3 . I installed PostgreSQL and PostGIS according to this instructions: http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21CentOS6pgdg When trying to create Postgis extension Create Extension Postgis; I get the following error, ERROR: could not load library "/usr/pgsql-9.3/lib/rtpostgis-2.1.so": libhdf5.so.6: cannot open shared object file: No such file or directory May I know how to install the POSTGIS extension successfully? 回答1: I

postgresql equivalent to $mysqli->insert_id

跟風遠走 提交于 2019-12-24 14:19:16
问题 Is there an equivalent to $mysqli->insert_id in postgresql 9.3? I am importing into one table, but I need to take the last primary key created in the table and apply it as a foreign key in the second table? Table 1 ----> Table 2 to complete a record. A bit more info: $sql = "INSERT INTO sheet_tbl (site_id, eventdate) VALUES ('$_POST[site_id]','$_POST[eventdate]') returning id"; **Using the sql above, i insert my record, how would I then utilise this in my next SQL insert, If i use returning

Best way to prevent duplicate data on copy csv postgresql

為{幸葍}努か 提交于 2019-12-24 11:34:08
问题 This is more of a conceptual question because I'm planning how best to achieve our goals here. I have a postgresql/postgis table with 5 columns. I'll be inserting/appending data into the database from a csv file every 10 minutes or so via the copy command. There will likely be some duplicate rows of data, so I'd like to copy the data from the csv file to the postgresql table but prevent any duplicate entries from getting into the table from the csv file. There are three columns, where if they

PostGIS equivalent of ArcMap Union

依然范特西╮ 提交于 2019-12-24 10:37:46
问题 What is the equivalent in PostGIS / PostgreSQL of the "Union" operation in ArcMap? Say you have two shapefiles with two features each. (PostGIS equivalent: two tables with two rows with polygon geometries) then the result would be 1 shapefile with 7 features. (PostGIS equivalent: Table with 7 rows with geometries) I've looked at ST_Intersect, ST_Union and ST_Collect but can't find the right combination. Your help is much appreciated. 回答1: Here is a working query based on this answer from gis

postgres: client could not connect to server

此生再无相见时 提交于 2019-12-24 08:56:46
问题 For clarification, please note that I have found several similar questions on stackoverflow, but I could not fix my issue. psql: could not connect to server: Connection refused” Error when connecting to remote database psql: How to Allow Remote Access to PostgreSQL database I am trying to connect to a postgres DB installed in a remote server. To create a connection from the client I am using QGIS plugin (Add PostGIS Layer): The error that occurs is: could not connect to server: Connection

PostgreSQL group by season (northern and southern hemisphere)

北慕城南 提交于 2019-12-24 03:48:10
问题 I have data points distributed over the whole globe. Every data point has a timestamp. I want to group the data by the seasons, as shown in this picture (source: https://en.wikipedia.org/wiki/Season#/media/File:Seasons1.svg). This is what I tried so far (winter 2011/2012 in the northern hemisphere): SELECT * FROM my_table WHERE my_date BETWEEN '2011-12-21' AND '2012-03-21' AND ST_Y(ST_Centroid(geom)) > 0; How can I do this for all possible years? I tried ...OR date BETWEEN... but this is very

Geodjango distance query not retrieving correct results

岁酱吖の 提交于 2019-12-24 03:12:44
问题 I am trying to retrieve some posts depending on their proximity geographically. As you can see in the code I am using GeoDjango and the code is executed within a view. The issue is that the distance filter seems to be completely disregarded. When I check the distances on the queryset I get the expected distances (1m and 18km) but the 18km post should not have been retrieved. def get(self, request, format=None): latlon=request.query_params pnt = GEOSGeometry('SRID=28992;POINT(%s %s)'%(latlon[

postgresql trigger with dblink doesn't return anything

◇◆丶佛笑我妖孽 提交于 2019-12-24 01:54:06
问题 I created a trigger to replicate inserts from a table 'mytable_db1' in database1 into the same table 'mytable_db2' on database2. Both databases are on the same server. CREATE OR REPLACE FUNCTION trigger_osm_test_insert() RETURNS trigger AS $BODY$ BEGIN PERFORM dblink_connect('db2', 'dbname=xxx port=5432 user=myusr password=xxx'); PERFORM dblink_exec('db2', 'insert into test.mytable_db2 (osm_id, name, name_eng, name_int, type, z_order, population, last_update, country, iso3, shape) values ('|

Most efficient way to find points within a certain radius from a given point

元气小坏坏 提交于 2019-12-24 01:18:42
问题 I've read several questions + answers here on SO about this theme, but I can't understand which is the common way (if there is one...) to find all the points whithin a "circle" having a certain radius, centered on a given point. In particular I found two ways that seem the most convincing: select id, point from my_table where st_Distance(point, st_PointFromText('POINT(-116.768347 33.911404)', 4326)) < 10000; and: select id, point from my_table where st_Within(point, st_Buffer(st_PointFromText

Npgsql parameterized query output incompatible with PostGIS

只谈情不闲聊 提交于 2019-12-23 14:21:44
问题 I have this parameterized query in an Npgsqlcommand: UPDATE raw.geocoding SET the_geom = ST_Transform(ST_GeomFromText('POINT(:longitude :latitude)', 4326),3081) WHERE id=:id :longutide and :latitude are double , and id is int . The query that is actually run against the DB looks like this: UPDATE raw.geocoding SET the_geom = ST_Transform(ST_GeomFromText('POINT(((E'-96.6864379495382')::float8) ((E'32.792527154088')::float8))', 4326),3081) WHERE id=((10793455)::int4) Thanks to help from Erwin