Stack Exchange Network

Stack Exchange network consists of 175 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]

Python is an open source interpreted programming language used in many GIS programs.

1
vote
2answers
86 views

Reproject all shapefiles in same folder in same projection with raster?

I have 4 shapefiles in the same folder names like that (1996.shp, 2000.shp, 2006.shp, 2014.shp) and one raster. I need to reproject all shapfiles in the same projection (4326) of raster, but I do it ...
0
votes
0answers
24 views

full python 3 script to load shp file inpo Postgis file

I am using Python 3 libraries to programmatically push a shapefile into a remote POSTGIS data base. I retrived the code googling aroung and slighty modifing it. Here the script: import pandas as pd ...
2
votes
1answer
66 views

Add items to print layout

I have created a blank print layout, now I want to add items to it like a map, legend, etc. Here is my code so far to create a new print layout, this works just fine: #This creates a new print ...
2
votes
1answer
48 views

How to find how grass's r.viewshed works programmatically?

I want the Python source code of Grass's Viewshed analysis. In QGIS software there is only an .exe file of that algorithm. Although I'm not sure whether it's written also in python or not. Where can ...
0
votes
1answer
40 views

Find the closest Point from a Point which contains the same attribute

I am trying to create python code to iterate through points on 1 layer and find the closest point on another layer (Road Chainages) based on attribute values. I need to limit the search to < 20m ...
1
vote
1answer
58 views

Circle is ellipse using Open Street Map

Currently I have a problem while developing an app - I use Open Street Map and draw a Circle and pass it to a Python backend, as central point and point on the perimeter on the Circle. Next I am ...
1
vote
1answer
40 views

Looping through folders and select shapefiles by name using pyqgis

I want to loop through folders and find shapefiles which contains the name "GST" and merging them together using python in QGIS 3.4.3. In detail: The folder x contains four folders called VA72, ...
2
votes
1answer
45 views

Reference ObjectID in a where clause within an UpdateCursor

I have a dynamic list of ObjectID values I need to filter an UpdateCursor on. I am setting a where_clause as: where_clause_points = "[ObjectID] IN({0})".format([x for x in inspected_points]) Which ...
1
vote
1answer
151 views

Invalid geometry vs. no geometry

Looking at the QGIS API Documentation: bool QgsFeature::hasGeometry Returns true if the feature has an associated geometry. Is invalid geometry different from a feature having no associated ...
2
votes
1answer
53 views

Calculate mean values for all bands and date to a dataframe

I have 5 rasters, each having 10 bands, where each band corresponds to a specific date. How do I calculate mean values for all 10 bands and save them? I need to save the mean values in a dataframe ...
0
votes
1answer
26 views

Converting string to float in Calculate Value for ModelBuilder?

In ArcMap 10.2 I have created a nested model where I am iterating through some feature classes in order to get the minimum value of a specific field for each of them and then collect the outputs using ...
0
votes
1answer
29 views

Projecting gtiff data using GDAL and Python?

I have a tile data and I would like to transform the data to a gtiff data with georeference information via gdal and python. The tile is the quadtree tile with quad key 1321222320321122. The left ...
3
votes
2answers
77 views

Script I made for pyQgis runs slow but can't find another way around it

registry = QgsProject.instance() first_layer = registry.mapLayersByName('buffered')[0] second_layer = registry.mapLayersByName('buffered')[0] areas = [] instrument_number = "tin_ttl_in" proprietor =...
2
votes
1answer
58 views

How to calculate mean for each band in raster using GDAL and Python 3

I have a raster with 6 bands and I need to calculate the mean for all bands in the raster without value 0 I have this script but it works for one band only: import os from osgeo import gdal import ...
0
votes
0answers
21 views

IDE's syntax completion doesn't work fine while using PyQGIS library!

I use a batch file to set everything up in Pycharm but while I want to use "iface"(which is the QGIS interface instance), my IDE wouldn't recognize it and Its arguments. My batch file is like this: ...
0
votes
0answers
34 views

Calling Google Earth Engine scripts using Python?

I have some scripts in the Earth Engine Code Editor. Is it possible to call these scripts remotely using Python API?
2
votes
1answer
67 views

QGIS Python matching list values to feature ID

Working in QGIS 3 x64 with built-in python console and editor. I have a list of the feature IDs of duplicate features in my dataset. Ultimately, I want each of these features to have a value of 1 ...
1
vote
0answers
46 views

Calculate stats with GDAL Python or rasterio for each bands [closed]

