Hot answers tagged

8

This can be done using the Processing Graphical Modeler to set up a custom chain. Here's a pic: From left to right we have three inputs - the tree layer (a Vector Layer Input Object), the buffer size (a Numeric Input) and the tree height (a String Input). The tree layer is then selected by its height attribute. The selected trees are then buffered by the ...


6

Your coordinates are out of order. If you reverse the order of coordinates in the first query, postgis says: 708.55982691. In postgis it's lon, lat, not lat, lon.


6

Log in to www.arcgis.com with administrator credentials. Click My Content, and navigate to the intended feature service. Open the feature service. If the error, "There are no services available" is returned when visiting the ArcGIS REST Administrator Directory, the hosted feature service is shared with 'Everyone' (public). In the item details page of the ...


5

[timeout:25][bbox:{{bbox}}]; ( way["highway"="motorway"]; way["highway"="trunk"]; way["highway"="primary"]; ); out body; >; out skel qt; See it on overpass-turbo: http://overpass-turbo.eu/s/aTL


5

Just figured it out. In the layer properties, go to the "Labels" tab, and set the Method to "Define classes of features and label each class differently". I set two different classes ("Default" and "2"), each with a different style and scale range. the label now changes its style according to scale range.


4

One method is to use the IN function followed by your list of values all inside brackets. E.g. "Column_Name" IN ('Value_1', 'Value_2', 'Value_N') Hope this helps!


4

