Tag Info

Hot answers tagged

11

If I got you right, the answer is yes, QGIS supports dynamic layer names. You would need to write a Python macro to be ran every time the project is opened. This would be the workflow: Go to on QGIS->Project->Project Properties and replace openProject() with the following Python code: def openProject(): import re, qgis iface = ...


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


6

It is not as easy as it used to be, but there are some helper methods for the collection. That should allow you to do similar things as ThomasG77 described above. Assuming you have a map named map, with 4 layers i.e. [base_layer, coastlines, heatmap, markers] Then you can get the collection via map.getLayers(), and the array of layers via ...


6

AndreJ and SS_Rebellious provide valid answers. However, there is another option which I find easier than creating the group and dragging layers in to it. You can select all the layers you want in your group (select multiple layers by holding down shift which selects everything between your first selected layer and the second one you click on, or hold ...


6

The reason you cannot edit these layers is because it is not a file. It is a map service. What you are seeing is a web service. A web service is data that is hosted on a server elsewhere, that is not your computer. Your computer is going out and getting the data live from OLIVER when you look at it in ArcMap. In this case the data you want to edit is ...


6

Assuming you use an ol.layer.Vector with an ol.source.GeoJSON you can use something like this: var vectorSource = new ol.source.GeoJSON({ projection : 'EPSG:3857', url: 'http://examples.org/fearures.json' }); var vectorLayer = new ol.layer.Vector({ source: vectorSource }); map.addLayer(vectorLayer); // show loading icon // ... var listenerKey = ...


6

GDAL suppports that so it should be possible for QGIS as well. However, I could not make it work with my QGIS 2.6.0. Perhaps there is just some missing step and somebody can point what it is. Test with GDAL and VSICURL gdalinfo /vsicurl/http://dl.maptools.org/dl/geotiff/samples/made_up/bogota.tif Driver: GTiff/GeoTIFF Files: ...


5

Split Layers by Attributes check out this python toolbox. Split Layer by Attributes, State Name, being the attribute you want.


5

Here's the ListLayers documentation ListLayers(map_document_or_layer, {wildcard}, {data_frame}) You can use a wildcard if you know the name of the layer. mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] road_layer = arcpy.mapping.ListLayers(mxd, "Road", df)[0] river_layer = arcpy.mapping.ListLayers(mxd, "River", ...


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


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


4

for QGIS 2.6 here is the code to identify each layer and group them #make the desired groups for layers root = QgsProject.instance().layerTreeRoot() group1 = root.insertGroup(0, "Group Point") group2 = root.insertGroup(1, "Group Line") group3 = root.insertGroup(2, "Group Polygon") #get the list of layers ...


4

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


4

Nick Ochoski is right about the SearchCursor, but there is a cleaner way to use it WITHOUT a while and manually calling next: import arcpy fc = "c:/data/base.gdb/roads" field = "StreetName" cursor = arcpy.SearchCursor(fc) for row in cursor: print(row.getValue(field))


4

http://qgis.org/api/2.2/classQgsSymbolV2.html#aa2c7db61d4234bddf3aa62f294ad6818 void QgsSymbolV2::setColor(const QColor & color) with python: myColour = QtGui.QColor('#ffee00') mySymbol1 = QgsSymbolV2.defaultSymbol(myVectorLayer.geometryType()) mySymbol1.setColor(myColour)


4

Try something like: map.getLayers().setAt(99, markers) The list of layers is in an object inheriting from an ol.Collection. See the API doc for it. Be careful, I'm pretty sure, you can't use arbitrary number like 99 in setAt: first arg is for the position in the array of layers and the second arg is for the layer element reference you want to move. To ...


4

First, feature classes don't have symbology attributes. Symbology is attributed to layers in ArcGIS. When you add a feature class to a table of contents in ArcMap, a layer is created, though not saved anywhere as a .lyr file. If you are having your users add a feature class to ArcMap that they then symbolize as desired, below is the way of saving that ...


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

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


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

First you need to make sure that your watershed are polygons. If not : feature to polygon. Then you can make the intersection (intersect_analysis) between your watershed and your lines. You'll end up with lines that have the fields of the waershed as an attribute table. You can then use summary statstics to have the total length for each watershed. Note ...


3

I think you should check that you are using the List By Drawing Order view of your Table of Contents. Of the four views described in Using the table of contents it is the only one which will allow you to change the drawing order.


3

If you right-click in the Layer's window, there should be an Add group option. Select this to create sub-sections by dragging your layers into it.


3

First, when you bring your DWG into ArcMap, there is no need to convert it to another file type, unless you are trying to edit the linework. You can view the file and change the way it looks without doing any conversion. (If you do need to edit it, right-click on the Polyline layer in the DWG and choose "Data" and "Export Data." You can then export it ...


3

You have the path wrong for the line that reads: arcpy.mapping.MapDocument(r"C:\Project\\" + mxd) you have made the path a raw string, so the double backslash is wrong and making it fail, it should either be: arcpy.mapping.MapDocument(r"C:\Project\" + mxd) or: arcpy.mapping.MapDocument("C:\\Project\\" + mxd)


3

There is a plugin named Layers menu from project that lets you import layers from other project files incuding the styling. The only pitfall: Attention : the project must be configured to record absolute paths which is not the default for QGIS. But you can change it in the project properties.


3

Append may be what you are looking for. You should be able to select the polygon you want to move from the yellow layer and append it to the existing red layer.


3

Error 010246 from ESRI support describe either a state that all input points have the same location, or that one or none point were selected. I believe that the second one applies to your model. I suggest you manually check whethear some polygons don't contain points at all, or contain one point - you might use spatial join to get the counts. After that ...


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.



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