Tag Info

Hot answers tagged

14

Building a query expression. Check the Combining Expressions sub-heading to see how to use the AND/OR operators correctly. For your example you should implement "IN": "Name" IN ('Chatham','Chester')


13

Have you tried replacing the "=" with "is"? I don't have QGIS in front of me, but that is pretty common database select syntax for working with NULL values. pedonal is NULL


12

This illustration stuck with me, and helps me remember at the most basic level what precision vs. accuracy is.This is the source of the image, also containing a little more context. In general, Precision is the how close your grouping of measurements are. Accuracy is how close your measurement is to the actual measurement in the real world. Blah238 is ...


11

All spatial table references are held in the geometry_columns metadata table. So try: select * from geometry_columns and you should get just the spatial tables


10

First, make sure you have an index on your geography column. It will speed up the spatial searches: CREATE INDEX geo_cities_geog_idx ON geo_cities USING GIST geog; VACUUM ANALYZE geo_cities(geog); Then, you can use ST_DWithin (with conversions from miles to metres) on a self-joined query: SELECT gc.*, ST_Distance(gc.geog, pt.geog)/1609.344 AS ...


9

Use "Name" IN ('Chatham','Chester Falls'...) Separate each with a comma and end with a closed parenthesis.


8

Use the methods available on the ISQLSyntax interface to make your code workspace-independent. As the help on IQueryFilter.WhereClause explains, use the ISQLSyntax.GetSpecialCharacter method to return the delimited identifier prefix and suffix specific to your workspace and add them to your column identifiers. Example: ISQLSyntax sqlSyntax = ...


8

All you need to do is change AND to OR. Because AND is a valid logical operator the validation passes. So technically the query is correct, it just will not return any records.


8

This is an exciting question! How big is the raster you want to query? WKTRaster is stored in the database as a BLOB. In order to find the value at a specific point, from a known (x_0, y_0) corner coordinate row/column indices (i, j) are computed using (dx, dy) steps and rotation. With (i, j) known, the ST_Value() function can access the actual data at the ...


7

This is a problem coming from that ST_Intersects has no tolerance. Even if double precision coordinates holds a lot of decimals they form a grid where the only places for the points is in the crossings. Often the line doesn't intersect with any of those crosses and there is no way any point will intersect the line exactly. The workaround is to use st_dwithin ...


7

