Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [python-3]

Use this tag when Python 3 (or any of its dot releases) is the version you are using.

1
vote
1answer
30 views

QGIS 3 - QSettings().value(r“[…]”)[0:2] error - 'NoneType' object is not subscriptable

I'm trying to find a solution to launch a plugin from outside the QGIS console I've succeeded to call the plugin from the python console in the QGIS software but I'm now trying to do it outside of ...
1
vote
0answers
39 views

Launch a QGIS plugin from a batchfile

After having built a QGIS 3 plugin, I'd like to know how could I call my plugin without clicking on the plugin bar of QGIS to launch it. I've tried implement a first batch file for it : REM changer ...
1
vote
0answers
38 views

Shapely : cascaded_union seems to return too many polygons

I'm trying to get the union of around 4,000 polygons using Shapely's cascaded_union function. The output of this function is a multipolygon in my case, which is normal since many input polygons do not ...
0
votes
0answers
26 views

Deprecation warning when importing Processing in pyQGIS 3

I use QGIS 3.4 with Python 3.7 and I have a warning message when importing Processing like this : import processing from processing.core.Processing import Processing Here is the message : Using or ...
1
vote
1answer
15 views

Setting selection border color in red and save the map of the resulting selection

I'm attempting to create a plugin in QGIS 3 in order to zoom on a selected feature and get the map picture exported in .jpg format. I've been able to perform the zoom and selection of my selection, ...
1
vote
2answers
77 views

Create Polygon with Length, Width, and a center coordinate

Using Shapely or like library, How can I create a rectangular polygon with known Length, Width (in meters)(Drawing over EPSG: 3857), and center coordinates (EPSG: 4326)? The output needs to be in ...
1
vote
0answers
14 views

How to set project CRS with plugin (sqlite layer)?

I'm loading a sqlite db into the current project of qgis with a plugin. The standard CRS is EPSG:4326, however i want the canvas to be set at EPSG:3857. When running one of the 2 codes in the console,...
1
vote
0answers
31 views

How to prevent “Type error: unhashable type” while writing properties with Fiona?

Using shapely's dissolve method I created new geometries from two existing shapefiles. Now I would like to save those new geometries and their properties with Fiona. I have tried to write the ...
0
votes
1answer
36 views

QGIS 3.4.4 - Error to zoom : Cannot zoom to selected feature(s) : No extent could be determined

I'm trying to zoom on a specific place of my map using PyQGIS In order to do so I've defined the layer I wanted to get the features : couche_parcelles = QgsProject.instance().mapLayersByName('...
1
vote
1answer
38 views

Getting GRASS 7.4.4 Working in Python 3

I'm trying to get some GRASS functionality in a Python Script, specification r.series, but I'm struggling to import GRASS. I'm trying to uses the method outline on the GRASS Wiki, Working with GRASS ...
1
vote
0answers
59 views

Rasterizing shapefile with rasterio and gdal gives all cells 0 values [closed]

I am trying to rasterize my shapefile (20 polygons) with rasterio and fiona and turn the new raster into a mask for clipping. I need to rasterize my all polygons in my shapefile and turn on mask ...
0
votes
0answers
29 views

Get a column from database and populate the shapefile attributes?

I would like to know how to get copy a specific columns from the database and add that column in a shapefile attribute table? I am open to other better ideas.
2
votes
1answer
46 views

Assigning function to a key in QGIS Plugin

I have trouble assigning function to a hotkey in my plugin. I have a class that does things with a mouse click. I'd like to assign another function to a keyboard key or sequence. I've tried two ...
1
vote
1answer
56 views

Understanding QgsLayoutItemLegend of PyQGIS?

As I get more into QGIS scripting, I refer to the documentation often and usually without success. I have trouble deciphering how to interpret the classes, etc. I found this thread which is really ...
1
vote
1answer
48 views

Plugin that selects closest point features from a mouse click

I'm trying to build a plugin that would select let's say 8 closest points from a mouse click. I've found a working plugin that selects the closest feature from a mouse click here: https://www....
2
votes
1answer
468 views

Getting error while importing GeoPandas in Python console

I have installed GeoPandas and its dependencies using pip install package_name. Here is the pip list output: Package Version attrs 18.2.0 Click 7.0 click-plugins 1....
2
votes
0answers
54 views

Running python code created in QGIS

I'm using QGIS 3.4 and Python 3.7.0 on Windows 7. From the Python console of QGIS, I created a test script ("test.py") which contains the following line: print('Hello) and this is saved in C:\...
1
vote
2answers
149 views

