Tag Info

New answers tagged

1

I've ran in the same problem with the current QGIS 2.6.1 by just typing make I had the same error again.Now I've searched for the pyuic4.bat file and it was located correctly. SO I just used the absolute path in the OSGEO4W Shell: C:\Users\ricckli\.qgis2\python\plugins\qgis2leaf>make pyuic4 -o ui_qgis2leaf.py ui_qgis2leaf.ui make: pyuic4: Command not ...


0

I've ran in the same problem with the current QGIS 2.6.1 by just typing make I had the same error. I've searched for the pyuic4.bat file and it was located correctly. SO I just used the absolute path in the OSGEO4W Shell: C:\Users\ricckli\.qgis2\python\plugins\qgis2leaf>make pyuic4 -o ui_qgis2leaf.py ui_qgis2leaf.ui make: pyuic4: Command not found make: ...


2

The PyQGIS Cookbook explains what files are common in QGIS plugins. As you can see there, you would only need three files to run a minimal plugin: __init__.py metadata.txt mainPlugin.py Regarding the QGIS Plugin Builder, I suggest you to read the official documentation to get an idea of how it is structured. I actually prefer not to use such plugin, ...


0

For reference, if you use QGIS >= v.2.4, you can set the selection color from the QGIS Python console in this way: from PyQt4.QtGui import QColor iface.mapCanvas().setSelectionColor( QColor("red") )


0

The problem with your procedure is that you probably used two different Processing versions, v.2.2.0-2 on your computer and v.2.6 on the other computer. Since v.2.6, Processing comes as a core QGIS plugin. It is installed in /usr/share/qgis/python/plugins/ (C:\OSGeo4W64\apps\qgis\python\plugins on Windows) and not in ~/.qgis2/python/plugins/ ...


0

First of all, to actually run a saga processing scrip use processing.runalg("saga:algorithmname", parameter1, parameter2) Basically Qgis can do two things: (1) Perform mathematical operations with rasters -> use saga raster calculator from processing toolbox A thing that can help you is that you can refer to the grids as a,b,c etc. a+b will add two ...


2

There are several ways to do this, but maybe the simplest is to use os.rename(). Loop through file_list and rename according to whatever algorithm you're using. For you example (untested, try on a copy of your data first): for file in file_list: name_parts = file.split('_') # = ['2014516', 'MS', '005.xyz'] pre = '_'.join([name_parts[1], 'e']) # = ...


1

I am a little unclear about how the original filename will translate to the new file name, but here is a python snippet that should put you in the right direction: import os for file in os.listdir('.'): if file.endswith('.xyz'): a = file.split('_') ## for months 1 to 9 if len(a[0]) == 7: print 'working on ' + a[1] + ...


0

I am using gdal_grid to generate rasters from point data using Python. Right now I am dealing with the same issue as you do, so I am testing as much as I can before taking my chance with another library. My advice would be to use the options for multiple cores and as much cache as you can give. --config 'NUM_THREADS=ALL_CPUS GDAL_CACHEMAX=2000' The gdal ...


1

I managed to get the script to run by copying the processing folder from my computer and placing it in the .qgis2 of the other computer. It seems there's something missing in the other computer although I'm not sure what. I did notice that when I installed QGIS via the OSGeo4W installer, there were no plugin folders in \.qgis2\python\plugins\. They only ...


2

If you work with ArcGIS 10.1 SP1 or above, you can use the arcpy.da.Walk() function to list Esri or other GIS data formats recursively. Use the type parameter to restrict the search to Esri GRID files: import arcpy, os workspace = r"C:\directory" output_folder = r"C:\other_directory" walk = arcpy.da.Walk(workspace, type="GRID") for dirpath, dirnames, ...


0

You might have to dig into that extra folder after listing all of the info folders using python. Use the os module to list all of the info folders, then for each folder look for an extra folder. Inside that extra folder, look for one of the extentions that are stored with a GRID file (like .adr)


1

The initial path setting might be off. QgsApplication.setPrefixPath("C:\\OSGeo4W64\\apps\\qgis", True) Maybe try setting this path to a variable, then use the variable in the set path setPath = 'C:\OSGeo4W64\apps\qgis' QgsApplication.setPrefixPath(setPath, True) OR maybe this? QgsApplication.setPrefixPath(r'C:\OSGeo4W64\apps\qgis', True) I hope this ...


2

You should read the whole thread of http://thread.gmane.org/gmane.comp.gis.gdal.devel/38725. Test image was an aerial photo (424 MB) and methods with best compression were: Lossless JPEG2000 (197 MB) DEFLATE compression with PREDICTOR=2 (280 MB) LZW compression with PREDICTOR=2 (307 MB) However, your images seem to suit very well for LZW compression and ...


2

You can access QGIS toolbar buttons (actions) by using the iface object (docs here). From those actions you can create a QActionGroup and add your custom action making all actions mutually exclusive. The following code snippet shows you how to do it, step by step. I've put the code snippet in the initGui(self) method of my test plugin. # Make sure your ...


1

