PostGIS

Having a generic GEOGRAPHY column with PostGIS

时光毁灭记忆、已成空白 提交于 2019-12-23 13:06:18
问题 In PostgreSQL 9 + PostGIS 1.5, is there a way to create a "generic" GEOGRAPHY column? By that I mean a column that would accept POINTs as well as POLYGONs, LINESTRINGs, etc. Until now, I've only seen columns like GEOGRAPHY(POINT,4326) on the Internet. If that is not possible, then how would you design (from a DB point of view) an entity that is linked to a random geographical object (point, polygon, whatever)? Should I create 3, 4, 5 different tables for each type of geographical object I'd

How to convert from PostgreSQL to GeoJSON format?

怎甘沉沦 提交于 2019-12-23 10:07:39
问题 I have a simple table called"imposm3_restaurant" with columns [ id, name, geometry] I want to convert these data into geoJSON, I am using this function CREATE VIEW imposm3_restaurants_geojson AS SELECT row_to_json(fc) AS geojson FROM (SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM (SELECT 'Feature' As type, ST_AsGeoJSON((lg.geometry),15,0)::json As geometry, row_to_json((id, name)) As properties FROM imposm3_restaurants As lg) As f ) As fc; and the result is

Need SQL optimization (maybe DISTINCT ON is the reason?)

主宰稳场 提交于 2019-12-23 09:57:32
问题 Related, preceding question: Select a random entry from a group after grouping by a value (not column)? My current query looks like this: WITH points AS ( SELECT unnest(array_of_points) AS p ), gtps AS ( SELECT DISTINCT ON(points.p) points.p, m.groundtruth FROM measurement m, points WHERE st_distance(m.groundtruth, points.p) < distance ORDER BY points.p, RANDOM() ) SELECT DISTINCT ON(gtps.p, gtps.groundtruth, m.anchor_id) m.id, m.anchor_id, gtps.groundtruth, gtps.p FROM measurement m, gtps

Hibernate Spatial - 'Invalid endian flag value encountered' Exception

﹥>﹥吖頭↗ 提交于 2019-12-23 08:36:40
问题 I'm trying to run a simple query in Hibernate Spatial 4.0 on PostgreSQL 9.3. I have a number of objects in a table with latitude/longitude values, and I'm trying to query objects that fall within a given radius of a particular latitude/longitude. The geometry values seem to be persisted without any problem, and are defined like this in my entity class: @Column(columnDefinition = "Geometry", nullable = true) @Type(type = "org.hibernate.spatial.GeometryType") private Point coordinates = null; I

PostGIS Homebrew installation referencing an old path?

元气小坏坏 提交于 2019-12-23 08:29:20
问题 I upgraded and subsequently reinstalled PostGIS & PostgreSQL on OS X Mountain Lion. When trying to use the PostGIS extensions, I receive the following error: ERROR: could not open extension control file "/usr/local/Cellar/postgresql/ 9.2.3/share/postgresql/extension/postgis.control": No such file or directory It appears that PostGIS (and PostgreSQL as well??) are still looking for the required files in the /postgresql/9.2.3/ directory and not in the /postgresql/9.2.4/ directory. I have used

How to calculate the Azimuth between two points in PostGIS?

£可爱£侵袭症+ 提交于 2019-12-23 05:17:37
问题 I have a GIS API based on OpenLayers. I have been trying to implement Azimuth calculation in JavaScript and I needed some way to calculate the Azimuth in order to perform tests. I started using PostGIS, but there seem to be many ways to calculate the Azimuth between two points. I show you three of them and, some return different results. -- Example 1 - Result 90 SELECT ST_Azimuth( ST_Transform(st_geomfromtext('POINT(-81328.998084106 7474929.8690234)', 900913), 4326), ST_Transform(st

Displaying PostGIS Data with Leafletjs

浪尽此生 提交于 2019-12-23 03:13:22
问题 I'm learning GIS with PostGIS and I wanted to try something funny so I downloaded shape files from OSM, imported in PostGres with PostGIS extension and now I want to represent data from PostGIS visually. I have Pulled data with Query SELECT ST_AsGeoJSON(geom) FROM "dar-es-salaam_tanzania.land_coast; I got bunch of GeoJSON and wanted to show them to user. Unfortunately it does not show it. I use Yii2 to write codes that pulls the data. Here is the controller code: public function actionIndex()

Add new column attribute to the shapefile and save it to database using Geotools Java

≯℡__Kan透↙ 提交于 2019-12-23 01:29:11
问题 I am transforming a shapefile by adding a new column attributes. Since this task is performed using Java, the only option I know for now is using Geotools. I have 2 main concerns: 1. I am not able to figure out how do I actually add a new column variable. Is the feature.setAttribute("col","value") the answer? I see from this post just the example:https://gis.stackexchange.com/questions/215660/modifying-feature-attributes-of-a-shapefile-in-geotools but I dont get the solution. //Upload the

Add new column attribute to the shapefile and save it to database using Geotools Java

╄→гoц情女王★ 提交于 2019-12-23 01:29:09
问题 I am transforming a shapefile by adding a new column attributes. Since this task is performed using Java, the only option I know for now is using Geotools. I have 2 main concerns: 1. I am not able to figure out how do I actually add a new column variable. Is the feature.setAttribute("col","value") the answer? I see from this post just the example:https://gis.stackexchange.com/questions/215660/modifying-feature-attributes-of-a-shapefile-in-geotools but I dont get the solution. //Upload the

How can I make this geo-distance SQL query Postgres compatible

江枫思渺然 提交于 2019-12-22 23:21:24
问题 A library I’m trying to use takes a given latitude and longitude and work out with entries in a table have a lat/lng within a certain distance from this. The generated SQL query works with MySQL, but not with PostgreSQL. Here’s the entry in my server.log file detailing the error psql is giving and the full query: ERROR: column "distance" does not exist at character 507 STATEMENT: select *, ( '3959' * acos( cos( radians('53.49') ) * cos( radians( places.lat ) ) * cos( radians( places.lng ) -