Hot answers tagged

7

The file bivariate_legend.py has a missing import. Open file /Users/judithheher/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/BivariateLegend/bivariate_legend.py in any editor. Add from qgis.core import Qgis to the import section. Restart QGIS and retry. The plugin will run seamlessly.


6

There is no problem in your code or no bug with QGIS. createRenderer method is deprecated since v3.10. Therefore, there may be incompatibility between the method and later versions of QGIS. I recommend you use the constructor.


6

If I understood correctly, the following script would work for you. First, select the layer and use the script in QGIS Python Editor. # get layer layer = iface.activeLayer() # convert features to list features = list(layer.getFeatures()) # sort features to be sure it is sorted by id. it is crucial features.sort(key=lambda f: f["id"]) dpr = layer....


5

Could be wrong but you should reinstall QGIS 3.18 with the new installer. QGIS standalone installers on Windows are all based on OSGEO4W. At the moment, 2 OSGEO4W installers and only the new one allows for point cloud support. See announcement at https://lists.osgeo.org/pipermail/qgis-user/2021-February/048137.html You may try the new standalone installer ...


5

There is not a specific action for "draw linestring" but rather one to add feature, regardless of the geometry: iface.actionAddFeature().trigger()


4

The QGIS geometry generator symbol layer type is well suited for this, allowing you to keep one QGIS feature and display both of its geometries (or more). For instance, suppose the (default) geometry assigned to each feature is the starting one (either since you digitized the feature in QGIS that way, or since you specified it as the geometry when importing ...


4

You can use QGIS for commercial use without any fees or payment see: https://qgis.org/en/site/forusers/index.html. qgisenterprise is a supportmodel for commercial support - by the way - there are a lot of support companies see: https://docs.qgis.org/3.10/en/docs/user_manual/preamble/help_and_support.html#commercial-support


4

You can do that using the following steps: Use Sample raster values to extract the raster values to the point locations Add a new field of numeric type (float, for example) name it Subtract or the name you like to store the subtracted values. Finally, use field calculator to subtract the values retrieved in step 1 from z values of point data. Note: Make ...


4

Here is a full example using changeAttributeValues(): layer = iface.activeLayer() # the layer to work with surfacefield = 'surface' # fieldname of your lookup field catfield = 'CAT' # fieldname of your new field with edit(layer): # start edit mode of the layer layer.dataProvider().addAttributes([QgsField(catfield , QVariant.String)]) # add the new field ...


4

The normal way will be: with edit(layer): for feature in layer.getFeatures(): if feature['surface']>10000: feature['CAT']='big city' elif... else... layer.updateFeature(feature)


4

This is a workaround using Reclassify by layer tool (so it is not a direct answer to your query). (1) Prepare a classification table by a spreadsheet software ( I used MS-Excel). (2) Drag and Drop the Excel file to the QGIS then it will appear on the TOC (Layers Panel). ] (3) Start Reclassify by layer tool and select Min, Max and Output fields from the ...


4

The file 'world.qgs' is not a vector data source- it's a project file. If you already have QGIS open the easiest way to open a project file is to simply drag and drop it onto the canvas or layers panel either from a folder in your file system, or from the browser panel within QGIS. See the gifs below for examples: At QGIS start from a file folder: From an ...


4

Instead of using Photoshop, you can fix the problem directly on QGIS. Hillshade rendering (or any other raster rendering) happens individual layer by layer, as each layer know nothing about their neighbours. You can bundle the all 9 rasters in a single layer by creating a virtual raster. You have a tool to create the virtual raster in the processing toolbox. ...


4

Yes and no. It takes a bit of doing/navigating, but under 3.18 at least, you can access the ArcGIS Server REST endpoint to add the data to your local project with ease. In other cases, you could accomplish it by loading the *.lyr files using SLYR by North Road/Nyall Dawson. Getting the REST endpoint URL is possible by opening your linked item in the web ...


4

