Hot answers tagged

11

Decrease the height of the the legend box to zero: In the example below you can see that I got a line legend even if my data is polygon. Right-click on your legend, click on properties Go to the Legend tab and change the height into either 1 or 0. That will reduce all polygon layer patches in the legend to lines. You can also set this property per-layer, ...


10

I used to work in that exact same environment (the exact same one!). I have not done any benchmark testing but my sense of this is that number of layers in the project doesn't have much effect by itself. In my experience the labeling and number of features is a much bigger issue than the number of layers (especially if many are turned off). I used to have ...


9

The workaround I usually use for any situation in which I want to customize the legend entry for a layer is to create a dummy layer which is only used in the legend, and not displayed on the map. So in your case, create a new line layer using a line shapefile with no features in it, symbolize it however you want, and add that to your legend. The new layer ...


8

Out of the box, field calculator does not support spatial joins across feature layers. But, if you have a look at NathanW's post on the function editor for qgis expressions you will be able to make out that we can script our own data interaction. The following script will allow you to express what you're after. It works by iterating through all features ...


8

A translation is an affine transformation. Next code includes this kind of transformation and it works well at the Python Console of QGIS for creating a memory layer with the displaced layer (building1). registry = QgsMapLayerRegistry.instance() n = registry.count() layers = registry.mapLayers().values() layers_names = [ layers[i].name() for i in ...


7

I would first check out Best Practices Using Citrix XenApp and ArcGIS, a guide put together by ESRI. For a previous client, I went through quite a bit of performance troubleshooting with ESRI and our Citrix environment. Below are the highlights from those conversations: I'm assuming you are going to be making edits in a tight area (zoomed in pretty ...


6

You need to understand that there is no such thing as a QGIS Shapefile, A Shapefile is a shapefile regardless of what software was used to create it. According to ArcGIS Online Help: A shapefile is an Esri vector data storage format for storing the location, shape, and attributes of geographic features. It is stored as a set of related files and ...


5

Yes, very simple: Just use the Categorized Symbology. If you do not have any attributes, you can just use $id as your "Column". Result:


5

This is a great question, I had to do something similar recently but with a much smaller dataset, so I was able to use a simple intersection with some extra visual quality checking and it was fine. But here's an idea for this, though I don't have code, and it's kind of a hefty process. Definitely test with a sample from the full dataset first. You can ...


5

Metadata is one of those things that is generally seen as "well, I know I probably should, but, is it really worth the time...?". And the answer is, for most of us, at least the basic parts of it probably should be. There is a LOT of information that can be put into metadata, depending on what standard you're using. However, a lot of that may not be all ...


5

With the next release QGIS 2.14 this will be fixed. If you have python knowledge, it should be straightforward to port the code linked to above to a small python snippet that copies joins and virtual fields from one layer to another. Please note that this is not a bug tracker and instead you should raise the awareness on the issue page you linked to, on ...


5

If you read the syntax section of the select by location tool you will see that it takes Feature Layers as inputs. A string which is a path to a shapefile is not a Feature Layer object. If you think about it how can you represent a selection of polygons with nothing more that a full path string to some file? A Feature Layer has this ability, it is called a ...


4

To find the name of the dataset as stored in the database use IDataset.BrowseName. IDataset.Name will give you the layer name as it is named in ArcMap. You should also test that the layer can be cast to IDataset: If TypeOf currentLayer Is IDataset Then... Things like group layers don't implement IDataset, and will cause an error.


4

You could just use a different version of google-maps-api, for example http://maps.google.com/maps/api/js?v=3.5&sensor=false Example: http://jsfiddle.net/expedio/sodserrw/ The same example with your Google-API address (https://maps.googleapis.com/maps/api/js ) is also not working: http://jsfiddle.net/expedio/zx4k29k5/ EDIT1: In the meantime this ...


4

The best way to save all of the settings of a layer (or multiple layers) in a map document, is to create a layer package. Select all of the layers you would like to save in the package Right-click one of the selected layers and click Create Layer Package Follow the Layer Package wizard, making sure to fill in all of the entries (such as summary and tags). ...


4

The reason why this code is failing is down to you missing () off the save method on your MXD, so you were not saving your changes. This code worked for me import arcpy print "This script turns off the following layers:" mxd = arcpy.mapping.MapDocument(r"C:\Scratch\newcode.mxd") for lyr in arcpy.mapping.ListLayers(mxd): print lyr.name lyr.visible = ...


4

TL;DR To get all features of a layer by the layer name you do not need to activate it. Just use layer = QgsMapLayerRegistry.instance().mapLayersByName( name )[0] poles = layer.getFeatures() Active Layer First of all, you do not need to care about the active layer. The active layer is the layer which is currently selected in the layer tree and ...


4

Right click add the labeling toolset Click on 'label manager' the icon next to the Labeling drop down menu... When the label manager appears choose the layer you want to work on on the left panel, then the label field from the drop down menu on the right. Then at the bottom use the 'SQL Query' option to query the records you want to label.


4

One way to do this: Create a function, that will set your layer on top (I guess there are a few solutions, you can use canvas.setLayerSet([top_layer, bottom_layer1, ...]) or something). Choose a signal from the list: http://qgis.org/api/classQgsMapCanvas.html It can be layersChanged() or something that occurs after you add a new layer or change hierarchy. ...


4

The reason you get the NaN-values is the following. If you look at the extent properties, described on the following page http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/extent.htm, you see the object has four more properties. These properties aren't set by default, so you'll get the NaN 'error'. If you only want to display the XMin, YMin, ...


4

To answer your specific question "How to iterate through layers of an MXD?" mxd = arcpy.mapping.MapDocument("CURRENT") # Uses your currently open MXD df = arcpy.mapping.ListDataFrames(mxd, '')[0] # Chooses the first dataframe for lyr in arcpy.mapping.ListLayers(mxd, '', df): # Loop through layers # Any tools you want to run on each layer go here ...


4

The short answer is no, not without accessing arcobjects. You would need to install comtypes module to access the interface that would return that information.


4

You can use the following code in the Python Console which iterates through each loaded layer (regardless if they're selected or not) and deletes the field with the name you specify. Just replace field_name with...a field name: for layer in QgsMapLayerRegistry.instance().mapLayers().values(): with edit(layer): fields = layer.pendingFields() ...


3

You could use this function: def laylist(): l=[] for layer in iface.mapCanvas().layers(): item = layer.name() l.append(item) print l or this one, if you only want to get layer names printed: def laylist(): for layer in iface.mapCanvas().layers(): print layer.name() Tested in the QGIS Python console. EDIT: In ...


3

Was just doing this yesterday. You should just be able to call findAndReplaceWorkspacePaths on your mxd object. Below will loop through the dict objects in the workspacePathMap array and replace old with new: mxdFn = r"C:\path\to\original\mxd.mxd" newMxdFn = r"C:\path\to\new\mxd.mxd" workspacePathMap = [{ "old": r'C:\path\to\old\conn.sde', "new": ...


3

There is this example at github https://github.com/clhenrick/BushwickCommunityMap It uses the createLayer and createSubLayers options to define different cartodb layers into the map and then it toggles them using buttons and checkboxes that are inside a panel.And also, the layers are added or removed depending of which part of the story you are. It uses ...


3

Assuming all your text files are into the same directory, you can run this code snippet in the QGIS Python console to get your files loaded as individual layers in QGIS: import os.path, glob layers=[] for file in glob.glob('/tmp/xy/*.txt'): # Change this base path uri = "file:///" + file + ...


3

Combine all text files in a windows directory with the copy command: copy *.txt river.txt On Linux use the cat (concatenate) command: cat * > river.txt Then in QGIS for the merged text file use 'Add Delimited Text Layer' button.


3

In ol3 version 3.10.0 things have changed. So is more clear than older versions but still more complicated than ol2. So for TILE (ol.layer.Tile) layers your code snip should look like: //declare the layer var osmLayer = new ol.layer.Tile({ source: new ol.source.OSM() }); //asign the listeners on the source of tile layer ...


3

based on srussking answer I wrote the following code assuming the main map object called map and it is a global var, I preferred using find layer by name and not by id, here is my code: function moveLayerBefore(old_idx, new_idx){ if((old_idx === -1) || (new_idx === -1)){ return false; } layer = map.getLayers().removeAt(old_idx); ...



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