New answers tagged

0

The DB Manager plugin in QGIS now has a 'Virtual Layers' node that allows you to write SQL commands against shapefiles loaded into your QGIS project. So now that you have this ability, the SQL logic to sort by multiple fields is in the ORDER BY statement, using asc (ascending), desc (Descending), and you can string them together to sort by multiple columns: ...


0

If you would like to get distinct geometries, use in postgis: SELECT DISTINCT your_geom_column FROM your_table; If you are interested in the number of points at the same positions: SELECT your_geom_column, count(*) FROM your_table GROUP BY 1;


0

Perhaps try extracting the nodes and then duplicate the node layer; one for start labels, one for end labels. For your first (start) layer, label with the start column. Under 'Placement', on the 'Labels' tab, select the "Offset from point" radio button and select a quadrant you want all you start labels to appear in. You can then use "Offset X,Y" to ...


0

In the map composer you can use the atlas settings. You can use your territories layer as the 'coverage layer', found under the "Atlas Generation" tab. Here you can also apply a filter to identify which territories you only want to show. It's probably best to also 'Sort by' the territory ID to keep the atlas in order. Under the "Item Properties" tab, ...


1

I think first of all you'll have to split the csv-files you bought in order to generate 'small' shapefiles of valid size. Then possibly it is a suitable approach for you to load your shapefiles into a PostGIS database and do the merge in the database? Thus you shouldn't have anymore problems with file size an the processing would be faster too.


0

you can use Rule-based labeling shapefile point before the rule all the points they label. after the rule: using rules you can specify which labels to show, even using conditional statements


0

Have you tried to activate option « Show all labels for this layer (including colliding labels) » ? This option is in the layer properties dialog > tab Labels > Rendering.


0

Sleep blocks the execution of your script for a while, synchronously. One solution for your question is to use a QTimer, which controls when to execute functions and it's asynchronous, i.e., it allows other functions to continue to run (think of a map.refresh()) while waiting some milliseconds to run the next instruction. Have a look at How to iterate over ...


3

If is OK to save the result permanently you can sort the shapefile with GDAL ogr2ogr -f "ESRI Shapefile" -dialect sqlite -sql "SELECT * FROM my_shapefile ORDER BY attr_1, attr_2, attr_3" sorted.shp my_shapefile.shp Took less that 3 minutes with a shapefile having one million polygons.


1

ShapeFiles have size limits: .shp maximum 8gb The other parts, for example .dbf do not, but are recommended to not exceed 2gb. http://www.gdal.org/drv_shapefile.html


4

You can do this with two "Rule-based Labelling" labels, with no filters. This lets you put multiple labels on a feature. The first rule labels the feature with the attribute you want at the start, the second rule with the end attribute. Initially your labels will appear in the centre of the line, so we need to fix that. Do that with "data defined" ...


5

You can use the Sort and Number plugin. It allows you to sort an attribute table by up to 3 fields, then it creates an additional field that contains the order of the sorted features. Disclaimer: I'm the author of the plugin.


2

If I understand your question, you want to design a road thru a sloped terrain, with start and end points. And you need to keep the slope of the road at minimum. If this is the case, then working with contour lines just complicates the process. There are "least cost path" tools available that work on raster layers. So you should revert your contour lines ...


3

This may be possible in a manual sort of way using the 'Advanced Digitizing Tools' Using this tool you can specify a distance. Then you just need to set up your snapping options to snap on intersection with your contour layer. As you can see in the image below a dark blue circumference guide helps you visualize the extent of your reach.


1

If the projection that you are using has meter unit such as UTM, then you can just write 2000 in cell width OR cell height mutiply by 1000 for Cell width or height, depending the shape that you want, if you are using Create Fishnet tool in ArcGIS. In QGIS you can go to Vector -> Research Tools -> Vector Grid, and enter 2000 for x OR y multiply by 1000 ...


1

After some search I finally found a working solution: As I saw that layer.maximumValue(idx) always kept the same value until I commited changes, I added the number of new elements and that are pending to be commited to this variable. This way I always get serial (autonumeric) number. Idea taken from here: def openProject(): from qgis.core import ...