If you've got a polygon you want to use as a declared variable and intersect it with a table containing existing geometry, your query (including your polygon variable declaration) would look something like this: (MSSQL Server syntax) declare @polygon geometry = 'POLYGON((-9486683.581 4810152.256, -9282073.762 4821688.121, -9262037.786 4625578.413, ...


4

I'm having difficulty with the classification of "search by attribute" as a "language". To understand an answer to this startlingly broad question requires understanding of the meanings of a number of computer terms, including: Application software, programming language, data format, user interface, and access paradigm. ArcGIS is application software. It ...


4

You can enter the following python command which will create an expression based on the selected feature ids on the active layer. '$id in ({})'.format( ','.join( str(id) for id in iface.activeLayer().selectedFeaturesIds() ) ) $id in (497483783,497483784,497483785) or something that works also with persistent values but needs to be finetuned for ...


4

In Postgres column and table names are not case sensitive and everything is converted to lower case before executing the query, see the docs. Therefore, SELECT SomeColumn FROM SomeTable becomes SELECT somecolumn FROM sometable unless you write it as SELECT "SomeColumn" FROM "SomeTable" In my view this is messy, especially when dealing with SQL ...


4

You can easily achieve that with select by expression dialogue. "my_field" LIKE '%specific_words%' See this example


4

You can use the regexp_match function to match the first number inside your CASE statements: CASE WHEN regexp_match("nombre", '^[0-3].*') THEN 'ROSETAS' WHEN regexp_match("nombre", '^[4-5].*') THEN 'CTO' ELSE 'OTRAS' END


4

For a File Geodatabases you could use - SUBSTRING(REGION FROM 1 FOR 3) = SUBSTRING(REG FROM 1 FOR 3) For a Shapefile use: SUBSTRING(REGION, 1, 3) = SUBSTRING(REG, 1, 3) I got the shapefile syntax from this Technical Article - HowTo: Compare a field with a substring in another field


3

The alternative is the use an AND/OR statement: "Column_Name" = 'Value_1' OR "Column_Name" = 'Value_2'


3

You can do this easily using a regular expression match. Try using the expression: regexp_match( "ADDRESS", '^[A-Za-z].*') This will select all records where the ADDRESS field begins with an upper or lowercase letter. The second argument is a regular expression - it specifies that the string has to begin '^' with a character in the range '[A-Za-z]', and ...


3

Just as an update to reflect the fast development in QGIS: In QGIS 2.8.2 (I don't know when it was introduced), commenting in expressions now seems to work! Using -- for one-line comments and /* ... */ for multi-line comments turnes the letters to a green color in the expression builder window and they seem indeed to be commented out! Thanks to the ...


3

You can use the Summary Statistics GP tool for that. Choose Shape_length field to be the Statistics field, and Locality Name field to be the case field.


3

Make sure your response is a featurecollection. You can get more information on how to do this here: http://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html So you probably can get along with something like SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As type, ...


3

It looks like the syntax you are using above is for a File GDB. If this references a feature class in SQL Server, I believe the syntax would be something like this: Field_A NOT LIKE '%' + Field_B + '%' This should work in the select by attribute tool or you could also set this as a definition query on the layer and work with the results that way as well. ...


3

you can also use strpos( "myField", 'awesome') > 0 and for case insensitive searches strpos( lower("myField"), 'awesome') > 0 this is slightly more error-prone as you need to put double quotes around field names and single quotes around string values. I always fall into that trap. I noticed that a recent version of QGIS (2.12?) has quietly ...


3

You must first UNION all the geometries. Then you can LEFT JOIN the geometries ON ST_Equals to retrieve the values. Sample code -- Create dummy test values WITH sand1 AS ( SELECT val, ST_MakePoint(x, y) geom FROM (VALUES (11, 0, 0), (22, 1, 2), (32, 3, 1)) a(val, x, y) ), sand2 AS ( SELECT val, ST_MakePoint(x, y) geom FROM (VALUES (12, 0, 0), (23, 1, ...


2

I do this with: echo [% "id" %]," [% "name" %], [% "year" %] OBSERVATION: If you have two or more point in the same local, you will get only one response. I need the next response, if someone knows how to do: id name year (for point 3) id name year (for point 3) id name year (for point 3) example: 17 Elsa 1985 ...


2

I always encourage to use field delimiters to access the fields in a right way: field_name = "UNIQUEID" input_value = 5 sql_exp = """{0} = {1}""".format(arcpy.AddFieldDelimiters('c:/data/file_gdb.gdb', field_name),input_value) print sql_exp >>> 'UNIQUEID=5' Another way to do this is to use the str.format(): sql_exp = """{0} = ...


2

I'd suggest an alternative approach: Download raw OSM data and use OGR to prepare your data in such a way that the relevant tags are not mashed together in the "other_tags" column. This can be achieved by customizing OGR's osmconf.ini file as documented in http://www.gdal.org/drv_osm.html. Look for the lines # keys to report as OGR fields ...


2

For a Python script, you could call tools such as Select by location from the Python console: import processing processing.runalg('qgis:selectbylocation', input_layer, intersect_layer, u'intersects', 0, output_layer) To see what parameters are required, you can call processing.alghelp("qgis:selectbylocation"): >>> ...


2

R's Spatial classes have select/extract idioms driven by the "[" operator - for extraction by index, number, name, logical map, or spatial overlay. I think this is close to what you mean. library(maptools) data(wrld_simpl) ## generate some random points n <- 5e4 d <- data.frame(lon = runif(n, -180, 180), lat = runif(n, -90, 90), x = seq(n)) ## ...


2

Bingo. It involved a little witchcraft piping two ogr2ogr instructions together via STDIN/OUT, and you'll need to adapt it to your purposes, but something like this should work: ogr2ogr -f "GeoJSON" /vsistdout/ -dialect sqlite -sql " SELECT fullname, COUNT(*) as ct FROM ROADS_3857 GROUP BY fullname " "C:\xGIS\Vector\ROADS_3857.shp" | ogr2ogr -f "CSV" -where ...


2

This is mostly a SQL question that fits better to stackoverfow. First error in your SQL is that you use "GROUP BY road_name" but you have not selected "road_name". Another error is that aggregate functions like count() can't generally be used in WHERE but it must be placed into HAVING or into a subquery. See ...


2

Use the "Join Attributes by Location" in the Vector menu for your cities and federal state layers, select to keep all attributes, then with the result shapefile, use "Save As" and select to save it as csv.


2

Your coordinates are in lat/lon (EPSG:4326) but you need to convert them into the projection that your polygons are stored in, so your query should be something like: SELECT ST_Contains((select the_geom_3776 from calgis_citybound_limit), ST_Transform( ST_SetSRID(ST_MakePoint(51.0644894,-114.081923),4326), 3776));



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