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. 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: ...


1

Below code works for me. I do two types of filtering (firstly select all features name start with "One" and then those features from these selected features which have word "domain" in the name) to select features and run merge operation on that features. import arcpy arcpy.env.overwriteOutput = True arcpy.env.workspace = ...


0

You can enable this button under the settings button within the Python console / editor.


5

I can crush this down to 3 lines of code, no cursors required! import arcpy arcpy.SpatialJoin_analysis("Site", "points","in_memory/points_SpatialJoin", "JOIN_ONE_TO_MANY", "KEEP_ALL", "", "INTERSECT") arcpy.Statistics_analysis("points_SpatialJoin", "in_memory/stats", "Join_Count SUM","Id") Then simply sort the table to find the polygon with most points.


5

The following approach uses a Search Cursor and Python dictionary to perform the following workflow: Select points within each polygon feature Update dictionary with key (OID) and value (point count) for each iteration Find max point value and corresponding OID and write to a text file import arcpy, os points = r'C:\temp\mytest\points.shp' polys = ...


0

The following code contains more than you need, but it will show that you need to specify or create a blank mxd, then specify a data frame, then activate that data frame then add your layers/shapefiles with optional symbology specified ''' mxd_create.py Author: Dan.Patterson@carleton.ca Purpose: create a base mxd and populate it with default values ...


1

You're improperly using the arcpy.mapping.Layer function. arcpy.mapping.Layer takes a Layer File (*.lyr) saved on disk and returns a Layer Object from that. Layer Objects have methods which you can use to change various properties of the layer, such as its visibility, transparency, definition query, etc. You're giving it a shapefile. Hence the error, ...


0

The error says something about duplicate names. It seems that you must clear the QComboBox you are using, before loading the layers again. You can clear a QComboBox by calling its clear() method. In your case, it would make sense to edit the run() method, so that every time the user launches the plugin (for example, by clicking the plugin's main button), ...


1

You can clear a QComboBox by calling its clear() method. In your case, it would make sense to edit the run() method, so that every time the user launches the plugin (for example, by clicking the plugin's main button), the QComboBox is cleared before layers are added to it: def run(self): """Run method that performs all the real work""" # show the ...


1

Try to move the below part of the code from the run to the initGui function. layers = QgsMapLayerRegistry.instance().mapLayers().values() for layer in layers: if layer.type() == QgsMapLayer.VectorLayer: self.dlg.featurecombo.addItem( layer.name(), layer )


0

That line of code run in the Python window of ArcMap should always work. To see this close and restart ArcMap and then try just that line of code in the Python window. Open any map and re-run that line and you should see that it still works. The error that you are seeing indicates that you have provided arcpy.mapping.MapDocument() with a value that is ...


2

This help topic should get you started -- basically you embed your toolbox in a Python package and install it in your local Python installation. Then your tool should show up automatically under system toolboxes.


1

You should add the toolbox to the Normal.mxt - and copy this customized Normal.mxt to each user's install files location. See the last section of the Fundamentals of saving your customizations help page for more details. So if I understand correctly (never tried myself): When opening ArcMap, ArcGIS uses the Normal.mxt from the user profile (usually ...


0

The Describe function is well documented at ArcGIS Resource Center. It is a quit big topic to define in here. So, have a look at the given link. In your case, the item "PAD_HI_250extent" doesn't have fields. As pointed by MWrenn above. It is wise to check the desc type first before calling its properties.


0

Here is ready to go code to find new latitude and longitude for given parameters (lat, long, bearing, distance). Hope that this will help. # required import import math # standard earth radius EARTH_RADIUS = 6371.00 def add_distance(self, lat, lon, bearing, distance): # convert Latitude and Longitude # into radians for calculation latitude = ...


1

This is more of a few tips than an answer. You mention that it takes a while to run. I have to things to point out that can save some you some time. 1) Your code goes through the wells once; no need to do it twice. You can get the list of well owner's names from the well_owners.values(). That's a python list of all the values in the dictionary. In your ...


0

So, I solved this problem by saving the orps matches for each well in match dictionary as a list, and then selected each one using the list.pop() method, which treats the list as a stack and retrieves and removes the bottom value. The code above is the same, except... matches = {} x = 0 # Create search cursor which will iterate through wells with ...


1

Your code is indicating that "name" does not exist in the object you are looping through. Try: import pprint and then in your loop: pprint.pprint(layer). If layer does not exist, then you will know what is causing your error and what items in your object are available for parsing. Stay curious my friend.


3

If you use Shapely, transform your polygon into a LinearRing or a LineString from shapely.geometry import shape import fiona Multilines = MultiLineString([shape(line['geometry']) for line in fiona.open("lines.shp")]) Poly = shape(fiona.open("one_poly.shp").next()['geometry']) Multilines.intersection(Poly) <shapely.geometry.multilinestring.MultiLineString ...


1

I don't have a Windows OS to test it, but I'm pretty sure the problem is in the path to your ShapeFile. Make sure the path is correct and try with slashes (/) or double back slashes (\\).



Top 50 recent answers are included