Hot answers tagged

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.


5

I think it is achievable but will require a few steps. Here is an example layer: Count the number of trees per species using the GroupStats plugin which can be downloaded from: Plugins > Manage and Install Plugins... Once installed, run it with the parameters shown in the image: Then save the results by going to Data > Save all to CSV ...


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


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.


5

One method is to use a virtual field which would automatically number your points using the $id expression (or whatever expression you prefer): Note that you will need to save a project file for this as virtual fields are saved in the .qgs file and not in the shapefile itself (but you can re-save the shapefile as a new one using the Save As... option ...


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


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


4

If I understand, you want aggregate a layer by location. You will need SQL for that, so create a virtual layer (Qgis >= 2.14) with a query like : SELECT geometry, count(*) AS count FROM your_layer GROUP BY geometry You can now use the "count" field of the virtual layer as label. For adding the filter by the text field : SELECT geometry, count(*) ...


4

Just use the clip tool : Vector > Geoprocessing tools > Clip. First input is your point layer, second input your polygon layer.


3

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/


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


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.


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.


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

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


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


3

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


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.


3

Nice question! PyQGIS to the rescue! Follow these steps to get a new field (in your original layer) called label with the number of points that lie in the same location: Active (select) your layer in the QGIS ToC. Run this code snippet in the QGIS Python console: from PyQt4.QtCore import QVariant lyr = iface.activeLayer() # Create New Field ...


3

Your layer have to be in edit mode for enabling the tool. All the parameters in the Change Label box are data defined fields, so you need to have fields corresponding in your attibute table. After creating the new fields in the attribute table, go to the proprieties dialog, and setup the fields you want access. For exemple, for the X coordinate : The ...


3

These have been added to the upcoming 2.16 release. There's options for 1/2, 1/3, 1/4 circles, and 1/2, 1/4 squares, and finally 1/2 rectangles.


3

I think you talk about the id of shapefiles, if so you can go to layer properties (doubleclick the layer) then go to fields and set the item that is called 'Bearbeitungselement' in german to UUID-Generator (id field type must be text) as shown in the screenshot below (https://en.wikipedia.org/wiki/Universally_unique_identifier). When digitizing your ...


3

Instead of playing with workarounds try if GDAL can do the job for you directly. If command ogrinfo -al -so your_big_shapefile.shp seems successful you have good chance to have luck with ogr2ogr as well. Read http://www.gdal.org/ogr2ogr.html and http://www.gdal.org/drv_pg.html and try ogr2ogr -f PG PG:"dbname='databasename' host='addr' port='5432' ...


3

You must create three grids in the print composer: one for the actual grid lines one for X values (to disable grid lines, set them to "No pen") one for Y values (idem) For Y coordinates, you want to see 1 2 3 4 ... Depending on your max and min coordinates, and interval, use the Custom format in the Draw coordinates submenu. You can add an offset to show ...


2

Slope analysis is performed on a DEM (raster layer with elevation values)This is one way to do it. If your contours have an elevation value, you can use the interpolation option (raster/interpolation) to produce a DEM. For instance, here are my contours as a shape file The attribute table do have a value for altitudes in the "elevacion" field Now you ...


2

You can create views on your table to access the different geometry types as separate layers in QGIS, for example: CREATE VIEW parcel_polygons AS SELECT id, name, geom::geometry(MultiPolygon, 4326) FROM parcels WHERE GeometryType(geom) = 'MULTIPOLYGON'; CREATE VIEW parcel_points AS SELECT id, name, geom::geometry(Point, 4326) FROM parcels WHERE ...


2

This looks very weird indeed! Do you have any language settings that hints that anything should be presented as text reading "right to left" (i.e. Arabic or ...)? Look in the Project settings... Can't really imagine this could be the only problem though. Is it only QGIS, or other software as well?


2

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

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


2

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



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