Acronym for Structured Query Language. A syntax for retrieving and manipulating data from a relational database.

learn more… | top users | synonyms

1
vote
1answer
64 views

Rewrite query to match two points with a linestring in a different database table

OK, not sure if I've worded the title brilliantly, but here goes: Suppose I have: a table "gps_nodes" containing columns: "EASTING" (containing longitude data) "NORTHING" (containing latitude ...
3
votes
1answer
592 views

PostGIS intersection function

I have a problem with intersection function. I built my query following http://manual.linfiniti.com/en/postgis/geometry.html, 5.7 section. I made my clip object, a red linestring frame: But after ...
1
vote
2answers
176 views

How to form SQL Expressions with mix of integer/numeric and text/string fields/values in ArcPy?

I am trying to create a query for the select by attribute function within a Python script.This is my current code. lot = '96' dp = 756421 lotFile = ...
5
votes
1answer
270 views

Is it possible that a good spatial index just cannot be made?

I have about 6 million rows with geography spatial features - they are all 1000 meter radius hexagons all over the US. There are a couple hundred thousand that would have been NULL, which I updated ...
1
vote
2answers
108 views

SQL: Select aggregated Bounding Box of multiple Features

I would like to calculate the aggregated bounding box of multiple features using OGC Simple Feature SQL or SQL API of ArcSDE. The following statement will only query the bounding box of each feature: ...
1
vote
1answer
173 views

Calculating difference between bearing values in degrees

Suppose I have 3 geographic points, A, B and C. I can calculate the bearing of B from A (in degrees) using this SQL snippet: degrees(ST_Azimuth(geogA,geogB)) as brg_a_b ...and the same of C from ...
4
votes
2answers
653 views

SQL Syntax to extract (convert) Strings with Degrees Minutes to Decimal Degrees

I have a PostgreSQL/PostGIS database with a two string fields containing Lat and Long coordinates in degrees and decimal minutes, like this 45° 24.5' N 3° 43.01' E. How can I convert them into ...
1
vote
3answers
272 views

Differences between SQL dialects in QGIS vs ArcView vs Oracle

I'm kinda new with SQL queries and there is something I don't get: A SQL query in QGIS is written differently than the same query in ArcView and will probably also be written differently if I want to ...
3
votes
1answer
69 views

Use selected value in postgis function