You do not need to do replace. You just need to modify the format string. "Convert" = "{}{:02d}{:02d}".format(!SignatureYear!,!SignatureMonth!, !SignatureDay!)


0

This is a little difficult because of the branching nature of stream networks. Over 1km you will likely need your solution to be able to make a choice of which branch/tributary to trace up. I suggest calculating Horton stream order for your stream lines and then dissolving features based on the Horton order field. Once that is done you can create a point ...


1

The problem you are facing is due to not valid layers constructed by QgsVectorLayer(). If you print shapefile.isValid() you will be getting False for all layers. This happens because you need to set the QGIS prefix path and initialize QgsApplication before using QgsVectorLayer in standalone scripts/apps. The solution for your problem is to: Add these ...


1

If you mean QGIS default toolbars, well, those are written in C++ and you can find their creation and configuration here (C++ file) and here (Qt4 UI file). All actions (buttons) inside QGIS toolbars are written in C++ (except by plugin buttons) and you can find them in the QGIS source code as well. If you want to get a reference of a QGIS toolbar in Python, ...


0

Yes, it's possible to customize the QGIS UI from a Python plugin by both adding your own toolbars and menus as well as removing/hiding QGIS toolbars and menus. These would be the code snippets for each situation: Adding a toolbar: # Add a custom toolbar self.toolbar = self.iface.addToolBar( "My tools" ) self.toolbar.addAction( self.action ) Removing a ...


0

As you can see in the QGIS API docs, the featureAdded signal only passes one argument, namely, the feature ID. When you create your slot, you must use a single argument (besides self), this way: def logFeatureAdded(self, fid): message = str( fid ) QgsMessageLog.logMessage(message) QApplication.beep() This should solve your problem!


1

I've tested the attributeValueChanged SIGNAL in a created-from-scratch test plugin using QGIS v.2.6.1 You can connect the SIGNAL to your slot this way (I did it in my run() method): def run(self): self.lyr = self.iface.mapCanvas().layers()[0] self.lyr.attributeValueChanged.connect(self.mySlot) And then, you have two options to write your slot ...


1

So the event that works IS attributeValueChanged. I simply needed to add some arguments to my function, as mentioned by another user. This works now: def myFunction(self): self.myLayer.attributeValueChanged.connect(self.myOtherFunction) def myOtherFunction(self, fid, idx): self.myLayer.dostuff self.dlg.show()


1

Pythonic way of what Brad Neson and help for GISKid too.. import arcpy arcpy.env.overwriteOutput=True fc= r"C:\Users\USER_NAME\Documents\ArcGIS\CWS.shp" ## path to your input feature class output = r"C:\Users\USER_NAME\Documents\ArcGIS\CWS_Unique.shp" ## path to your output feature class ...


0

I've worked out how to do this albeit in a fairly simple manner. I wanted to create a multivalue parameter where I add many FeatureLayers and then choose an ID field for each layer. I've got it working but I was unable to work how to make the field a drop down list, so a user has to enter a field name manually. Here is the interface: If anyone has ...


1

To split a string into a list of numbers you can use regex in this way as well: import re s = re.split('[a-z]+', '123ab987') print s ['123', '324'] and for your , problem you can use this regex: s=re.split('[a-z|,]+', '123bc324,1,3,4') print s ['123', '324', '1', '3', '4'] but you have to be a bit carefull. Because if the first/last character is also ...


2

I would use regular expressions for this. You can use this in an arcpy script to update the field by setting the m.group(index) to be the field value. It is of str type. import re reload (re) r = re.compile("([0-9]+)([a-zA-Z]+)([0-9]+)") m = r.match("123ab1234") if m: print m.group(1) print m.group(2) print m.group(3) else: print "no ...


2

This is a known issue. The current version of scipy (actually numpy) is not compatible with python distribution that comes with ArcGIS, although theoretically they should. The core reason is that scipy is not pure Python (for speed) and hence it matters which API against which things have been compiled. I had that issue and I never found a compatible ...


0

even if the answer is already found i would like to point to an nice article about adding layers to Geoserver using curl for the users who are still searching for some more information about that: http://boundlessgeo.com/2012/10/adding-layers-to-geoserver-using-the-rest-api/


1

As per this question I think you (or your IT staff) need to run the autorun.exe application, it will launch the startup window (otherwise known as the Quick Start Guide) of the 10.2 installation for Desktop. From here you can install the 64-bit BGP. I realize that this refers to 10.2 not 10.2.2 but I think it is the same process. Just a side ...


3

Not very elegant but this should work: output = Dir + "\\" + (fc[:2]+"_"+fc.split("_")[1][:-4])[:13] By the way, not sure if there was an indentation issue when you pasted the code in GIS.SE, but the for loop should be something like: # Loop for fc in fcList: output = Dir + "\\" + (fc[:2]+"_"+fc.split("_")[1][:-4])[:13] # Process: Polygon to ...


3

As you can see in the QGIS API docs, when you call getFeatures() with no arguments, QGIS gets a QgsFeatureRequest() by default. That is, QgsFeatureRequest() is the default value for the first argument of getFeatures(). You can choose whether or not passing it, the result is the same. Also from the docs, by calling QgsFeatureRequest() you: construct ...


