postgis

How to efficiently query large multi-polygons with PostGIS

I am working with radio maps that seem to be too fragmented to query efficiently. The response time is 20-40 seconds when I ask if a single point is within the multipolygon (I have tested "within"/"contains"/"overlaps"). I use PostGIS, with GeoDjango to abstract the queries. The multi-polygon column has a GiST index, and I have tried VA...

how do i remove overlapping lines in postgis

I have a typical database with millions of polygons as land parcels and i want to split these polygons onto lines and then remove the lines that overlap eachother. These lines will be used purely for rendering in mapnik/and or geoserver as at the moment every parcel boundary gets rendered twice. i propose to split the parcel polygons i...

Permissions required to allow arbitrary sql to be executed safely

I want to create an SQL sandbox that will allow users to execute arbitrary SELECT queries at a PostGIS database. Essentially, I want to allow users access to psql to play with. Obviously this is a security disaster if write access is allowed. How can I create a system such that querying data is allowed, but there is no reasonable poss...

How to import Lat/Long data into PostgreSQL

Hello all, PostgreSQL / Django / newbie here. I've got a bunch of JSON data with venues and lat/long information, and I'm looking to import it into my database. So far I've fenagled a script to format my JSON into SQL statements, so I can import them with a slew of INSERT statements. But my 'location' field (a PointField) is giving me...

How do I supply a British National Grid reference as WKT to GeoDjango?

I'm trying to insert some National Grid references into a Django PointField defined as follows: oscode = models.PointField(srid=27700, null=True, blank=True) However, I don't know how to format them correctly in WKT. This is what I get if I try simply using a basic National Grid reference, TR3241: INSERT INTO places (placeid, struct...

How to Improve UPDATE query result time in Postgresql?

I have the following query running for 3hours+: UPDATE eop_201007 set coord_x = gi.x_etrs89, coord_y = gi.x_etrs89,gr_type = 4 from eop_201007 as eop, geoindex201001 as gi where eop.cp7=gi.cp7 AND eop.gr_type=0; eop table has 300k+ records, and gi table 100k+. The cp7 field is indexed in both tables, and this is taking way too much t...

Need performance on postGIS with GeoDjango

This is the first time I'm using GeoDjango with postGIS. After installation and some tests with everything running fine I am concerned about query performance when table rows will grow. I'm saving in a geometry point longitudes and latitudes that I get from Google geocoding (WGS84, or SRID 4326). My problem is that distance operations a...

Constucting a PostGIS query with Rails

I'm using PostGIS (1.5.1) with Rails (3.0.0rc) and a Google Map (v3), and I'm looking for a way to query the database to retrieve all the points within a polygon (specifically, the bounds of the map viewport). At present I am sending the coordinates of the bounds to the server as such: google.maps.event.addListener(map, 'bounds_changed'...

tinyows fid returned as table_name.null ?

Dear friends, i am trying to use tinyows for wfs-t in my app along with openlayers and postgis. i am using osm tables and myown tables for storing geom. tinyows working fine with osm tales, but returning table_name.(null) as fid for requested features. so i am unable to do wfs-t on my tables. How to solve this error, where is my mistake...

Geography mode distancies in GeoDjango - PostGIS 1.5

I store a PointField field named "coordinates" in a model. Then, I consult nearest instances from a given one, in the command interpreter, and print its name and the distance in km. [(p.name, p.distance.m) for p in Model_Name.objects.filter(coordinates__distance_lte=(pnt, 1000000)).distance(pnt)] The thing is, when the field "coordin...

I want to edit corresponding postgresql data of a vector from openlayers- how to do it?

hi Friends, I want to edit the corresponding text/numeric data type columns of a vector through openlayres, when a user click/mouse over a vector. like, http://dev4.mapgears.com/bdga/bdgaWFS-T.html# any tutorial page for how to do it? I gone through it , it was difficult for me to understand from its js codes. -posted in gis.stackexch...

PostGIS 1.3.5: where to download it from ?

I was looking for a two years old version of PostGIS because I need to import data from an existing remote database and it won't let me make an exact mirror of the database, I need to install PostGIS locally before transferring data and being able to upgrade locally. The problem is that version is no longuer available and I can't seem t...

postgis / proj 900913 to 4326 projection issues with Y coordinate

hi all, this is an oldie, but i cannot seem to find a solution. When i want to do an st_transform on a 900913 coordinate to a 4326 system, the y coordinate shifts. example: SELECT AsText( Transform( Transform( GeomFromText( 'POINT( 449760.25168159 6790560.4594059 )', 900913), 4326 ), 900913 ) ) here the original 900913 stating p...

GIS: PostGIS/PostgreSQL vs. MySql vs. SQL Server?

I need to analyze a few million geocoded records, each of which will have latitude and longitude. These records include data of at least three different types, and I will be trying to see if each set influences the other. What database is best for the underlying data store for all this data? Here's my desires: I'm familiar with the DB...

PostGIS : nearest linestring to a given point

Hi guys. I've been using PostGIS in a long time now but never had to use the LINESTRING geometry ... yet! :) Here's what I would like to do : I have a table of linestrings (representing streets of a given city, SRID 3395) and I would like to find the nearest linestrings to a given point (GPS position, SRID 4326). The solution I found ...

PostgreSQL+PostGIS function that gives angular seperation for a pair of (lat,long) points.

I wrote the following code (after spending a few hours trying to get the quoting correct): CREATE FUNCTION ast3angsep(double precision, double precision, double precision, double precision) RETURNS double precision AS $$ SELECT ST_Distance( ST_GeographyFromText('SRID=4326;POINT('||$1||' '||$2||')'), ST_GeographyFromText('SRID=4326;POINT...

Grant EXECUTE to many PostGIS functions

Hello. I have a Web Application which is based on MapServer, which uses PostGIS as underlying database extension. Now I want to have a dedicated database role which is used for MapServer, cause I don't want to access the database via the postgres superuser. This role should only have SELECT permission on public tables (which is easy to...

PostGIS: bounding box of a multipolygon

SELECT id, ST_Box2D(areas) AS bbox FROM mytable; In this example, the table "mytable" contains two columns: "id" is the unique id number of the row and "areas" is a geometry field containing one MULTIPOLYGON per row. This works fine for multipolygons containing only one polygon, but some rows have polygons very spread apart, hence t...

Comparison of geospatial support for mongodb and postgis

I am in the process of creating a consumer facing location based mobile app that will heavily need GIS support. I have narrowed down the databases to Postgres (PostGIS) and mongodb. I was wondering how someone who has experience with both would rate the geospatial support particularly in the area of: Performance Query expressibility ...

PostGIS: register a "geometry" column without AddGeometryColumn

The usual way to create a geometry column is AddGeometryColumn, however I have to work with pre-existing columns, so I can't use that function (as far as I know). Thanks to the PostGIS docs, I can already register the column in the "geometry_columns" table, however AddGeometryColumn seems to do more than create a column and add a row in...