I have MODIS EVI file stacking with 10bands. I use Python 3 in Spyder. I'm trying to rastersize shapefile and do mask to my MODIS EVI. This is my script : import os import glob from osgeo import ...
0
votes
1answer
253 views

Missing osgeo in QGIS 3.4 Madeira (macOS High Sierra)

I am trying to install QGIS 3.4 on my Mac. When I open QGIS I get a message that osgeo is missing. Couldn't load plugin 'processing' ModuleNotFoundError: No module named 'osgeo' Here are ...
0
votes
0answers
37 views

GeoAlchemy2: Cannot insert row because Function st_geomfromewkt(unknown) “does not exist”

i've been stuck on this problem for quite a while now and I can't figure out what could be the issue here. I have a Postgres DB with postgis extension installed CREATE EXTENSION IF NOT EXISTS ...
2
votes
1answer
59 views

How to de-stripe a Landsat 8 band with python?

I am working with Landsat 8 images and some of the bands have striping, e.g.: I've been going down a rabbit hole by looking for a solution for this. Does anyone know a python library that could be ...
1
vote
0answers
47 views

Reading .sde connection file without Esri softwares?

I would like to be able to read connection properties from an sde file without any Esri dependencies such as Arcpy, ArcObjects etc. Is this possible?
0
votes
1answer
26 views

SOLVED: geoserver.catalog.FailedRequestError: Failed to load coverage information:Failed to create reader from file

I have the error geoserver.catalog.FailedRequestError: Failed to load coverage information:Failed to create reader from file:/home/tomcat/data/GaiaGisDataDir/MOSAIC_DATA_DIR/id1626s011002r000-europe/...
2
votes
1answer
56 views

Define a action with Python directly (QGIS)

I'm using QGIS 3.4.3 and I have created some actions for vector layers. I did it interactively and this part is working. Now I wanted to know if there is a mechanism how I could create my actions ...
0
votes
1answer
46 views

Identify lat long points falling out of cluster

Problem Statement I have a set of lat-long locations, say 30 in number. Ideally they should be just a few meters from each other on ground. But sometimes there's that odd junk data point that's 20kms ...
3
votes
1answer
58 views

Colorize singleband GeoTIFF raster using Python/GDAL with discrete interpolation like in QGIS

I have singleband raster with min 0 and max 0.82 values. For raster I applied next color scheme in QGIS: I want colorize raster using GDAL command, but receive raster with another color: GDAL ...
0
votes
1answer
41 views

Is MODIS sinusoidal tile boundary in Eathdata website real?

I was using MOIDS data MCD12Q1 (MODIS/Terra+Aqua Land Cover Type Yearly L3 Global 500m SIN Grid V00). I try to use PyProj in Python to transform the Sinusoidal projection to lat/lon. It actually ...
1
vote
0answers
42 views

Change coordinate system of image exif data

I just started using Pix4D mapper and straight away ran into the problem that the flight data is in WGS 84 and the GCPs are in Gauss Krüger 3. The pix4d support suggested to Transform the image ...
1
vote
0answers
17 views

Reading a RasterIO MemoryFile triggers a GTiff driver warning/error message

I have recently upgraded RasterIO from version 1.0.5 to 1.0.12. After this upgrade I now get CPLE_NotSupported in driver GTiff does not support open option MODE when reading a MemoryFile. My code to ...
1
vote
1answer
150 views

How to fix 'Could not find the Qt platform plugin “Windows” in “”' when implementing qgis in custom Python3 application?

I am implementing qgis 3.4.3 in a custom application, but when I instantiate the QgsApplication() class, I receive the error "Could not find the Qt platform plugin "Windows" in "". I've attempted ...
0
votes
0answers
23 views

From raster histogram/raster make frequency tables in Python

Im new in programming... I would like to know, how I can get a frequency table from a rasters histograms? Or how can I generate the table from a raster? I would like a table of the histogram showed ...
2
votes
0answers
41 views

Running gdal ogr2ogr command from python

I have an ogr2ogr command which uploads an ESRI File Geodatabase to a PostgreSQL database, updating/overwriting the existing data: ogr2ogr -f "PostgreSQL" PG:"host=hosting_url port=5432 dbname=...
0
votes
0answers
60 views

QGIS 3.4.3 - Input dialog for a column in attribute table

I’m working with QGIS 3.4.3 and Python and I’m looking for a better mechanism in attribute table (vector layer) which tells me which fid and which index of a column I’m currently working with. For ...
0
votes
1answer
57 views

GDAL EPSG:4326 Python