1

That definitely sounds as a coordinate reference system (CRS, projection) issue. Contours are created in different CRS than the grid is as ahmadhanb suggested. There is important basic rule in QGIS - you always have to be aware of source CRS of datasets and project CRS (displayed map). Most if not all the tools in QGIS won't reproject on the fly as map ...


2

Here's what I did to implement a second Toolbar button and its corresponding dialog: Edit the plugin.py file to add a run2() method, a self.dlg2 variable, a new action in initGui(), and this import: from plugin_dialog2 import pluginDialog2 Copy and paste the UI file and rename it as form2.ui (optionally, open it in Qt-Designer and change the windowTitle ...


3

Following the suggestion of @Joseph, I solved the question by this way: Assuming that there are already defined labels. Step 1: created two fields; xLabel and YLabel, decimal type, length 20, precision 4. Step 2: Layer Properties > Labels > Placement > Data defined, maped the X and Y fields in 'Attribute field' to match with the fields previously created ...


3

You could use the easy custom label plugin to move them where you want. See my blog post for a longer example of how this works.


1

Create a polygon centroid, and then move the centroids where you want.


2

Another way to approach this, that may give you some flexibility for the longer term, is to create a view based on your query in PostgreSQL, then load that into QGIS with the standard PostGIS data loader. Basic SQL Query in Postgres: Create View from SQL Query, with unique ID Load View in QGIS Unioned layer displayed in QGIS The benefit to saving the ...


0

Try setting the label placement to the "Cartographic" option (available in QGIS >= 2.14). That mode uses the font baseline/ascent for placement.


2

You can use a virtual field and conditional CASE statement


0

