Tag Info

Hot answers tagged

5

I don't think you can remove features from a selection layer once it's been created, but the workaround that I usually use is to create a new selection layer from your existing one: Select the features in your selection layer that you want to remove. Open the selection layer's attribute table and click Switch Selection, which will make all the features ...


4

The Extent object supports a 'disjoint' (i.e. does not intersect) method. Try something like: for mxdname in arcpy.ListFiles('*.mxd'): print mxdname mxd = arcpy.mapping.MapDocument(os.path.join(env.workspace, mxdname)) df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] for lyr in arcpy.mapping.ListLayers(mxd, "" ,df): if ...


4

Actually, logically Union is the the area shared by both plus the area of each of the two layers not shared by the other. Therefore the area returned must be equal to or greater than the area in the largest layer. This is what you are seeing. The way to extract just the portion where the land use layer and the limit layer intersect is to use the Intersect ...


3

In Python a backslash is an escape character. In order to put a backslash in the string you need to need to put another backslash next to it to stop it from forcing a new line. myString = "this is\\ a string with a backslash" I can see your paths are set correctly but maybe the strings you are parsing only have a single backslash. You can solve this ...


2

Finally I found the answer : using the QgsLegendModelV2()class, and its functions inherited from QgsLayerTreeModel : "index(i,j)" to select each legend item and "rowcount" to obtain the rows number. All in a "for x in xrange" loop. That gives: for i in self.composition.items(): if isinstance(i,QgsComposerLegend): legend = i for i in ...


2

I think the issue is that you are trying to save a service layer. I couldn't tell you why it doesn't work through Python, but I have had similar issues with database joins and symbology. They work when I do it by hand, but not when I try and script it, it doesn't work. Even though it seems like it's the same task. In these situations I had to move to ...


2

One way to do this is to create a polygon feature layer of the dataframe extent, then you may select features in your dataframe to see if they intersect the extent polygon. http://anothergisblog.blogspot.com/2011/06/dataframe-object.html mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] layers = ...


2

You need to filter away those map documents which contain "land use" in their names. It is better to test and if the evaluation gave us "false", proceed with the processing. env.workspace = r"C:\Project" Layer1 = arcpy.mapping.Layer("abc.lyr") for mxd in arcpy.ListFiles("*.mxd"): if 'land use' not in mxd: print mxd mapdoc = ...


1

You are not providing the code required to add a layer to the map at all. You need a feature layer from the shapefile and then save it on disk as the .lyr file. inputLocationsSavedFcFeatLyr = arcpy.MakeFeatureLayer_management(input_locations_fc,"Stops") arcpy.SaveToLayerFile_management(in_layer=inputLocationsSavedFcFeatLyr, ...


1

I think you correctly understand the first two options. You can specify options at the widget level (global options) which will be applied to all operational layers and you can specify the same options at the individual operational layer level to override widget level configuration. Finally, you can also use the LayerControl in your own widget by ...


1

Ok, the first error is easy to avoid. It's failing because you are trying to find the datasource of a group layer, and group layers don't have data sources. Filter the group layers out by doing this: for lyr in arcpy.mapping.ListLayers(mxd, "" ,df): if not lyr.supports("DATASOURCE"): continue #further code here for non-group layers ...


1

A few days late, but here's a workflow that did what I needed. Open up qGIS ( http://www.qgis.org/en/site/ ) Set up your projection under project -> project properties (I use NAD83 / Alberta 3TM ref merid 114 W EPSG:3776 but hey whatever look you want try a few) and make sure on the fly CRS transformation is checked. Add your .shp : Layer -> add vector ...


1

Does the problem also occur in the Python Window? Like: import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") df1 = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.ListLayers(mxd, "*", df1)[0] arcpy.SaveToLayerFile_management(lyr,"""D:/test.lyr""",'#') (I am using 10.0 so there are only 3 arguments for SaveToLayerFile_management())


1

Needed to exclude the last two layers from the layerswitcher by adding a -2 to length like so: for (i = 0, ii = layers.length-2; i < ii; ++i) layers[i].setVisible(i==checkedLayer); This makes the layers visible on load, so set them to false like so: layers[4] = new ol.source.TileWMS({ Visible: false, source: new ...


1

The functionnality has been added recently, see these 2 examples : Tile load events , Image load events


1

This is how I would form the query you're asking about using ST_MakeEnvelope() and the && operator. You can request whatever field data you want, in addition to the geometry in GeoJSON format using ST_AsGeoJSON(). Also I recommend taking advantage of that function's ability to specify a max decimal precision value. Here I'm requesting geometries ...



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