4

You are trying to put a string into the insertRow method, but that method expects a list or tuple. The insertrow method first counts the items in the list or tuple to see if the item count matches the row field count, but since a string item count is most likely 0 it always fails to match up with the field count of the row (i.e., 1). So instead try ...


5

You have to insert a list, you're inserting a single value. for uv in uniqueList: cursor.insertRow(uv) should be for uv in uniqueList: cursor.insertRow([uv])


1

Have you seen this snippet: Modify Features It is possible to either change feature’s geometry or to change some attributes. The following example first changes values of attributes with index 0 and 1, then it changes the feature’s geometry fid = 100 # ID of the feature we will modify if caps & QgsVectorDataProvider.ChangeAttributeValues: ...


2

I prefer the latest builds from Gisinternals. Note that the link has recently moved to http://download.gisinternals.com/. It gives you always the latest Windows builds of GDAL and PROJ. The binaries linked on the PROJ page are version 4.46, and quite outdated. The current version of PROJ is 4.8.0 PyProj might be a benefit if you do things programmatically, ...


0

Use affine to load the world file, translate it from center to corner reference, and reorder the coefficients for GDAL. import os import affine from osgeo import gdal gdal.UseExceptions() ds = gdal.Open(input, gdal.GA_Update) gt = ds.GetGeoTransform() if not gt: # guess the name of the world file, if it exists inputwf = os.path.splitext(input)[0] + ...


3

Using rasterio: import rasterio with rasterio.open('sample.tif') as r: ar = r.read() The ar array has 3-dimensions [band, row, col]


1

The gdal.Dataset class also has a ReadAsArray method which will read multiband rasters into an ndarray. For example: >>> ds=gdal.Open('multiband.tif') >>> print ds.RasterCount, ds.RasterYSize, ds.RasterXSize 4 256 256 >>> nda=ds.ReadAsArray() >>> print nda.shape (4, 256, 256) Note: the code in your question is not ...


1

Right, I've tested your script and, as you say it doesn't throw anything (not even errors) when I run it. Try instead this script, it works for me on Linux, emulating your scenario (moving processing folder to my script folder): # Prepare the environment import sys from qgis.core import QgsApplication from PyQt4.QtGui import QApplication app = ...


2

I would use below code-- If you have access to "Data Access Module" import arcpy,os,sys pattern = 'fish_46.shp' folder = 'C:\Users\USER_NAME\Desktop\delete'## root folder field = 'Id' ## your field where calculation to be applied files_process = [] for root,dirs,files in os.walk('C:\Users\USER_NAME\Desktop\delete'): for filenames in files: if ...


0

Why don't you just use arcpy.SpatialReference(WKID)?


4

The error is due to the fact that you're using a tuple (returned from your cursor) as your input for your MakeFeatureLayer_management. This function requires a feature class or layer as its input. If you're wanting to know where your layers lie in relationship to a polygon, I suggest using a spatial join as opposed to a cursor. It is faster, and a good ...


4

Here's what you need to do, with comments: # Reference the MXD containing your layers. # If you're doing this in the Python Window of the MXD, # use the "CURRENT" keyword instead of providing a path # to the MXD you already have open. mxd = arcpy.mapping.MapDocument(r"C:\Users\Daimon Nurse\Desktop\Zonetrial.mxd") # mxd = ...


1

By using the new Layer tree (aka legend or ToC) added by Martin Dobias since QGIS v.2.4, you can load a layer to the top of the ToC following these steps: Get a reference of the layer tree root = QgsProject.instance().layerTreeRoot() Create the layer object from PyQt4.QtCore import QFileInfo fileName = "/path/to/raster/file.tif" fileInfo = ...


0

You can try to remove whitespace, tab (\t) etc from the dictionary with something like: new_dict = {k:v.strip() for k, v in diamResDict.iteritems()} and then passing the new dict to setEditorWidgetV2Config(diamidx, new_dict)


0

You have need to add layer.updateExtents() just after layer.commitChanges(). It is necessary if features are added or deleted to the layer as mentioned in the QGIS API Documentation! Hope this helps!


1

What you need is exactly what Load Them All plugin does. It can load several vector or raster files at once from a base directory you set. Additionally, the plugin can: Load rasters of a particular format (e.g., only .tif) Create groups in the ToC to reflect your folders in the hard disk. Groups can be nested. Turn off loaded layers. Load layers based on ...


0

I may be able to weigh in here, as I did a similar cemetery project a few years back. It is not too difficult to use a python script to pass variables through to an SQL statement to select certain graves, but it can become very frustrating if you are unfamiliar with the syntax. It is a good idea to search this site for hints like How to include variable in ...


0

Okay so I finally figured this out. It was a stupid mistake on my part. The files I had in the specified folders were actually feature classes and not datasets. Anyway it is not possible to create a dataset inside a folder. It can only be done inside a geodatabase. So for someone who knows their way around with ArcGIS, they could have noticed that I had just ...



Top 50 recent answers are included