My coworkers and I were all having this problem in versions of QGIS that range from 2.6.1 to the new 2.14. The solution we worked out is to run: Vector > Geometry Tools > Multiparts to Singlepart... The new shapefile produced will now render at all zoom levels. I believe the issue is that the old shapefile had an incorrect ring order (presuming your file ...


0

This link might be some help to you: https://www.reddit.com/r/gis/comments/20ygje/raster_radiometric_and_atmospheric_corrections/


0

After having browsed a bit on GIS, I found this thread v helpful. I have added an indicator on my spreadsheet (where I have the lon/lat and postcodes). Then I added the spreadsheet as a vector layer. After that I double clicked on my shapefile > Joins > merged the data together. I used this new merged data to colour selectively on "Categorized" as explained ...


3

To me, you need to make a join between your main shapefile that contains the common names only with the CSV file. I would do that this way: Load your CSV file into your QGIS project (Layer > Add layer > Add delimited text layer) and specify that field delimitations are semi-colons and that it is a non-geometric layer. Make a join between your shapefile and ...


2

There is a tool bundled with PostGIS 2.2: PostGIS 2.0 Shapefile and DBF Loader Exporter It allows you to import and export.


1

A faster way would be to dissolve by tree species, then using the field calculator: num_points($geometry) This will then count all the points within each multipart feature


3

Nice question! Say that you have a vector layer referenced: lyr = iface.activeLayer() At this point, I assume you start an edit session and digitize some features. Now you can use the QgsVectorLayerEditBuffer class, in this way: if lyr.editBuffer(): print len( lyr.editBuffer().addedFeatures() ), "features to add!" addedFeatures gives you a ...


0

You don't mention if you're doing it, but as you're writing a standalone application, you need to create a Map Canvas by yourself, in this way: self.map_canvas = QgsMapCanvas() Then you can set the map tool using self.map_canvas: tool = PointTool( self.map_canvas ) self.map_canvas.setMapTool( tool ) Why not to write the parenthesis in ...


2

I suggest that you use a custom rule-based placement for each feature label. You do this by creating a label-placement rule associated a unique value that the feature contains (e.g a id, gid or any other field which is unique). Go to properties for the layer (right click layer and choose properties) and pick the 'Labels' tab. Choose rule-based labelling in ...


1

PostgreSQL / PostGIS (pgAdmin3) create a view and use ST_GeomFromText (text WKT): text WKT = geo;


4

You can use the \W (upper case W) to match any non-alphanumeric characters. If using regexp_replace() it seems you need to escape the backslash, so it becomes \\W (thanks, Joseph!) For example regexp_replace( '=+&hello%%£world','\\W+','_') returns _hello_world If using the python equivalent function re.sub(), you probably won't need to escape ...


1

To fix the error: NameError: global name 'QgsMapLayerRegistry' is not defined Just add the following at the top of your script: from qgis.core import QgsMapLayerRegistry Tip: What I do normally when I receive similar errors is to type the class into the Python Console. It will then provide you with a list of classes and libraries in which they ...


3

You can execute SQL queries and load results as layers in QGIS using the DB Manager. If you still want to go through csv you must take care that WKT-geometry is included in the csv. You can make the query and save the result to CSV with ogr2ogr using the following command: ogr2ogr -f CSV -lco GEOMETRY=AS_WKT -sql "select avi, st_union(geom) geom from ...


2

The "SPIT" plugin is no longer bundled with QGIS, as the plugin was unmaintained and has been surpassed by DB Manager and the processing database import algorithms. changelog.qgis.org/


2

+axis=neu does in fact work, I had an error in the datum I was using. To clarify; if bringing in WKT that is in the format y,x for whatever reason, using a custom CRS with the axes swapped seems to work.


0

For large raster files you can use r.mapcalculator in QGIS Processing Toolbox.


5

In 2.8 - 2.14 (Not sure about earlier versions) you can export shape files to PostGIS using the build in DB Manager. Open DB Manager In the list of PostGIS databases find the one you want to export to, find the desired schema and pres the button marked with the red outline. Choose the shape file in 'input' (Has to be in your 'Layers Panel') and press ...


1

The only line that is going to generate that error is return(subsetOut) If subsetOut is referenced before assignment it means none of the above if and elif conditions matched as true. There's no else to catch anything else. You seem to be comparing a selection value with a numeric. I suspect the selection values are character values (since a selection ...


0

I regularly export maps at 600dpi, so what you can achieve will depend on a combination of your hardware, the complexity of your data and the settings in QGIS. To be honest, your map does not look very complex, so I am surprised you are having problems, unless you have a computer with only an on-board graphics chipset (ie.e no separate graphics card) and ...


1

For your case, that the current layer and the coverage layer don't share a similar field, you will need to use the following rule: within($geometry, @atlas_geometry) Some extras If the current layer and the coverage layer share a similar field, then you can use: "my_filed" = attribute(@atlasfeature, 'atlas_similar_field_name') Finally, if the layer you ...


2

Without knowing exactly where you're up to it's a bit difficult, but here's the nuts and bolts: layermap = QgsMapLayerRegistry.instance().mapLayers() RemoveLayers = [] for name, layer in layermap.iteritems(): if layer.isValid(): if layer.type() == QgsMapLayer.VectorLayer: if layer.featureCount() == 0: ...


6

Better than a script, there's a plugin to achieve it, and it's called "Remove empty layers from the map." http://plugins.qgis.org/plugins/RemoveEmptyLayers/ Disclaimer: I'm the plugin's author.


0

You can use the heatmap option from the layer property. Just double click on the layers' name then on the dialog box select Style--->Heatmap This is my result:


1

Thee other option is to use a size assistant that is available for each of the data layer style. Say you categorized your point data based on color using a certain attribute. Simply right click each category and select Change Size. It should display a size dialog box. Then click on the expression filter and then select Size Assistant. The size assistant ...


1

You can use None as output parameter. Doing so, QGIS Processing creates a temporary vector file for you: processing.runandload("qgis:createpointsalonglines", "Clipped" ,100,0,0,None) Or: res = processing.runalg("qgis:createpointsalonglines", "Clipped" ,100,0,0,None) iface.addVectorLayer(res['output'],'my points','ogr') In my case (on a GNU/Linux), the ...


0

Are you working with an old version of QGIS? Even though I dont know your answer, maybe you will find an answer here



Top 50 recent answers are included