Python shapely intersection with buffer in meter

Having a line and a polygon, I use shapely to determine the intersection between the two with a defined buffer. Both the line and the polygon are in WGS84 coordinates, while the buffer is in meter. ...
0
votes
0answers
18 views

Find diagram for understanding pyqgis

In orther to undestand the api of pyqgis, i'd like to konw where can i find a diagram of pyqgis api ?
1
vote
0answers
72 views

Normalizing negative pixel values in a GeoTIFF with GDAL in Python

I have a GeoTIFF pulled from Google Earth Engine. I'm using the following code to see the red values of each pixel: from osgeo import gdal gdal.UseExceptions() ds = gdal.Open(myfile) band = ds....
3
votes
1answer
84 views

How to transliterate in QGIS using Python 3

I am QGIS user but beginner in Python. I figured out how to transliterate Georgian script into Latin using this module (https://pypi.org/project/transliterate/). from transliterate import translit, ...
0
votes
2answers
381 views

Ipyleaflet map object doesn't display in Jupyter Notebook but it gets created

When running the code from the example (https://ipyleaflet.readthedocs.io/en/latest/api_reference/map.html#example), no map get displayed. from ipyleaflet import Map, basemaps, basemap_to_tiles m = ...
4
votes
1answer
105 views

Why does osr.SpatialReference return different values in python2 and 3?

Can somebody explain why the result of osr.SpatialReference() differ between Python 2 and 3? sr = osr.SpatialReference() sr.SetFromUserInput('EPSG:28992') sr.ExportToProj4() In Python 2.7 this gives ...
2
votes
0answers
31 views

Getting Python console in QGIS to do tab completion of file system?

I am trying to have the Python 3 console tab of QGIS 3 complete my file system. I've tried import sys but this does not allow me to do it.
0
votes
1answer
117 views

Getting bounding box from Point type GeoDataFrame to getting data from Osmnx

I've a point geodataframe which has only point features inside of it. fishnet_Id ... geometry 0 0 ... POINT (403486 4540640) 1 ...
0
votes
0answers
159 views

Will Anaconda with Python 3.7 work with Python 3.6.5 environment of ArcGIS Pro?

I just uninstalled my Anaconda with Python 3.6 and need to reinstall, but the current version is now with Python 3.7. Will that work for ArcGIS Pro (Python 3.6.5)? I'll have to copy the ArcGIS Pro ...
0
votes
1answer
48 views

ExecuteError: Failed to execute. Parameters are not valid error when SelectLayerByAttribute run in Python 2.7

I am running a line of code in a Python 2.7 environment using arcpy.SelectLayerByAttribute_management: fl_haz_selects = arcpy.SelectLayerByAttribute_management(S_Fld_Haz_Ar, "NEW_SELECTION", "\"...
0
votes
1answer
92 views

RuntimeError: Object: Error in executing tool when running Union

I have a list of a 2 layers (nfhl_fld_haz_features, prelim_fld_haz_features) and a feature class (master_merge) that I want to perform a union on: wkflw2_union = arcpy.Union_analysis([master_merge, ...
3
votes
1answer
66 views

Get xy coordinates of QgsMapCanvas in PyQGIS 3?

I am trying to get the QgsMapCanvas coordinates when they change using PyQt5 and PyQGIS 3. What I have used for that: self.canvas.scaleChanged.connect(lambda: self.showScale(self.canvas.scale())) ...
1
vote
1answer
59 views

S57 Driver doesn't support update Error

I am trying to load S-57 file with pyQGIS with code below self.canvas = QgsMapCanvas() # self.canvas.useImageToRender(False) self.canvas.show() # Lay our widgets out in the main window using a # ...
0
votes
2answers
49 views

Weird cursor issue

Lets say I have a temp layer made out of selected items from another layer and I am trying to look through 2 attributes in that layer with searchCursor: union_test = "C:/Workspace/Sandbox/...
1
vote
1answer
1k views

Uninstalling and Reinstalling Anaconda

I had 2 versions of pandas (22 and 23) in my Anaconda environment for Python 3.6. One of the pandas looks like it was installed through Python 2.7 pip. Basically, I am unable to import pandas at all ...
1
vote
1answer
214 views

Using output statistics in ArcGIS REST API query?

I am using an API to pull in some Web Mapping Service Layer data to my script. The API query has a max count limit of 1000 on returned features per request. There are 2 attributes I am trying to use ...
1
vote
1answer
47 views

RuntimeError: General function failure when running arcpy.da.SearchCursor

I have a script that was previously working but just started throwing an error out of the blue. Here is the traceback: Traceback (most recent call last): File "<ipython-input-68-be384b1c4968>...
0
votes
1answer
20 views

Making the results from function a string [closed]

I am trying to get the features count from feature, then put it in a dictionary that I can call later: ct_dict = dict() ... fipsList = ['13245','06007'] for fip in fipsList: mergedJoinCentroids =...
0
votes
1answer
45 views

Can Python 3.6 Script be turned into tool that will work in ArcGIS Desktop?

I have a Python 3.6 script that I want to turn into a tool for that I can use in ArcMap (10.5). Will that even work or will I strictly have to do it in ArcGIS Pro? I couldn't seem to find any ...
0
votes
1answer
54 views

SearchCursor not reading the last row

Let's say I have a layer made up of pre-selected features from another layer: selects = arcpy.SelectLayerByAttribute_management (S_FIRM_Pan, "NEW_SELECTION", "DFIRM_ID = '{}'".format(fipC)) If I get ...
1
vote
1answer
140 views

Get QgsLayoutItemMap from existing QPT Layout

I created a QPT model with a map inside QGIS. The problem is when I try to select the map under pyQGIS : qpt = QDomDocument() qpt.setContent(content) layout = QgsLayout(QgsProject().instance()) ...
0
votes
0answers
186 views

How to populate a div with hover text in bokeh?

I am developing a geographical dashboard in bokeh. It is fairly easy to use hover tooltip in bokeh, however I want to populate a div when I hover on a field. Python version : 3.5.2 Bokeh ...
0
votes
0answers
782 views

Error in coordinate transformation with Geopandas

I am trying to transform coordinate system of shapefile. %matplotlib inline import matplotlib.pyplot as plt import pandas as pd import geopandas as gpd from geopandas import GeoDataFrame from ...
2
votes
2answers
245 views

Getting a county name using a 5 digit FIPS code

Lets say I have a five digit fips code: '13245'. I have a dictionary to handle know that the 2-digit state part of the code(ex: {'GA':'13', etc...}). But I want to also get the full county name (EX: ...
0
votes
2answers
35 views

Getting dates from an attribute table

I'm using the following to get a list of dates in a field called "EFF_DATE" from an attribute table for some pre-selected features. selectDates = [row[0] for row in arcpy.da.SearchCursor(selects, "...
0
votes
0answers
195 views

Profile FileNotFoundError: [WinError 2]

I've been working with ArcGIS module in python trying to connect to the portal in an intelligent manner. I tried to create a profile so that I wouldn't have to leave my username and password to the ...
1
vote
1answer
93 views

Assigning an ID to each pixel which overlaps with polygon shapefile (Python)

I calculated NDVI values for the last 24 years and created Pandas Dataframe which every cell includes columns with XY coordinates and 24 NDVI values. I have several polygon shapefiles which overlap ...
1
vote
1answer
36 views

Using the results of geoprocess function in another geoprocess function

I have a list to hold the iterated results of running arcpy.MakeFeatureLayer and 'arcpy.CopyFeatures` geoprocesses. selectList = [] fip = '13245' for fc in featureclasses: select = arcpy....
0
votes
1answer
423 views

TypeError: unhashable type: 'dict' when using shapefile with arcpy_metadata module

I am having an issue with the arcpy_metadata module. I have a simple shapefile I am trying to load into the MetadataEditor: import arcpy, os, sys,env import arcpy_metadata as md myfeatures = "C:/...
1
vote
1answer
278 views

Using Python to create xml metadata files for different file types

I have a folder with 3 subfolder, each having a different type of data. Folder_A and Folder_B have standard shapefiles (about 3 shapefiles in each folder). Folder_C has .tif grid files (about 100). I ...
0
votes
0answers
47 views

How to get pixel position of a location, given latitude and longitude, in Python 3? [duplicate]

I have a sentinel-1 GRD product, downloaded from Copernicus. I have used a shapefile created in QGIS and used 'gdalwarp' to crop it. Now, I'd like to open that file in Python using gdal or some other ...
4
votes
1answer
113 views

Weird schema lock issue

I wrote a Python script that produces several output features layers in separate .gdb's. As I am testing and modifying my code, I generally go into arcCatalog, find the .gdb under which the feature ...
0
votes
1answer
47 views

Difficulty using variables as input parameters for arcpy.Intersect_analysis

I have 2 variables created from a previous geoprocesses: fc = arcpy.JSONToFeatures_conversion("cslf.json", os.path.join("cslf.gdb", "cslf")) selectFeatures = arcpy.CopyFeatures_management(select, "C:\...