I am converting multiple CSV (Lon, Lat, value) to GeoTIFF. My output is in a different projection (EPSG:404000) using output = 'gdal_grid -a invdist:power=2.0 -zfield "value" -of GTiff -ot Float64 -...
0
votes
1answer
35 views

Alignment and distribution tools for shapefiles? [closed]

Does anyone know of a native Esri tool, Python, or R package that would allow one to emulate arcmap's graphic element toolbar functionality, but for shapefiles rather than graphic elements? For ...
0
votes
0answers
11 views

Efficienctly determine which of a set of coordinates which are contained within a set of closed polygons via python [duplicate]

I'm trying to determine which of about 300,000 points fall within any of 215 closed polygons. My code right now loops through each point and then through each shape to see if it the point is ...
0
votes
0answers
39 views

Transforming GRIB file into GeoTIFF that is correctly georeferenced using Python GDAL?

I am trying to transform a GRIB file into a GeoTIFF to be used in a ArcGIS, but am having trouble getting the image to display in the correct location. I have been able to create a GeoTIFF, using GDAL ...
0
votes
0answers
17 views

grass-session 1.0 produce ImportError cannot be imported in Spyder IDE

I am trying to use the recently developed grass-session package inside Spyder in Linux Mint with GRASS 7.4.3 installed with a aim to do some geoprocessing without starting GRASS explicitly. I ...
0
votes
1answer
99 views

How can I convert shapefile to raster and mask using GDAL Python 3

I have a polygon and filelist of data I need to convert my polygon to raster and mask my filelist with this mask and campute the statistics in the area in polygon. I'm using GDAL Python. I can do it ...
0
votes
0answers
40 views

Rasterise shapefile as 1 band (grayscale)

My code converts shapefiles to rasters. I had first done this in colour, but now I need greyscale (1 band). The code seems to create this for the first raster file, but the other raster files seem ...
1
vote
3answers
57 views

Search Cursor Return Field Name If All Rows Contain a Value

I'm trying to print the field name to a list if all rows in that field are not NULL. Here is the logic I have so far. fiberCable = r'Orlando\Orlando_FIM_prep\FIBERCABLE' list = [] with arcpy.da....
1
vote
0answers
50 views

AGOL & SQL database: Is ArcGIS for Server necessary?

A client is requesting we come up with a Python script to have an AGOL feature layer and a SQL Server database containing similar information be able to read/write to each other without having to use ...
0
votes
1answer
27 views

Problems with raster to point operation in QGis 2.18.17

I tried to make points of IDW or Kriging interpolation. From point csv-file I made .asc raster file, then I tried to make "raster value to points".At first QGIS wrote me about the error: ascii' ...
0
votes
1answer
58 views

Can I programmatically output the same map with different shp files?

I have 39 different .shp files of the same locations but different data values and I need to output a map for each of them. Is there a way to build a map template and then run a process that will ...
2
votes
0answers
42 views

Shapely .project() function not working on horizontal or vertical sections of line

I have a function called intersect_point_to_line that includes the following relevant code snippet: for i in range(len(segment.coords[:])): if i < len(segment.coords)-1: seg = ...
2
votes
1answer
209 views

Open GPKG embedded layers in python

I have a gpkg with multiple tables, and I am trying to load it with geopandas: import geopandas as gpd filename = '~/example.gpkg' gdf = gpd.read_file(filename)' This returns the first table/layer ...
1
vote
0answers
24 views

pyqgis : Load WMS layer and make him invisible (qgis 3.4.3 ) [duplicate]

I am loading WMS layer in Python console with simple code. Then I try to make the layer invisible in TOC, but not success. I run the code in QGIS 3.4.3 in Python console in Windows 10. I will be ...
0
votes
1answer
61 views

Projection conversion with Python/Pyproj: Canada Albers Equal Area to WGS

How do I get the geographical coordinates (lat and lon) from x,y values in Canada Albers Equal Area projection? The range of x and y values as follows: min(x) = -5171461.906673405 max(x) = 3372679....
1
vote
0answers
200 views

Error unsupported operand type(s) for /: 'int' and 'list' with QGIS

In a academic project I've produced a small python script for watershed analysis. This script relates shapefiles attributes and generates a .txt file. I am trying to adjust the script to use within ...
1
vote
0answers
42 views

Printing plugin data on QGIS map canvas

I created a Python plugin in QGIS & when i am running my plugin it printing the data on python console. But i want that when i run my plugin it will print the data on QGIS map canvas. How can i do ...