How can I use the selected value from a SELECT statement in a PostGIS function. e.g. using the geom_way from SELECT geom_way FROM osm_2po_4pgr ORDER BY ST_Distance(ST_GeomFromText('POINT(21.323329 ...
1
vote
1answer
39 views

How to do “random” distribution of certain classes to certain amount of polygons with respect to spatial constraints

I have a polygon layer. Now, I would like to assign/allocate/classify these Polygon into 13 different classes respecting spatial constraint, in my case: neighboring polygons (sharing line or nodes) ...
2
votes
2answers
156 views

Can I use the LEFT (string) operator in ExecuteSQL()?

In QGIS I can use the LEFT operator on a dataset like this: LEFT( "Name2",3) ='031' What is the syntax for using this expression with ogr in python? Isn't this the right syntax? ...
0
votes
0answers
76 views

Multiple geometry in a cursor SQL

I have a cursor which I create from a table which has one geometry field only. But in my cursor I would be using two geometry fields as I need to calculate two different areas.Below is the sql ...
3
votes
1answer
702 views

raster2pgsql: Strange error when creating a table

Hi GIS Stackexchange people, When I try to load a asc file into my psql setup, I get a strange error message. I have created the sql input file via raster2pgsql -s 4236 -I -C -M gis_data.asc -F ...
2
votes
0answers
36 views

Multiple Cursors

Below is the sql statement which I have explained below. Declare Cursor c1 is select store_number ,0 as total_area,0 as BG_ID ,0 as store_geom from table1 where CLIENT_ID= 1 and ORG_ID ...
0
votes
0answers
33 views

SQL cursor issue

I am trying to create a new table using a cursor and a select statements. Declare Cursor c1 is select store_number from table1 where CLIENT_ID= 1 and ORG_ID = 1 ; Type C1_TAB_TYPE ...
2
votes
1answer
830 views

Trouble with INSERT in PostgreSQL 9.1

I am trying to execute the following: INSERT INTO lithic (cp_east, cp_north, type, material, art_count, comment, field_no, gps_unit, initials, rec_date, cortex, geom) SELECT (cp_east, cp_north, ...
2
votes
2answers
99 views

shp2pgsql mangles date field — quotes data as if it were char or varchar

I'm attempting to import a shapefile into postgis via shp2pgsql. Among the fields in the shapefile's .dbf file is a date field with format yyyymmdd, which is a valid date format for postgresql. ...
0
votes
0answers
67 views

Is there a limitation in quantity of joined tables using spatialite views?

I've one point layer in qgis and several non spatial tables in a spatialite database. Now I want to create a view as you can see in the following: CREATE VIEW testansicht10 AS SELECT ...
1
vote
1answer
183 views

arcpy: can I use SelectLayerByAttribute to compare fields from joined tables?

I can't figure out the syntax to select table records where one field's value exceeds that of another. The fields are from a pair of table views connected w/AddJoin(). One view is of a fgdb table and ...
0
votes
1answer
56 views

Issues with pgrouting workshop code in postgis 2.11/pgrouting 2.0

I'm having issues getting the pgrouting workshop to work on Postgresql 9.2/PostGIS 2.11 and pgrouting 2.0 on windows. How can I rewrite the following php/sql code and make it compatible with my ...
4
votes
3answers
514 views

How to create Where Clause from user input via Python list?

I am trying to perform a query based on values in a Python list. The where clause will then be used in an Update Cursor, so that the rows NOT equal to the values in the list will be deleted. This is ...
0
votes
1answer
73 views

Create Area or Polygon based upon a Series of points

i have a large list of points that i would like to merge to create an Polygon based upon an attribute. Essentially an area that encompasses all points. x | y | attr ____________________ 1 | ...
0
votes
1answer
618 views

Where Clause problems when all parts are user input variables

I have written some generic user ipnut code for a toolbox script (ArcGIS 10.0) but because everything is a variable I don't know how to write the SQL whereclause. Please can someone help and suggest ...
2
votes
1answer
260 views

Direct DBMS sql queries and ArcSDE geodatabase

i want to make updates from Arcobjects on several tables stored on a ArcSDE 10.1 versionned geodatabase based on Postgresql 9.0.5 , none of these update require spatial data , and making these updates ...
3
votes
2answers
1k views

Adding rows of data to a non-spatial table in ArcMap with a SDE SQL Server for Metadata purposes

I'm attempting to use several non-spatial tables to better organize the large set of feature classes I continually add to a SDE Geodatabase (SQL Server Express). So I have several tables setup and ...
1
vote
4answers
724 views

How to find the center point of MULTILINESTRING?

How to find the center point of MULTILINESTRING, which lies on the multiline?
4
votes
1answer
376 views

How to populate SQL options for parameter in ArcGIS 10 tool?

I'm trying to create a tool where individuals can select a variety of records using a SQL expression that is then passed to a calculation. I can add a parameter under the tool, and select SQL ...
3
votes
1answer
461 views

Edit SQL Server table (not registered with geodatabase) with arcpy

I am trying to update some rows in a SQL Server database table (not registered with geodatabase) with arcpy.da.UpdateCursor. However, when running the deleteRow(), I get the error return without ...
14
votes
5answers
4k views

A SQL console in QGIS

I know QGIS comes with its field calculator, which is not bad. It also comes with ftools which permits several operations on geometry and attributes. But we often need more control and I haven't seen ...
4
votes
1answer
780 views

Select by attribute expression invalid in python

I'm not sure how my expression is failing. Any ideas? inPoints = "points.shp" i = 0 arcpy.MakeFeatureLayer_management(inPoints, "pts") arcpy.SelectLayerByAttribute_management("pts", "NEW_SELECTION", ...
0
votes
0answers
74 views

Select By Attribute sql problems [duplicate]

Having trouble with this python code. I keep getting a ERROR 000358: Invalid expression" code for the select layer by attribute management statement towards the end of the code. Moved the data to ...
2
votes
2answers
518 views

CartoDB- Passing selected features bounds to map center parameter (Zoom to selected features)

Looking to build a light-weight viewer for some data we have hosted on CartoDB. I'm looking to have a user input their address into an input, pass a query to CartoDB and have the map zoom/pan to the ...
6
votes
3answers
1k views

Join intersecting lines with PostGIS

This is something that I'm almost ashamed to ask but I can't seem to get it to work for the life of me. I have a road layer with segments, each segment has a Road ID and a segment type. I would like ...
3
votes
2answers
993 views

Check if an object is empty in mapbasic

I have mapbasic code that manipulates the obj-column in a point-table. Some rows doesn't have any geometry so the obj-column is empty. My question is how to check if there is no object? All the ...
0
votes
1answer
244 views

Linked point geometries to linestrings in Spatialite

I have been parsing Canada's radio system frequency open data. It's a single large table per province, containing point geometries for each station callsign. Where a point-to-point link is defined, ...
1
vote
1answer
52 views

Using Like on Join Field

Ok, so this has probably been asked by someone else out there somewhere but I can't find it via google or this stack, so... I've got two tables from an SDE database (SQLServer Express 2008 r2) that ...
1
vote
2answers
150 views

sqlite version error with ogr2ogr

I am trying to randomly select some points from a shape file using ogr2ogr and an SQL query via sqlite but it seems to baulk at the sqlite version: ogr2ogr -sql "SELECT * FROM probe_2004to2012 WHERE ...
1
vote
1answer
238 views

Multiple input shapefiles for ogr2ogr sqlite spatial operations

I'm running up against an issue doing a spatial operation requiring multiple input shapefiles using ogr2ogr and sqlite. I have: ogr2ogr -f "ESRI Shapefile" output.shp input.shp -dialect sqlite -sql ...
0
votes
1answer
58 views

Wrong output wth group by and aggregate function in spatialite

I have a grid and for every cell I want to set the column "landuse" according to the largest intersecting polygon. SELECT grid.PKUID, landuse.landuse, ...
0
votes
0answers
205 views

Date Parameter in model builder - ArcMap

Basically I'm building a model where the user has to select the data from a drop down list and the result is executed. I have a problem when trying to pass a date as a parameter. Below you can find ...
1
vote
1answer
1k views

Postgresql Trigger to insert records in my table from another one

I spent few days trying to resolve this question but it was impossible. I have two tables: Table1. CREATE TABLE point ( id_point integer NOT NULL DEFAULT, layer text, elevation numeric, ...
19
votes
4answers
6k views

What is the best way to join lots of small polygons to form a larger polygon?

I have the following layer using SRID 27700 in postgis: It's every administrative region in the UK, and (as you can see from the colour grouping) each of them has a text field specifying the county ...
3
votes
1answer
82 views

New attribute creation using ogr and regex

I've got a folder full of dxf files with elevation values included as part of a long text attribute. I've written a regex expression to extract the elevation value, and would like to add it as a new ...
7
votes
2answers
3k views

PostGIS: Find points that lie within a set of coordinates

I have a PostGIS db, and I want to find the points that lie within some region (a bounding box). I have two sets of coordinates, from which I can get all four rectangle points that form the box (if ...
2
votes
1answer
674 views

How to get polygons from PostGIS table to PHP array best?

Currently I fetch polygons from a database table using ST_AsText(). The results are in text format, like the following. POLYGON((84 104,212 48,321 122,243 179,275 238,131 240,84 104)) I am not ...
0
votes
1answer
46 views

Could SQL performance be increased by storing rotations of the data?

I'm working on a project where this kind of SQL Psuedocode would apply: SELECT * FROM objects WHERE (distance My inputs are latitude and longitude, and my database holds latitude and longitude. ...
4
votes
1answer
166 views

How to query nearest date in ArcGIS Server REST?

How to query nearest date (today) in ArcGIS Server REST? Table: ID NAME DATA 1 test 2013-06-01 13:00:00 2 test1 2013-06-01 16:00:00 3 test2 ...
3
votes
2answers
761 views

GDAL SQL syntax to add field an put values

I try to make a new field in my attribute table and put in values from another field after converting from character to integer but can't get the right syntax. I run this as shell-script in MSYS. cd ...
1
vote
1answer
494 views

Postgis: find geometry within multiple polygons

I've got two tables with geometry in it. Table 1:items holds items with a point geometry; while the second table property_zones holds polygons. The Items: CREATE TABLE public.items ( id integer ...
2
votes
0answers
171 views

Select a distinct attribute with maximum shape area

I am trying to manipulate a large dataset containing a lot of sliver polygons resulting from an overlay operations. (The eliminate tool is very time consuming to generalize them.) I identified the ...