Tag Info

Hot answers tagged

4

Don't use a message box for this. It is not what they are for and will make people cry. Use the message bar. iface.messageBar().pushWarning("title", "message") or iface.messageBar().pushMessage("title", "message") http://qgis.org/api/classQgsMessageBar.html


4

This is the precise use case for a geoprocessing service. Write your script and add it to a geoprocessing toolbox on the server as a script tool. You can test it on the server while developing the script by hard coding the parameters. Once you're comfortable with your code, replace those hard coded parameters with arcpy.GetParameterAsText(), add to a ...


4

You are missing date2 in dictIN: Change it: dictIN= [{'field1':"test1",'date1':'01-02-2015','date2':''},\ {'field1':"test2",'date1':'01-02-2015','date2':'01-02-2015'},\ {'field1':"test3",'date1':'','date2':''},\ {'field1':"test4",'date1':'01-02-2015','date2':''}] Full code is: dictIN= [{'field1':"test1",'date1':'01-02-2015','date2':''},\ ...


4

Without seeing your error message it is hard to be certain, and I prefer to use arcpy.CreateFolder_management() in place of os.makedirs, but try changing: os.makedirs(os.path.join(PF,row.FID)) to os.makedirs(os.path.join(PF,str(row.FID)))


3

First, I Suggest you to use SearchCursor from data access modulde for better performance. rows = arcpy.da.SearchCursor(featureclass) The problem with you code is that you are joining string with int (FID). just convert it to string. os.makedirs(os.path.join(PF,str(row.FID)))


2

I use PyCharm for a period and and it works great for me.


2

The tool works well. I modified slightly the code for producing only 3 raster (10, 20 and 30 Pixel Size) with a point shapefile with 5 features. import processing RasterPixelSize = (10.0,20.0,30.0) i=1 for rps in RasterPixelSize: processing.runalg("gdalogr:rasterize",\ "/home/zeito/pyqgis_data/point.shp",\ "id",None,1,rps,rps,6, ...


2

I got your model running using a shape file instead of a spatialite db. Can you try a shape file first, to see if it's work. Then perhaps it would be easier, to identify any Spatialite problems. I also added my model code, so you can check against your model. I got another Python error than you using Spatialite: Algorithm testModel starting... Prepare ...


2

You are probably setting a connection between a SIGNAL (button clicked) and a SLOT (your method showTable) every time your plugin is open (run() method?) and you are not disconnecting such SIGNAL/SLOT when your plugin is closed. This leads to a new call to showTable() every time you open your plugin, because there's a new connection calling it. A couple of ...


2

I didn't find the option from the API, but you could mimic such behavior this way: I assume there are selected features already, so get their Ids: lyr = iface.activeLayer() selIds = lyr.selectedFeaturesIds() You said you have an expression, let's say: expr = QgsExpression( "\"NMG\" = 'CALI'" ) Now, get feature Ids that match your expression: it = ...


2

I think your best bet will be to create a custom button that saves your map document - mxd.save() - as well as whatever operations you wish.


2

You're mixing returning values from a function and assignment. You have to return the modified value, not assign it to the old variable. The correct format for the pre-logic script code would be: def mycalc(ADM2_NAME, Projects): if ADM2_NAME == "Bo": return (Projects + 1) else return Projects Although there is an even better (shorter) way of ...


2

The script uses a somewhat crude method to guess which point within each polygon is furthest from any of the other points also in that polygon. For each polygon, it calculates the distance between all possible pairs of points, then finds the 5 longest distances and finds the point that was the most common in those 5 pairs. It writes these "far points" to a ...


2

Nathan W is correct. But, if you still want to display a QMessageBox with autoclose behaviour. You can do it bu subclassing the QMessageBox like this: class CustomMessageBox(QMessageBox): def __init__(self, *__args): QMessageBox.__init__(self) self.timeout = 0 self.autoclose = False self.currentTime = 0 def showEvent(self, QShowEvent): ...


2

Why do you think is incorrect? Supose you have this point and line: ls = LineString([(0,0),(1,1),(2,0),(3,1)]) p = Point(2,-0.2) By using ls.project(p) you'll get de distance from the beginning of the line to the nearest point. 2.828 meters, the distance of this part: I think this is what you are asking. A second option is to include, to the ...


2

edit: I didn't quite get what you were trying to do, but this should work as a sort of cumulative function. Untested (there may be some errors with indices): import arcpy, os, string fc = "D:\\path\\exampless.shp" fields = arcpy.ListFields(fc) fieldNameList = [] for field in fields: if field.type in ("Double", "Integer", "Single", "SmallInteger"): ...


1

Not seeing your code, this may not work for you, but you can try to use the Python list selector: for row in sorted(arcpy.da.SearchCursor(fc, [f1, f2]))[:5]


1

If you have set, mxdPath = "\\server1\d$\arcgisserver\directories\arcgissystem\arcgisinput\Unknown_Unknown\poly_test.MapServer\extracted\v101\POLY_TEST.mxd" Then you should put r before paths in python or escape BackSlashes with another backslash. option 1: mxdPath = ...


1

You have to calculate these two values. Georeferency is a tuple with 6 numbers: X coordinate of origin (upper left corner), horizontal resolution, rotation of X axis, Y coordinate, vertical resolution, rotation of Y axis. You can use this pattern to calculate indexes: COL = (X - OX) / RX ROW = (Y - OY) / RY X, Y are coordinates of pixel OX, OY are ...


1

This situation is always confusing. There are two types of 'Layers' in arcpy. The feature layer, which you are creating, isn't the type you can add to a map. The other is the layer generated from the mapping module. This is the one you want. Instead of MakeFeatureLayer, try this: NewLayer = arcpy.mapping.Layer(r"W:\Source.lyr") Then you can perform ...


1

You should check, longName property of the layer to see whether it has backslashes or not: Here is the snippet: import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") for lyr in arcpy.mapping.ListLayers(mxd): if lyr.isGroupLayer == True: if lyr.longName.find('\\') == -1: print lyr.longName I hope it helps


1

First, let it be known there are a number of ways someone could go about accomplishing roughly the same goal in this case. For me personally, especially for someone less experienced with arcpy, it would likely be simplest to do roughly the following workflow Convert the CSV file to Table in GDB Join the Table to Point Feature Class Make Feature Layer ...


1

Having trouble adding a comment from my phone, so posting here... I would recommend that you become familiar with JSON, if not already. I would develop your service to return a JSON object that contains key/value pairs that hold the results of your calculation. That JSON object can be easily parsed in your javascript, placed into existing html or used to ...


1

You can overwrite the close function of your UI as well, that the plugin is reloaded every time you close it. def closeEvent(self, event): qgis.utils.reloadPlugin('YourPluginName') This will reload the plugin completely and will empty all your boxes. In this way you don't have to care about clearing the boxes because the plugin will always load only ...


1

Both underdark‚ô¶'s and gcarrillo's replies provide valid answers. How exactly the issue should be handled however depends on the use case, and if necessary, options should be provided.


1

In my opinion you should empty the combo box before populating it. The rationale behind that is that the layer might have changed so it's not a good idea to set a flag and ignore everything that might happen afterwards.


1

I suggest you to write a proxy class in managed C++ if this is an option for your. Realistically, you might need to perform the kind of operation that takes longer in .NET or Arcpy(large iterations of small operations).You have the choice to write a proxy class in Managed C++ where you can place ArcObjects code that heavily uses the interop layer. Once ...



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