New answers tagged

0

I have no working experience on PyQGIS, but i tried to achieve the similar results in one of my project using Turf Please check http://turfjs.org/docs/#pointsWithinPolygon Hope it helps...


0

The approach that works in my testing context (PS: I have thrown away the QgsProcessingUtils, not needed or I missed something) This answer was an addition to solve the part you were stucked Seems good, but the display name in the layers panel remains stubbornly 'Extracted (attribute)'. I've used the file world_map.gpkg always present will all QGIS ...


0

That kind of works. I tried: layer = QgsProcessingUtils.mapLayerFromString(format(extracted['OUTPUT']), context ) feedback.pushInfo('\nLayer name is initially {}'. format(layer.name())) layer.setName('my_layer') feedback.pushInfo('\nLayer name is now {}'. format(layer.name())) The first pushInfo call produces: 'The name of the layer ...


0

If I understood correctly the problem, you need to use the QgsMapLayer.setName() function (documentation here). So, taking your code, you should be able to set the layer display name with: layer.setName("LayerDisplayName") Hope this helps.


0

To answer your first question, many packages come with their own function to open a file. The current state of the art for working with vector data in R is the sf package, like @Spacedman already mentioned. To open your shapefile in sf, simply use: munboundary<-st_read("Filename.shp") As Spacedman also correctly assumed (not taking credits here), your ...


0

You can do the requested task using not Select by location but Select by expression. In the image below you can see one example of the necessary expression that selects all the features that have an X coordinate smaller than the X_min (minimum X coordinate) of the polygon. This selects all the features on the left side. This is the expression: --...


1

I recieved the same error- there was an issue with my query. I forgot to add the geometry field. Added the extent to the query and it pulled just fine. 99% of the time I get an error- there is an issue in the query.


0

I created a GeoPackage layer with "CompoundCurve" geometry, added a "circle from two points" and then Save As a shapefile and discovered it is a Line String geometry shapefile. Here's a GeoPackage with a circular line feature in it. If I use the vertex tool to edit it I can edit the ends and the radius, showing it is being stored as circle parts. If I ...


2

This can be done in QGIS Python console. First, list all the layers, then iterating into all layers, get each layer's geometry type and set new name. Here is the code: from qgis.core import QgsProject from qgis.core import QgsVectorLayer # list all layers and iterating into all of them for layer in QgsProject.instance().mapLayers().values(): ...


0

I had a similar issue which I ended up solving in python using xarray: import xarray as xr ds = xr.open_dataset(nc_in.nc) dtran = ds.transpose() dtran.to_netcdf(nc_out.nc)


7

As an alternative solution you may use the layer order tab, it won't lock the layers order but can save from unwanted changes in the layer order. From the View/Panels turn on Layer order panel and check Control rendering order and set the necessary order (it will inherit the order from layer panel). Turn off Layer order panel and save your project. If you ...


0

Here is my two cents: You likely have imported a CSV data into QGIS through Add Delimited Layer and been trying to run the statistics tool on it. Many geoprocessing tools do not work properly on CSV layer. Export the POINTS layer as a new shapefile, and resume working on the shapefile. (Also pay attention to the field name and datatype). TLDR part: First,...


5

I am assuming you have a single layer which contains the 400 polygons. Each of these polygons should have a unique ID field for this to work. This could be an integer, or if each of the polygons has a unique name then that would be fine too. First step is to use the "Split vector layer" tool from the processing toolbox with the input being your 400 polygon ...


0

There is a solution :) from qgis.core import * from osgeo import ogr import os.path path2=r'C:\Users\Martin\Documents\gpkg' #rewrite path if not os.path.exists(path2): os.mkdir(path2) #print(path2) files = [] # r=root, d=directories, f = files for r, d, f in os.walk(path2): for file in f: exten = os.path.splitext(os.path....


2

Another option is to use pyqgis to print out the layer names in current map extent: layerlist = [layer for layer in QgsProject.instance().mapLayers().values()] #List all layers added to the map e = iface.mapCanvas().extent() #Find current map extent for l in layerlist: if l.extent().intersects(e): #If layer extent intersects current map extent ...


3

You may want to use tileindex from QGIS using the following processing. You can access it as shown in the screenshot. A tileindex is a vector layer you generate from raster tiles extent (in QGIS from your layers, if use with GDAL from the mentioned files). So, you have all the benefits of vector layers. You may also be interested to use the recipe from ...


7

You can use pickLayer plugin to select the layer from the canvas and highlight it in the table of content (TOC). When you use the tool, click the raster image in the canvas and select Set current layer and it will highlight the layer in the TOC. You need to download the plugin from the Plugin manager.


0

The aim is to "cover" unwanted areas in the map for reports in order to receive "island maps" from certain administrative districts. In the meantime we have found a solution: Via the following parameter in the SLD of the layer, which should overlap the labels: <VendorOption name = "labelObstacle"> true </VendorOption>


-2

#In ArcGIS Python script windows (only shapefile): workspace_type = 'SHAPEFILE_WORKSPACE' oldlyr = r'C:\TMP\OLD.shp' newlyr = r'C:\TMP\NEW.shp' workspace = r'C:\TMP\NEW.shp' #(!!!with shapefile name and extension!!!) dataset_name = 'NEW' #(!!!without extension!!!) oldlyr.replaceDataSource(workspace, workspace_type, dataset_name) #In independence Python ...


Top 50 recent answers are included