New answers tagged

0

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


1

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


2

To get the answer on your question I recommend you to use QGIS Python API: To iterate over all features in the layer use qgis.core.QgsVectorLayer.getFeatures To iterate over selected features use qgis.core.QgsVectorLayer.getSelectedFeatures Then get features geometry with qgis.core.QgsFeature.geometry And finally use qgis.core.QgsGeometry.difference


1

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


1

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


1

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


0

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.


0

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


3

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


1

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


0

Found a solution here: PyQGIS QgsVectorLayer() Loading Invalid Layer in Standalone Python Script? Just added the following line: os.environ['QGIS_PREFIX_PATH'] = 'C:/OSGeo4W64/apps/qgis'


0

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


2

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") layer.loadNamedStyle(...


0

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


1

Assuming QGIS supports data frames you could use three of them with different extents (for contiguous states, Alaska and Hawaii ) on a layout, and then export that layout to a TIFF file.


0

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: if f.endswith(".mxd"): ...


1

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


Top 50 recent answers are included