I adapted Germán Carrillo's code to import xyz files (I use it to import river cross sections).
As the fields in my cross profile tables are separated by multiple spaces, what results in adding several empty columns if I use " " as decimal separator, I added a piece of code to replace the spaces by a comma (consecutive spaces are replaced by one coma). For ...
Managed it with this code, with explanation:
fields = difflayer.fields()
features_A = layer_A.selectedFeatures()
features_B = layer_B.getFeatures()
outgoingFeatureList = 
for f in features_A:
compFeature = QgsGeometry()
localFeature = QgsGeometry()
outgoingFeature = QgsFeature()
localFeature = f.geometry(...
To get the answer on your question I recommend you to use QGIS Python API:
To iterate over all features in the layer use
To iterate over selected features use
Then get features geometry with qgis.core.QgsFeature.geometry
And finally use qgis.core.QgsGeometry.difference
I will assume that you are using the 4.x version of the API since it seems GeoJSONLayer was implemented in 4.11.
Remember that you have to define the modules and classes you will use on top of your script. I see you are calling several modules and classes but GeoJsonLayer is not listed (hence the error you are getting). If you take a look at the ...
Remove space in your output_gpkg.You can try typing another layer name and you will see how the first one loads as well.
for example :
output_gpkg = r'W:\srm\wml\Workarea\mamcgirr\Q_universal_overlap_tool\work\qscript_outputs\one_status_common_datasets_debug_version_dqu_shape_2.gpkg |layername = INVENT'
to load the correct layer you must remove all spaces ...
Based on the discussion in the comments, it now seems that the issue is one of projection. When you load geospatial data into QGIS (or any GIS program), sometimes QGIS will automatically detect the layer's projection, or sometimes you need to tell QGIS what projection that layer is in. In either case, if you chose the wrong projection or QGIS did, the layer ...
It's worth checking your layer order panel (different to the layers panel) by right clicking anywhere on your toolbar or by going View>Panels>Layer Order Panel. Once open, make sure the option 'control rendering order' is unchecked.
Your raster image is covering up your point layer. The simple solution is to rearrange the layers in the layer panel. Move the point layer above the raster layer .
If you prefer to have a simple country boundary line instead of a raster image, you can obtain a country boundary as a vector from here. Choose your country from the dropdown list and download ...
I am assuming you are new to QGIS.
Firstly you need to make sure you have your 'Layers Window' open. Go to View > Panels > Layers to open it if not.
Load your layers (shape files and rasters) by dragging it into QGIS.
Order your layers in the 'Layers Window' depending on which layer do you want to see above which other layer.
If there is a layer and ...
In QGIS 3.6 this is not possible if adding the WFS through the browser panel.
However, if you add the WFS through Layer > Add Layer > Add WFS Layer you are then able to apply SQL to the layer.
So, from scratch, do the following:
After you select Layer > Add Layer > Add WFS Layer, in the next
window select New to add a new service.
Enter a Name and the ...
In the version 5 API:
extent The extent that constrains the center, in other words, center cannot be set outside this extent.
In the version 6 API:
extent The extent that constrains the view, in other words, nothing outside of this extent can be visible on the map.
Also your extent is twice the width and height of your image, but it should be the ...
There are two possible solutions, that I know:
First, is to use a predefined style, saved e.g. in a .qml file. You can than load that .qml file with LAYER_OBJECT.loadNamedStyle(PATH_TO_QML), where PATH_TO_QML obviously point to the file location of the saved style:
layer = QgsVectorLayer(uri.uri(), tr(layer_name), "postgres")
This answer is based on answer provided by @BERA: Save a selected row into a new shapefile with arcpy
The scripts reads the feature class, and exports each of the rows as unique shapefile in three steps:
use ``arcpy.da.SearchCursorto loop throught each row in a feature class to get uniqueOBJECTID`
use OBJECTID to create a new query to subset the row
My Arcmap 10.7.1 does not recognize .GLOB but I found another solution. Thank you everybody for your help.
import arcpy, os
import arcpy.mapping as mapping
layer = mapping.Layer(r"C:\PATH_TO_LAYER FILE")
for root, dirs, files in os.walk(r"c:\Users\jcook\Desktop\Batch"):#I have folder named Batch on desktop
for f in files:
One thing to note here is that mapping.MapDocument("CURRENT") works only within ArcMap and refers to the current open MXD. With this in mind, is necessary that you pass the path to your MXD file as the parameter of mapping.MapDocument(). Because you want to refer to multiple MXD files, you'll need to get the paths of all the MXD files and then iterate ...