Tag Info

Hot answers tagged

6

The Describe object also has the hasM and hasZ properties.


3

There are a number of definitions to "centroid", but the most common solution for labeling a linear feature involves either the midpoint along the arc or the midpoint of the longest segment on the arc. Averaging the vertices is unlikely to be "on" the feature and will over-emphasize the significance of short segments. If it's acceptable for the label to be ...


2

You have forgotten to add the feature: lineLayer = QgsVectorLayer("LineString", 'test layer', "memory") pr = lineLayer.dataProvider() # define the fields of the layer pr.addAttributes([ QgsField("ID", QVariant.String), QgsField("latStart", QVariant.String), QgsField("lonStart", QVariant.String), QgsField("latEnd", QVariant.String), QgsField("lonEnd", ...


2

Instead of cutting out polygons, an alternative is to reshape your polygon (Toggle editing > Edit > Reshape Features) into your desired corridor. The topology should remain intact as no polygons are being removed.


2

For this, you need to create new ogr features and save them to the layer and not simply create geometries ( geom1.AddPoint(linkpoint[0],linkpoint[1]), feature1.SetGeometry(geom1)), with dataSource.SyncToDisk() at the end (SyncToDisk() might be helpful to ensure that a particular feature is flushed to disk but it is not necessary here, look at the script). # ...


1

You need to construct your string properly. Instead of: 'POINT("shot.lon" "shot.lat")' Try: 'POINT(' + "shot.lon" + ' ' + "shot.lat" +')' EDIT - However - for your example, that will only give you distance in degrees. This will work for projected coordinates (UTM, for example) but not decimal degrees.


1

I think the two messages are separate. The first message is just a warning that anything such as formulae, formatting and additional worksheets cannot be saved in a CSV as it is a simple ascii format. The second message suggests that you maybe have a text field as one of your attributes which contains a comma. This will effectively introduce an extra ...


1

Hi Athena and welcome to PyQGIS programming! For having a good start you could take a look at PyQGIS Cookbook! Anyway, the snippets below is an example what you are trying to do of: from PyQt4.QtCore import QVariant ## create an empty memory layer vl = QgsVectorLayer("Point", "myLayer", "memory") ## define and add a field ID to memory layer "myLayer" ...


1

I am no expert but I would assume when you draw any points, lines or polygons, they will have to be placed in a vector layer beforehand. The following code is from here which describes how to add a line layer and attributes: from qgis.core import QgsVectorLayer, QgsField, QgsMapLayerRegistry from PyQt4.QtCore import QVariant #create Layer ...


1

You are correct that if your data are in a small region that you should use a geometry type. However, you would also normally transform the Lat/Long coordinates to a spatial reference system for the region. Normally most folks choose a UTM Zone, which describes coordinates for Eastings and Northing with length units in metres. Check out ST_Transform to ...



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