Creating a circle using QGIS 3.18 (Windows 10 Pro) with 3 points. Documentation [https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/editing_geometry_attributes.html?highlight=circle#draw-circles]2


3

If I understand correctly: You loaded the DEMs into QGIS, you were happy with the styling You weren't happy with the artefacts, so you did some polishing in Photoshop When loading the polished-up rasters, the styling in QGIS is different from what it was originally. If that's the case, you should be able to apply the styling of your "old" layers ...


3

QGIS uses PyQt for ui, and it doesn't come with a preinstalled Tkinter python package. I would recommend you either include the relevant package code with your plugin (if the license allows for that), or use PyQt to build your interface. I would recommend learning PyQt and using the included Qt Designer as instructed here in the pyqgis developer cookbook.


3

You should use the same logic in your else clause as you do in your first condition. E.g. In your else clause you should add the layer to the project without adding it to the legend: QgsProject.instance().addMapLayer(layer, False) Then add it to the layer tree root: root.addLayer(layer) Note that addLayer() appends the layer node to the end of a group. To ...


3

You will need to learn how to use field calculator. See this section of the manual to start. Then, your field is a string (text) field from which you need to extract the relevant substrings for the x coordinate and y coordinate and convert them into numbers. The expression substr(string,startpos,length) will let you extract length characters starting at ...


3

You need to update to QGIS 3.16. There you may choose anchor-points for the callout lines at both the feature and the label.


3

A very fast way to remove all the annotations from your project is to use a PyQGIS script in the QGIS python console. the script is manager = QgsProject.instance().annotationManager() for i in manager.annotations(): manager.removeAnnotation(i) This will remove all the annotations in a single action.


3

As I understand it, the only way to update geometry on the go (using this reshapeGeometry method at least) is to access the layer's data provider: layer = iface.activeLayer() provider = layer.dataProvider() line = QgsLineString([QgsPoint(1, 1), QgsPoint(2, 2)]) feats_to_update=[] for feat in layer.selectedFeatures(): geom = feat.geometry() geom....


3

Its probably the version of the DWG - QGIS doesn't like newer versions of CAD files. Your best bet is to try and save it as an older DWG/DXF file.


2

Although the question is quite old, there is still no direct solution for the Qt timing problems that occur in QGIS when adding content via scripts or rendering HTML/Javascript during Atlas generation. But we can work around the problem with a small Python Expression function: from qgis.PyQt.QtCore import QTimer,QEventLoop @qgsfunction(args=1, group='Custom',...


2

You can use the updated code for QGIS 3.x. It's not in the official repo but in a forked version. Download zip https://github.com/ChrFr/osmpoly_export/archive/master.zip and install plugin from zip You may prefer using command line tool for Python 3 at https://github.com/smellman/ogr2poly There is a good list of libraries and tools to import/export from POLY ...


2

As an alternative approach using the "Geometry Generator" via RMC > Symbology > Symbol layer type: Geometry Generator. Keep in mind that this approach depends on the capabilities of your PC. In the working window insert the following expression buffer( collect( $geometry, group_by:="REGION_UN" ), 0) Here the ...


2

You can find below a sample to do sorting using the "PyQGIS way" instead of the Python way. project = QgsProject.instance() projectLayoutManager = project.layoutManager() layout = projectLayoutManager.layoutByName('Your layout name') # You need to select in the layout GUI an existing # "QgsLayoutItemAttributeTable" (in fact, insertion # ...


2

There are 2 things that I think aren't correct. First "if False:" part and second "return..". Meaning of "if False:" is that "don't run the code below this statement". So "the buffer processing algorithm" will never be executed. You should change it to "if True:" or just delete if statement. Second ...


2

The available QGIS Custom Widgets in Qt Designer are defined in QGIS libqgis_customwidgets. It is easy to find out the library in use. Go to Qt Designer → Help → About Plugins. You will see the QGIS library in use. If you see different widgets in your Qt Designer, maybe you are using a different libqgis_customwidgets library. You could be using some ...


2

The CRS drop down in the Save Layer dialog just gives you a selection of recently used CRS's. After you have opened the Coordinate Reference System Selector with the Select CRS button ('globe icon') shown below... ...you will have access to all the predefined Coordinate Reference Systems via a tree view which you can expand and browse: To quickly find a ...


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