Skip to main content

Questions tagged [vector-layer]

A vector layer represents geographic data whose features are given by sequences of points. (Contrast with a raster, which is a grid of values.)

Filter by
Sorted by
Tagged with
53 votes
3 answers
74k views

Reprojecting vector layer in QGIS

I have a series of layers of lines (shapefiles) in My Project. The CRS of some are different and to merge them they all must have same CRS. When I use Processing > Toolbox > Qgis_algorithims >...
razi's user avatar
  • 531
30 votes
3 answers
28k views

Creating new empty vector layer with PyQGIS

I have looked at a few tutorials on Python scripts for QGIS. All of them create new vector and raster layers with some existing data source e.g. shapefile or GeoTIFF or PostGIS database table. Is it ...
Theuns Heydenrych's user avatar
8 votes
1 answer
3k views

Adding calculated fields with PyQGIS

In the Memory provider described in PyQGIS Cookbook and in the question Creating new empty vector layer with PyQGIS I can see how to create a Vector Layer programmatically using standard fields (...
rpet's user avatar
  • 159
7 votes
2 answers
2k views

PyQGIS QgsVectorLayer() Loading Invalid Layer in Standalone Python Script?

In my standalone python 3 script, QgsVectorLayer() is loading an invalid layer. When I use the exact same function and inputs in the QGIS GUI python console, the layer loads fine. I am not sure what ...
Matt Brauer's user avatar
13 votes
2 answers
11k views

Deleting selected features using PyQGIS

I have a shapefile with only one field "DN". I would like to delete all features which does not have specific value of the field. Let's say the "DN" can be 1,2 or 3. So far I was ...
MasterPJ's user avatar
  • 359
5 votes
2 answers
4k views

Connecting QGIS to OS Vector Tile API

How do I bring Ordnance Survey's OS Vector Tile product directly into QGIS via their API (https://osdatahub.os.uk/docs/vts/overview)? It feels like this should play very easily with the vector tiles ...
Chris's user avatar
  • 51
2 votes
1 answer
1k views

Shapefile with no map and no attributes in QGIS

For QGIS 3.14 I was following the tutorials, and I got stuck in adding my very first new vector layer. Every time I tried to do the option new Vector Layer, no map appears and the the attribute table ...
oric29's user avatar
  • 23
41 votes
3 answers
97k views

Enabling "Snapping" in QGIS while drawing polygons?

I tried to draw polygons in QGIS 1.7.0 and somehow I can't find or failed to find the "Snapping" option. I'm used to ArcGIS 10.0 where you have some snapping options, like placing points of polygons ...
q9f's user avatar
  • 2,176
11 votes
2 answers
4k views

Loading CSV data table as Vector layer using PyQGIS

This might be a simple problem, but how does one load a simple two-column CSV with no associated geometric data? I have given a couple of go's via QgsVectorlayer[delimited text, spatialite] types - ...
Katalpa's user avatar
  • 871
5 votes
1 answer
3k views

Creating line layer with features using PyQGIS

In QGIS GUI, a line feature is created using this icon How to create a line with a fixed distance from a vector layer using PyQGIS. This my example: from qgis.core import * from qgis.PyQt.QtCore ...
leotv's user avatar
  • 439
11 votes
2 answers
6k views

Deleting all features of Vector layer using PyQGIS

I am developing a Python plugin for QGIS. In the QGIS map window, certain features of a vector layer are selected and those features are highlighted. Now I need to delete all the existing features ...
Sjs's user avatar
  • 1,007
10 votes
2 answers
6k views

Returning latitude and longitude of point using PyQGIS [closed]

I have a point layer, that I'd like to return the Longitude, latitude using the PyQGIS. How do I use QgsPoint to do that?
dassouki's user avatar
  • 8,563
9 votes
1 answer
8k views

Saving layer as shapefile using PyQGIS

Using QGIS 3.4.4, I'm trying to save a layer as shapefile with the following code: import os import qgis.core working_folder = r'C:\myFolder' fc_Prospect = os.path.join(working_folder, Equipment.gdb|...
Pitrako Junior's user avatar
5 votes
2 answers
679 views

Exporting Vector layer using PyQGIS

I found a problem with exporting the vector layer with: "Replace all selected raw field values by displayed values" in the PyQGIS script. The source layer contains a value map for attribute &...
Wenceslauw's user avatar
10 votes
2 answers
11k views

Getting projection from vector layer in QGIS

I am trying to set the projection on a raster to match that of a vector point layer. Thus I need to find out what is the projection of a given layer, to use it in the GDAL.Dataset.SetProjection() so ...
fccoelho's user avatar
  • 1,237
5 votes
2 answers
3k views

Filtering layers by geometry type using PyQGIS

I need to list all layers with geometries skipping the layers without geometries. Can I be sure geometryType = 4 are geometryless? I cannot find the documentation explaining which number is which type ...
BERA's user avatar
  • 73.7k
4 votes
1 answer
196 views

Change the symbology of a vector output layer that is returned from a processing tool?

I want to change the symbology of a Vector Output Layer that is Returned after running a Processing Tool. I am building a processing plugin. I am trying to make the effects reflect in the displayed ...
Beginner's user avatar
22 votes
2 answers
6k views

Creating temporary layer out of selection in QGIS

I want to create a temporary layer out of an existing layer and only get those features from the existing layer, which are selected. I know that ArcGIS has this functionality that you can create a ...
LaughU's user avatar
  • 4,186
16 votes
2 answers
21k views

Clipping Error 1: Cutline polygon is invalid

I used the sample files located at this URL to learn QGIS: https://qgis.org/downloads/data/. I tried to clip SR_50M_alaska_nad.tif using a shapefile as a mask (alaska.shp). The problem is I ...
bryan's user avatar
  • 161
13 votes
4 answers
4k views

Maximum value of field of vector layer using PyQGIS

If I have a vector layer in QGIS, how do I use Python to find the maximum value which a given field has? I need to convert the values in one field into values between 0 and 1. I guess I therefore need ...
Tom Chadwin's user avatar
  • 5,842
11 votes
3 answers
10k views

Defining the CRS for memory layer using PyQGIS

How can I define the CRS for a memory layer from the QGIS project settings? vpoi = QgsVectorLayer("Point", "vectpoi", "memory") feature = QgsFeature() feature.setGeometry(...
dassau's user avatar
  • 387
9 votes
1 answer
726 views

QGIS make the appearance of selected feature the same as defined in symbology

I want to select my item one by one in order to capture them separately. I defined their colour like blue and thickness as 1. According the thread below: Displaying only selected features on map in ...
Geographos's user avatar
  • 4,109
7 votes
4 answers
16k views

Dynamically add layer(s) to Layer Group

I have an Openlayers 3 app and users can retrieve stored routes from a web service and display them on a map. Currently each route is added to the top of the index but I'd like them to be inserted ...
dvmac01's user avatar
  • 1,065
7 votes
2 answers
2k views

Saving temporary layer to shapefile using PyQGIS

I'm attempting to save a polygon created in a scratch layer to a shapefile. The Python code below is a simplified example. Note the questions: Saving layer as shapefile using PyQGIS and Setting ...
user2627043's user avatar
7 votes
1 answer
1k views

Calculating overlap of several lines in QGIS

I've traced several lines that represent people's paths. Some of these lines overlap several times. I would like to get a view showing for each segment of my lines the number of line overlaps. The ...
ddomizia's user avatar
  • 648
7 votes
1 answer
152 views

Setting delimiter in the QgsAggregateCalculator

With PyQGIS I want to aggregate some fields in my layer. When I use: mylayer.aggregate(QgsAggregateCalculator.StringConcatenate, myField) Then I get a concatenated string without a delimiter. So I ...
André's user avatar
  • 357
6 votes
1 answer
352 views

Iterating feature attributes of PostGIS layer using PyQGIS

I am creating a QGIS plugin. Loaded PostGIS layers into QGIS. Now, I need to iterate the feature attributes with next and previous buttons. Once the layer is loaded, first attribute and feature is ...
kiruthika kcube's user avatar
6 votes
4 answers
6k views

Assign a specific color to vector layer based on RGB codes in attribute table

I use QGIS and have a geological map for a large area. I present this after ID codes based on the geology ("Geokartnr" in photo). I want to use international/nation color codes for each rock type, ...
Casairo's user avatar
  • 61
5 votes
0 answers
343 views

Finding difference between two vector layers using QGIS [duplicate]

I have two vector layer land cover for 2016 and 2018. I want to get result layer that will show changes in land cover e.g. the forest has changed into a meadow. What option in QGIS can I use to do ...
Karolina's user avatar
5 votes
2 answers
529 views

Batch replacing of layer file paths in QGIS

I reorganized my shapefiles folders. Now the layer file paths are broken. I have tried the solutions shown in the QGIS User guide (chapter 6.2), but: I don't want to process my layers individually ...
greg's user avatar
  • 67
5 votes
2 answers
457 views

Joining dangling end in the vector layer using QGIS

I have a large river network vector file, where there are disconnections between features. Is there any way to join the nearest dangling points as in the figure below? I found there is a plugin "...
unknown123's user avatar
5 votes
1 answer
348 views

Creating new layer with all attributes inherited from original layer using PyQGIS

Let's assume there is a polygon layer called 'test2' with its attribute table, see the image below. With the code below I am creating a new layer as centroids of original features layer = iface....
Taras's user avatar
  • 33k
4 votes
1 answer
561 views

Performing in-memory difference operation between vector layers in PyQGIS

I've been working on a project using QGIS's Python API. I need to create an in-memory layer that is defined as the difference between two polygonal vector layers, but I'm having difficulty figuring ...
Benjamin's user avatar
  • 154
4 votes
2 answers
7k views

Getting attributes of overlaying polygon layers by spatial query in QGIS

In QGIS I would like to merge selected data/attributes out of the attribute tables from overlaying vector objects on different vector layers without creating new additional layers. Is there any ...
relume's user avatar
  • 71
3 votes
0 answers
1k views

GeoServer 2.9.2 database connection pooling/thread locking issue

I am mocking GetMap requests. Scenario is that 50 users use only "database layers". Each user "sends" 8 GetMap requests every ~22s for ~300s which sums up to 5200 GetMap requests for vector data. ...
user435421's user avatar
3 votes
2 answers
165 views

Graphical model for random points inside polygon moved to closest point on line

I want to place a regular random distribution points inside a polygon and move these points to the respective closest point on a line layer afterwards. I use regular points algorithm with random ...
winnewoerp's user avatar
  • 1,504
3 votes
1 answer
793 views

Getting all shapefile layers in project using PyQGIS

I'm writing a plugin that needs to check a few things for every shapefile layer in the current project. I am iterating over the layers as shown below, but cant figure out how to check if it is a ...
Mads Skjern's user avatar
2 votes
1 answer
2k views

OpenLayers refresh vector source with bbox strategy after map moved

I have a vector layer, in GeoJSON with a Vector source on which I applied the BBOX strategy. I have unique IDs for each feature in the layer and having a look at the network tab in the browser the ...
user3523583's user avatar
2 votes
1 answer
167 views

Linear referencing using virtual layers in QGIS

I am trying to replicate the behaviour explained on this page. There are two initial layers : One network layer (line geometry), called base_lines (fields : LB_idRiver) One event layer (non-...
Kantan's user avatar
  • 1,917
2 votes
1 answer
2k views

How do I merge layers using an external Python script to call the processing module?

This is what I'm trying to run: import sys, glob # Prepare the environment from qgis.core import * # qgis.core must be imported before PyQt4.QtGui!!! from PyQt4.QtGui import * app = QApplication([]) ...
Jas's user avatar
  • 115
2 votes
2 answers
1k views

Assigning colour to QGIS vector layer fields?

I have a vector layer with a field called "dBM". through query builder, I am hoping to change change the colour of the point depending on the value of "dBM". e.g. "dBM" more than 20 ----> ...
JolyDroneSP's user avatar
2 votes
1 answer
3k views

QGIS exporting vector layer to SVG as image

I've rendered a fairly ordinary chloropleth in QGIS (2.18) and am trying to export it to SVG via the print composer. While the text labels come through fine, the shapefile's layer is exported as an ...
futuraprime's user avatar
2 votes
1 answer
363 views

Relying on order of layer categories in PyQGIS

Follow-up to this question, after input considering this other question: To figure out which feature in a QGis vector layer, styled with a categorized renderer, is currently visible (i.e. enabled), I ...
LuWi's user avatar
  • 278
2 votes
1 answer
5k views

OpenLayers 4 does not display vector layer from geoJSON

I am using OpenLayers 4.0.1 and here is my json in pastebin, because it is too large for embedded code: http://pastebin.com/VfLn0RR0 Projection of vector data is 4326 LineString. html code: <div ...
Denis Stephanov's user avatar
2 votes
1 answer
643 views

Using Refactor fields (Batch processing): error in "Fields mapping" column [duplicate]

I have several layers and want to delete some of their table attributes columns, like FLAG. Using Refactor fields is fine: However, when I do it in batch, I get an error in the Fields mapping column ...
JAT86's user avatar
  • 932
1 vote
0 answers
323 views

Vertically fit an Open Layers map in a div

I've created an Open Layers map similar to this example I've mocked up: https://codesandbox.io/s/seamlessly-repeating-vectorlayer-forked-igqti?file=/main.js [EDIT: The above link now shows a commented ...
Dale de Silva's user avatar
1 vote
1 answer
91 views

Non-destructive improvement of vector layer (shapefile) representing a road network?

I have a QGIS project with some vector layers backed by shapefiles. One of these layers contains all the roads, and I would like to "improve" it: It is organized in a way that each vector feature ...
heltonbiker's user avatar
  • 1,237
1 vote
0 answers
210 views

PyQGIS overlaying raster image on vector map correctly?

I have some code written in Python using PyQGIS where I am trying to overlay a raster image gridded with coordinates on to a vector shapefile map with the same coordinates. However, when overlaying ...
user137875's user avatar
1 vote
1 answer
530 views

Split vector by field name and rename output files according to field value

I have a shapefile with several features and want to split the layer into separate shapefiles. I looked into similar questions recommending Split Vector Layer. However, I could not find a way to ...
JAT86's user avatar
  • 932
0 votes
1 answer
787 views

Openlayers 4 WFS & vector select

I want to convert this project for other use from OL2 to OL4 but I can't convert the code and get back a map, http://www.trafficorders.uk/ here the OL2 code: layer = new OpenLayers.Layer.WMS("...
DevWizard's user avatar
  • 511