Hot answers tagged

4

QGIS has its own internal handling of layers and features. Different data "providers" are used to pull layers in from a variety of sources (eg PostGIS, OGR file types, WFS servers, etc) and translate them into QGIS' own internal formats. Once you have a project fully loaded, including a .shp file plus a .dbf, plus another CSV joined, are all the data in ...


3

I suggest use parameter passing to the script while you call this script using task scheduler and grab this parameter using sys module- as below try: data = "= For ArcGIS 10.3.1: Date: "+str(timed)+ sys.argv[1]+'\n' #grab parameters passed except: data = "= For ArcGIS 10.3.1: Date: "+str(timed)+ "Arcgis tool used"+'\n' # else arcgis tool ...


3

You're close! The setGroupVisible function requires (int, boolean) as parameters (i.e. the integer you provided for your group as 0). Try the following: root = QgsProject.instance().layerTreeRoot() group1 = root.insertGroup(0, "PGB") legend = iface.legendInterface() legend.setGroupVisible(0, False)


2

wait, it looks like it's expecting a file or a file-like object. when you say you have an json embedded in python, it's the whole json text, not the file path? a = "/home/george/boundaries.json" # file-path b = "{ 'type': 'FeatureCollection', 'crs': { 'type': 'name', 'properties': { 'name': 'EPSG:3857' } }, ...


2

You could automate some tasks using the QGIS modeler which allows you to build and run models on selected layers like the following: There's a nice tutorial in the following link which goes into quite great detail on how to create a complex model: Automating Complex Workflows using Processing Modeler. You could also use the Python Console to call ...


2

If you look at QgsZonalStatistics.Mean it's part of an enumeration - it's actually the integer 4. You're calling it as if it's a function. Try removing the brackets:- zoneStat = QgsZonalStatistics (polygonLayer, rasterFilePath, 'pre-', 1, QgsZonalStatistics.Mean) zoneStat.calculateStatistics(None) Note that these values are done as powers of two; to get ...


2

You can use mapnik.save_map() import mapnik m = mapnik.Map(1440,800) # ... add styling and layers ... mapnik.save_map(m, "output.xml")


2

You initiate newGeom as GEOMETRYCOLLECTION, but in the loop you combine geometries. combine is the geometric union operation and as such has a much greater job than simply adding a geometry to a collection. It must check topological relationship on a low level, and if objects are disjoint it aggregates them to MultiPolygon geometries. When I interpret your ...


2

This is what fiona module would do, but in a sense you are then adding some GIS functionnalities to Python. Further GIS-like analysis on the geometries can then be performed using shapely.


2

This is only half an answer as the following code can be used to import waypoints, routes and tracks but not route_points or track_points (these seem to be replaced by the tracks layer). import os path = "path/to/gpx/folder" names = ["waypoint", "route", "track", "route_point", "track_point"] for dirpath, subdirs, files in os.walk(path): for f in ...


1

A solution was given by Tim Sutton in A python layer action to open a wikipedia page in QGIS (in one single line): In my case, the field is "URL" and the complete path of one feature is for example http:/..../descriptions/4280614.htm (URL = "4280614.htm") The Python action is then (in one single line): from PyQt4.QtCore import QUrl; from ...


1

The custom function can be used to run a specific function on each feature in a layer. But this will be feature specific. For more uses for this please see the following posts specifically for this: http://www.lutraconsulting.co.uk/blog/2015/06/05/qgis-function-editor/ http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/ ...


1

SampleServer3 = ArcGIS 10.0. SampleServer6 = 10.3. As suggested, its the server which is having problems, not your code. The following works against 10.3 - note I modified your code to use built-ins instead of Requests. (Remember, Server underwent massive changes between 10.0 and 10.1. If you're stuck at 10.0 I'd suggest looking to upgrade as soon as ...


1

As @polygeo suggests, POST requests do have a size limit, but it depends on server and browser. http://stackoverflow.com/a/2880777/3182496


1

The code looks fine, but I'd expect the performance to get worse over time. Each time round the inner loop, you're combining the current feature's geometry with the union of all the previous matching features' geometries. At the start you'll have one simple geometry. Each time round the loop, the geometry gets more complex, so each time round the loop it ...


1

The reason why it doesn't work is because the arguments for is_land(xin, yin) are referencing the grid, and aren't latitudinal and longitudinal coordinates, they're simply the index values. Since is_land(xin, yin) takes index values and not lat/long coordinates, you need to find out the index values on the map for the coordinates you're interested in. map ...


1

This page has a good example of doing rule based renderer via python: Rule-based renderer The rule-based renderer styles features using a list of rules, defined by expressions. The rules are processed sequentially, with the first matching rule used to render a feature. The example below defines a new rule-based renderer for different ...


1

I would use a data access module da Update Cursor and the replace() method to accomplish this. The following is the preferred (new) method of using an Update Cursor. import arcpy shp = r'C:\path\to\shapefile.shp' with arcpy.da.UpdateCursor(shp, "your_field") as cursor: for row in cursor: row[0].replace("-", "") cursor.updateRow(row)



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