PostGIS

Obtain double precision values from inconsitent strings for using ST_GeomFromText (PostGIS)

依然范特西╮ 提交于 2019-12-13 04:45:34
问题 I have a PostgreSQL table with a column containing strings in the following format: '3.985 58.934, 4.56 61.2323, 5.4 63.234355, 3.25982 59.309' '3.985 58.934, 4.56 61.2323, 5.4 63.234355, 3.25982 59.309, 4.5632 58.32423' 'and so on...' As you can see the column contains coordinates in different lengths as strings in one line. I would like to use the PostGIS function: ST_GeomFromText('LINESTRING(3.985 58.934, 4.56 61.2323, 5.4 63.234355, 3.25982 59.309)', 4326) The following questions now

2D Open Street Map Data Representation in Meters

我与影子孤独终老i 提交于 2019-12-13 04:24:19
问题 I am in the process of converting OSM data into an open source Minecraft port (written in javascript - voxel.js). The javascript rendition is written such that each voxel (arbitrarily defined as a cubic meter) is created as a relation from a single point of origin (x,y,z)(0,0,0). As an example, if one wanted to create a cubic chunk of voxels, one would simply generate voxels as a relation to the origin (0,0,0) : [(0,0,0),(1,0,0), (0,1,0)...]. My question is this: I've exported OSM data, and

To update several non dupliated rows at one time using “Group by”

别来无恙 提交于 2019-12-13 04:19:50
问题 I followed the help from Generate a random number of non duplicated random number in [0, 1001] through a loop . But I can't apply that to my case. When I do: update weighed_directed_edge set endpoint= trunc(1000 * random()+ 1) from generate_series(1,10) group by 1 where startpoint= from_point; to update endpointId it complains: ERROR: syntax error at or near "group" LINE 1: ...nc(1000 * random()+ 1) from generate_series(1,10) group by 1. I also tried: insert into weighed_directed_edge

Get random point from django PolygonField

佐手、 提交于 2019-12-13 04:18:55
问题 TL,DR ; I want to get a random point from a polygon (potentially) using ST_GeneratePoints. Background I'm making a GeoDjango web service and have a collection of UK Postcodes with respective boundaries like so: from django.db import models as dj_models from django.contrib.gis.db import models as gis_models class Postcode(gis_models.Model): pretty_postcode = dj_models.CharField( max_length=8 ) coords = gis_models.PolygonField( default='POLYGON EMPTY' ) I've found a delightful little PostGIS

PosGis and Django-Tenants

余生长醉 提交于 2019-12-13 03:47:44
问题 (Using the library django-tenants for tenant separated multi-tenancy) For PostGis support the docs say to add ORIGINAL_BACKEND = "django.contrib.gis.db.backends.postgis" . I have this, however, when I go to create a new tenant I get the following error: Traceback (most recent call last): File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\celery\app\trace.py", line 382, in trace_task R = retval = fun(*args, **kwargs) File "c:\users\cole\appdata\local\programs

Retrieve closest road when given (lat, long) using OSM in Postgres with Postgis using SQL query

偶尔善良 提交于 2019-12-13 03:14:30
问题 Given a set (lat, long) I am trying to find the maximum speed using "max_speed" and street type using "highway". I have loaded my database (Postgres and Postgis) as follows: $ osm2pgsql -c -d gis --slim -C 50000 /var/lib/postgresql/data/germany-latest.osm.pbf The closest related question I could find was How to query all shops around a certain longitude/latitude using osm-postgis?. I have taken the query, and plugged in a (lat, long) that I found in google maps for the city center of Munich

How can I prevent CakePHP from escaping data on a save?

余生颓废 提交于 2019-12-13 02:35:17
问题 I am doing some PostGIS work on a CakePHP application. Because I've been working with some database functions, I've done raw $this->query() calls to do inserts of data. I'm at a point where I need to get the ID of the result of an insert query, but $this->query() returns an empty array. Here is the query I'm using for inserts: INSERT INTO locations (title,company_id,state_id,poly,point) VALUES ('$title',$company_id,$state_id,ST_GeomFromText('$geom',4269),$point); The problem is Cake is trying

How to select inside a FOR-Loop for further computations?

落爺英雄遲暮 提交于 2019-12-13 02:35:01
问题 Working with postgresql and postgis I have 2 openstreetmap tables, containing: Point: Locations with a single coordinate Polygon: Areas with sets of coordinates Now, I'm trying to loop through the Point table and for each record I'm trying to do some computations with postgis functions, e.g. ST_Intersects() . Then trying to insert the results into another tables. So far I've only done simple SELECT queries with postgis functions, they basically work like this: SELECT a.name, b.name FROM table

Count number of points within certain distance ranges from another set of points

假装没事ソ 提交于 2019-12-13 01:35:20
问题 I have the following, which gives me the number of customers within 10,000 meters of any store location: SELECT COUNT(*) as customer_count FROM customer_table c WHERE EXISTS( SELECT 1 FROM locations_table s WHERE ST_Distance_Sphere(s.the_geom, c.the_geom) < 10000 ) What I need is for this query to return not only the number of customers within 10,000 meters, but also the following. The number of customers within... 10,000 meters more than 10,000, but less than 50,000 more than 50,000, but

How to convert HEXEWKB to Latitude, Longitude (in java)?

谁说我不能喝 提交于 2019-12-13 01:30:09
问题 I downloaded Street information from the Open Street Map project. This file is basically a CSV with the following fields: CSV fields ============================================== 1 : id; UniqueId of the street(always null for the moment) 2 : name; The name 3 : location; The middle point of the street in HEXEWKB 4 : length ; Length of the street in meters 5 : countrycode; The iso3166 Alpha2 Code of the country 6 : gid ; GlobalId (not use yet) 7 : type; The type of street (see bellow) 8 :