Tag Info

Hot answers tagged

11

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


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

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

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.


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

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


5

You should have no problem calculating a field based on another. One way to accomplish this is through the field calculator directly. You can also easily incorporate calculations such as this using stand-alone Python scripting. I've attached a screenshot from ESRI's Calculate Field examples that will hopefully get you started. Keep in mind you will have ...


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

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


4

You will need to first load both of the layers you want to join into the map canvas - there is no option to add an additional file once you've opened the Properties dialog. Or am I misunderstanding the problem? You can add any OGR compatible layer - e.g. a CSV file - as a layer (doesn't need to be a delimited text layer with X and Y!) and then do a join. ...


4

you can check this example on openlayers. OpenLayers.ProxyHost = "proxy.cgi?url="; var map; function load() { map = new OpenLayers.Map('map', { maxExtent: new OpenLayers.Bounds(143.834,-43.648,148.479,-39.573) }); var political = new OpenLayers.Layer.WMS("State Boundaries", ...


4

The Feature Merger transformer will allow you to Join by attributes Using FME Desktop 2012 SP2 here http://docs.safe.com/fme/pdf/FMEReadersWriters.pdf Search 'Feature Merger' A good blog post 'Joiner vs Feature Merger' by Mark Ireland http://evangelism.safe.com/fmeevangelist79/


4

This can be done easily in a number of ways, but the best way would be to use the FeatureMerger Transformer. The Requestor will be the shapefile, the Supplier will be the text file. If you leave the settings on their defaults that should be fine for you. This will give you parameters that look like this: Note: The first few times you run it be sure to ...


4

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


4

What you want to do is called a Spatial Join. A common GIS task is to join the attributes from one spatial data layer to another. In this example we will join the attribute table from a polygon layer to a points layer, based on which polygon contains the points. In QGIS, you can do that by using the JOIN ATTRIBUTES BY LOCATION TOOL. You can ...


4

The ArcGIS 10 help under "calculate field examples" shows you how to "Calculate the accumulative value of a numeric field." This will do the trick, provided the data are physically in the intended temporal order. To apply it directly, invert your [Home/Away] indicator (subtract it from 1) so that "0" means "away" and "1" means "home". I call this ...


4

in arcgis you want to do a spatial join. from the arctoolbox select analysis tools, overlay, spatial join. choose the one to many operation. "ESRI desktop help 10.1" use the intersect match option. In my example the first time I got the target features switched so pay attention to the target and join features.


4

What you are doing is fine and good practice. You are not creating a new class but a new feature each time. A new class in your case would be if you added a new LandUse code, say "Big Building" or something like that. What has happened in the original dataset is your colleague has draw in each building and then combined them into a single object called a ...


4

Assuming python and you want as a result a dict { "Facility Type" : None, "Geoid": "<a ...", "County" : "Saginaw County", "2010 Correctional Population": 18 } you could use mystr = "<div>Facility type: </div><div>Geoid: <blah></div><div>County: Saginaw County</div><div>Pop: 18</div>" parts = ...


4

I remembered an entry from ESRI's Geoprocessing blog which describes a tool which concatenates row values and does what you're after. I haven't used it before as I haven't had a need for it yet. But I thought it looked useful and I think this will be an easy solution for you. From the ArcGIS Resource Center: This tool is based on a python script that ...


4

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


4

You should look at using the codeblock in the field calculator. I think it's easiest using the python parser. Have a look at the examples on this page. You could do something like this: Parser: Python Expression: calc(!FIELD!) Code Block: def calc(myField): if (myField == ""): return someValue else: return myField


4

To help debug this I would suggest cleaning up the code a bit: import arcpy from arcpy import env arcpy.env.workspace= r"E:\cities" # added raw string indicator `r` Mi= r"E:\cities\rivers.shp" # removed parentheses - (r"E:\cities\rivers.shp") is a tuple, not a string rows = arcpy.SearchCursor(Mi,'"NAME" = \'Mississippi\'') row = rows.next() largeur = ...


4

int QgsVectorDataProvider::fieldNameIndex (const QString & fieldName) const Returns the index of a field name or -1 if the field does not exist. http://qgis.org/api/2.0/classQgsVectorDataProvider.html#a10263dbd16e19d7aa146a818ac002266


3

I think Intersect will enable you to quickly identify the overlaps and give you an attribute table that you can use to zoom from one overlap polygon to the next. "Intersect can run with a single input. In this case, instead of discovering intersections between the features from the different feature classes or layers, it will discover the intersections ...


3

To all the people who are looking for a way to collect data via Popup as asked in my question, this is how I solved it (same script as in question except the added popup-function and the tool "select"): function init() { Save-strategy var saveStrategy = new OpenLayers.Strategy.Save(); //empty map, bounds are test-layer bounds (EPSG:32647) map = new ...


3

I once answered this question;If you import your Data from a csv file you need to create a csvt file in order to determine the attribut type of a field. See the explanation here: How to change an attribute value from text to number? Jo



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