Tag Info

Hot answers tagged

32

Renaming is possible using Table Manager plugin (http://plugins.qgis.org/plugins/tablemanager/)


15

The MultiQML plugin lets you apply one QGIS layer style to multiple layers at once. I think that's as close to what you are looking for as currently possible.


12

Simplest answer I've found, based on Ryan Garnett's advice to do it within QGIS: Use regexp_replace This capability was added to field calculator 1 year ago by J├╝rgen Fischer (as illustrated by this bug report). I tried for a while to find out how to do this, but failed searching for "qgis regex" and other vague terms. It's functionality is probably ...


10

For this you can use UpdateCursor, which opens the feature class or table and steps through each record (row) incrementally. The script below works on this test data +-----------------------+ | Time| Home_Away|Trip | +-----|----------|------+ | 1 | 0 | <nul>| | 2 | 1 | <nul>| | 4 | 1 | <nul>| | 5 | 0 | ...


9

Form layout You have the following methods to do this: QgsVectorLayer.setEditForm( '/path/to/your/ui/file' ) to provide a UI file and QgsVectorLayer.setEditFormInit( 'python.Function' ) to provide a python init method So having a QgsVectorLayer vl the following will do what you are looking for vl.setEditForm( '/home/me/uifile.ui' ) vl.setEditFormInit( ...


9

One way you could do this (while avoiding the two other solutions you mentioned - creating a new layer from selected features, or adding a new field for color) is to use a Definition Query. First, you will want to create a duplicate of your current layer so its in your Table of Contents twice. Then you will need to set a Definition Query for each of ...


8

CSV layers cannot be edited. You have to save to a different format, e.g. Shapefile, before you can start editing.


8

You can use this command to replace all comas in the fields of your Species column with spaces: regexp_replace( "Species", ',', ' ' ) In this post answered by Nathan, the regex_replace function is described by : regexp_replace(string,regex,after) So in your case: 'string' is your column (species) 'regex' is the character you want changed (coma) ...


7

Creating a new integer column is the right way to go - but the 1*FIPS that you used (which would work in Excel or Libreoffice) is where the problem comes in; QGIS doesn't automatically convert between field types in a calculation. You need to use one of the conversion functions (toint converts to integer, tostring to text, and toreal to real/decimal) with ...


7

This may be a dumb answer, as it may be a learning objective for the grad students, but is there a reason why you are not editing the attributes in QGIS with the use of the Field Calculator? In previous versions of QGIS (pre 1.7) editing attributes directly within QGIS was not possible; hence the need for editing .DBF files in OpenOffice etc. As of 1.7 ...


7

If you don't need some kind of routine or script, here is the simple procedere using QGis (Master 1.9, but 1.8 should also work). Add your shapefile as vector layer in QGIS Add your table (can be .csv or .xls files) to QGis in the same way -> Add Vector Layer Both, table and layer should now be visible in the layer table of contents. Now make a simple Join ...


7

Shapefile format cannot support column names longer than 10 characters (a limitation of the dBase format). If you converted to an enterprise geodatabase (ArcSDE) table the limit would be 31 characters (30 in Oracle). File geodatabase supports 64 character column names.


7

Here is the arcpy version of zoom to next feature. You may run this in your ArcMap python window: mxd = arcpy.mapping.MapDocument("CURRENT") # currently opened map doc df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0] # define layer you want to iterate and zoom on for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == 'myTOCLayerNameHere': ...


6

Use Group Stats plugin and set the ID as a field classification. You can see how many times each value has been entered in 'count' column.


6

The event is OnChangeFeature.


6

I think that the best way to think of an attribute is "some property or characteristic of the thing I care about". So for a point that represents a place, it could be the name of the place, the street address, the kind of place it is (e.g. a shop, or a house), or the properties of the soil that is present, or the height of the antennas. Obviously what ...


6

use vector ->geoprocessing tools --> dissolve: select shapefile and field (LEP_NAME in your case), choose name for new shapefile and you are done


6

Edit: The first method I posted wouldn't work. This one should though. One straightforward way to do this would be to select everything you want to keep via Make Feature Layer with a where clause of X <> c. Then, use Copy Features to save the result.


6

Use field calculator (Python) on shape field, e.g.: arcpy.Point(1747952,5907660) If you know coordinates of this point. This is extension of original answer. Create a copy of the layer in table of content and and call it 'points'. Select correct point in 'points. Use field calculator (Python) on shape field for record with missing geometry: def ...


6

It sounds like you want to subset your data and plotting is secondary. Please keep in mind that it is not always necessary to create a new object. If you are only wanting to plot subsets of the data it is far more efficient to take @fdetsch advice and subset in the call to plot. Here are some examples of subseting and plotting sp class data using the meuse ...


6

First part is the AddIn, the real work is done on a form: Inherits ESRI.ArcGIS.Desktop.AddIns.Button Private pForm As fFeatureInspector Public Shared IsFormLoaded As Boolean = False Public Sub New() End Sub Protected Overrides Sub OnClick() 'My.ArcMap.Application.CurrentTool = Nothing If Not IsFormLoaded Then pForm = New fFeatureInspector ...


5

If you need to get the fields of a layer you can use QgsVectorLayer::pendingFields() in Python like so: fields = layer.pendingFields() which will give you something like this: {0: <qgis.core.QgsField object at 0x46d9d40>, 1: <qgis.core.QgsField object at 0x46d9b00>, 2: <qgis.core.QgsField object at 0x46d9cb0>, 3: ...


5

A quick (although inelegant) way to do this is to go into Layer properties, select Style - Categorized using the column that you're interested in. Apply this, then right click on the layer in the layers window and check the Show Feature Count checkbox. Then expand the layer in the layers window and you can immediately see how many times each value has been ...


5

You should use context property of Style object: options = { div: "map", zoom: 12, center: [-9074392.9993436, 5021122.97485], layers: [ new OpenLayers.Layer.OSM() ] }; map = new OpenLayers.Map(options); OpenLayers.Util.extend( OpenLayers.Feature.Vector.style.default, { label: "${getLabel}", pointRadius: ...


5

Quantum GIS has excellent support for PostGIS (which I guess you can use at home since it's free software), so if you are familiar with it, you could script this procedure using SQL with something like this: UPDATE poly_layer p SET neighbors_class = ( SELECT class FROM ( SELECT class, count(0) FROM poly_layer n WHERE ...


5

In ArcMap, you could use python to run nested search cursors. For example: arcpy.MakeFeatureLayer_management("region shapefile location", "Regions") arcpy.MakeFeatureLayer_management("event shapefile location", "Events") out_features = "name and location for output clips" out_count = 0 r_rows = arcpy.SearchCursor(Regions) for r_row in r_rows: r_name = ...


5

If the output file is a shapefile, it is not possible due to the restrictions of the shapefile definition: http://www.gdal.org/ogr/drv_shapefile.html Attribute names can only be up to 10 characters long


5

In QGIS if your polygons do not have any holes or multi-parts: l = iface.activeLayer() for f in l.getFeatures(): print f['NAME'] print 'no. edges: %d' %(len(f.geometry().asPolygon()[0])-1) replace 'NAME' with some identifier in your layer attribute table. Concerning writing to the attribute table check the instructions in the PyQGIS Cookbook - ...


5

With Python and Fiona, Polygons and MutiPolygons (multi-parts) are different geometries: 1) multi-parts geometries import fiona shape = fiona.open("polygons.shp") # shapefile schema print c.schema {'geometry': 'Polygon', 'properties': OrderedDict([(u'id', 'int:10')])} # first feature first = shape.next() print first (GeoJSON format) {'geometry': ...



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