I can get you part of the way there by assuming you have figured out how to request (a) the easternmost half of a set of points and (b) the northernmost half of a set of points. From these you can, of course, easily obtain (c) the westernmost half or (d) the southernmost half. (I don't know QGIS, but one way to do (a) in general is to request the median ...


7

First off, yes you will definitely want to make sure your primary and foreign key fields are indexed on both tables. This lets the DBMS plan and execute queries against these fields much more efficiently. Secondly, you are calling SelectLayerByAttribute_management in a tight, nested loop (once per tree per treatment). This is highly inefficient, for several ...


7

I'm surprised it's quite so coarse, but there it is. It's not DISTINCT, per se, it's the '=' operator, which is defined for geometry as 'equality of the index keys' which means practically 'equality of the 32-bit bounding boxes'. You can see the same effect just using '=' directly, select 'POINT (0.000000001 0.000000001)'::geometry = 'POINT (0.000000001 ...


7

The docs specify that ST_Split returns a collection of geometries. You can confirm this using some test data: WITH rect AS (SELECT 'POLYGON ((0 0, 10 0, 10 1, 0 1, 0 0))'::geometry as geom), line AS (SELECT 'LINESTRING (3 0, 3 1)'::geometry as geom) SELECT ST_GeometryType(ST_Split(rect.geom, line.geom)) FROM rect, line -- returns ...


6

You can also use the IN (includes). Like... Tenement IN ('E59/1002', 'E59/1421') Tenement NOT IN ('E60/1002', 'E60/1421')


6

You can preatty easily run a search by combining WFS anc CQL like in the following example: layerQueryRun: function() { var wfs = new OpenLayers.Protocol.HTTP({ url:WMSCONFIG.wfs_server_path+"?service=wfs&version=1.0&request=GetFeature&typename=" + youLayerTypeName, format: new OpenLayers.Format.GML.v3({}) }); // ...


6

To answer the first part of your question, I think it helps to look at the additional text in the Creating Attribute Indexes help file about Multi-column indexes. The order in which fields appear in a multicolumn index is important. In a multicolumn index with column A preceding column B, column A will be used to conduct the initial search. Also, ...


6

When creating a spatial index on a table it is important to run "vacuum analyze <table>" after that. For finding nearest points you can use operator <-> introduced in PostGIS 2.0. It actually gives you the distance between two points. More info can be found here: http://workshops.opengeo.org/postgis-intro/knn.html SELECT id FROM nodes ORDER ...


6

Some useful stuff here for 1.8 and older http://hub.qgis.org/projects/quantum-gis/wiki/How_do_I_do_that_in_QGIS http://hub.qgis.org/wiki/quantum-gis/Calculating_field_values http://hub.qgis.org/wiki/quantum-gis/List_of_Field_Calculator_Functions


6

No, probably not. I'm going to assume from the coordinates of your point that you are working in longitude/latitude coordinates, but that you want to express your distances in meters. Rather than building a real "circle", recognize that for the purpose of a true/false test you can express the query as a distance calculation. SELECT routes.* FROM routes ...


6

Like so, CREATE INDEX mytable_gix ON mytable USING GIST (Geography(ST_MakePoint(lon, lat))); SELECT * FROM mytable WHERE ST_DWithin( Geography(ST_MakePoint(lon, lat)), Geography(ST_MakePoint($qlon, $qlat)), $radius_meters ); Edit: If you have your data already in geometry points, but want to do a geography-style query: CREATE INDEX ...


6

You can use the join method: selectionQRY = "RTE_1_NBR <> '" + "' AND RTE_1_NBR <> '".join(userSelectionList) + "'" A string will be created, in three parts. The middle part is the key, where code of the form string.join(list) will take all objects in the list, convert them to strings, and then append them all together, with the specified ...


6

1) Select your polygon of interest - you can do this manually or with one of the selection tools. 2) Select your 'marginal' points using the Select By Attributes tool with the Method drop-down set to 'Add to current selection'. You will now have a selected polygon in one layer and selected points in another layer. 3) Use the Select By Location tool to ...


6

You just need "KDhh_survey".* in your Select SELECT "KDhh_survey".* FROM public."KDhh_survey", public."ur_pilot_survey" WHERE ST_contains(public."ur_pilot_survey".the_geom, public."KDhh_survey".the_geom);


6

There easily might be multiple queries that return the same result. Using the following data: FID STNAME DIR 0 BLUE ST N 1 BLUE ST S 2 BLUE ST N 3 BLUE ST S 4 BLUE ST S 5 BLUE ST S 6 BLUE ST W 7 BLUE ST W 8 BLUE ST W 9 BLUE ST W 10 BLUE ST E All these queries return the same thing: "FID" < 6 "FID" < 6 AND "STNAME" = 'BLUE ST' ...


5

Do you just need to know the max value for each unique entry in column B, or do you actually need to select the features with the maximum values on your map? If you just need an output table with headings [B], [Max_of_A], you can open the attribute table, then right-click column B and choose Summarize. In the list of summary statistics to be calculated, ...


5

Underdark has composed some nice examples for labeling expressions: Easier Conditional Labels in QGIS Here are some helpful links for querying: Query Attributes Working with Attribute Table - Basic Queries If you are interested in coding then you can start with this resource: pyQGIS Developer Cookbook


5

This works for a "relate" (definded in an MXD). I'm not sure if it works for a "relationship class". Please try. If you work with a relate you make a selection in table A and transfer this selection to tabe B (this works in both directions of a relate): Make a selection in the "vegetation table". Open the attribute table of "vegetation table" Click the ...


5

The wildcard to use with LIKE depends on the data source. You are using square brackets as field name delimiters. So I suppose you are using a Personal Geodatabase. The wildcards you have to use to query a personal geodatabases are asterisk (*) for any number of characters and question mark (?) for one character. If you use SDE or file based geodatabase ...


5

Skip the trig, create view mypoints as select id, st_makepoint( st_x(st_endpoint(geom)) + (st_x(st_endpoint(geom))-st_x(st_startpoint(geom)))/2, st_y(st_endpoint(geom)) + (st_y(st_endpoint(geom))-st_y(st_startpoint(geom)))/2 ) as geom from mytable; then select geom from mypoints where id = 1; should work fine, for all values of id



Only top voted, non community-wiki answers of a minimum length are eligible