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]

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

0
votes
0answers
3 views

gdal_translate does not crop the GeoTIFF file

When I use gdal_translate to crop the GeoTiff file, the output file is saving the same as the input file. Nothing changed. The size needs to decrease at the boundaries I specify. What can I do? from ...
2
votes
0answers
8 views

Making choropleth map using geopandas?

The following python script gives me a choropleth of the maternal mortality rate by country. The resulting map, though, assigns the same color to (e.g.) Congo and Canada, which is not what the data ...
1
vote
1answer
21 views

Learning to code with Python [on hold]

Can anyone recommend any online courses for Python? The MSc in GIS I hope to start later this year has Python programming modules, but you can substitute with an Environmental module if you so wish. ...
-1
votes
0answers
24 views

Loop all the raster files in the same folder? [on hold]

I'm trying to calculate mean of rasters NDVI for the same years. I have 10 rasters. How can I loop all the raster files in the same folder to calculate mean and add to dataframe? The following code ...
-1
votes
0answers
12 views

Modifying axis y in python 3? [on hold]

i have dataframe in csv i need to plot timeseries ( Date , mean ) this is my script : from pandas import Series import matplotlib.pyplot as plt from matplotlib import pyplot ...
0
votes
0answers
12 views

ValueError: expected array of dim 2

I'm trying to crop a GeoTiff file with spesific coordinates. I tried to implement many methods (gdal_translate, gdal_warp). The best approach I had was with the following codes. But I'm having a ...
3
votes
0answers
38 views

Shapefile polygon operation efficiency

I would like to make a graph from a shapefile, where edges would express spatial relations between polygons according to DE-9IM For that, I use fiona + shapely My code is working but it is extremely ...
-1
votes
0answers
9 views

Turn all raster in folder with rasterio and rasteriomask [on hold]

I have 10 rasters in same folder and I need to mask all rasters with same shapefile using rasterio and rasteriomask This script works just for one raster (1 band) : import rasterio import rasterio....
0
votes
0answers
8 views

Print Layout Items. setExtent() and attemptResize()

I'm trying to arrange some map items onto a print layout. Let's start with the map item itself. Here is my code to add a map item to the print layout. Specifically I have questions about the ...
0
votes
0answers
22 views

Clipping Grid to State polygon using geopandas? [on hold]

I'm new to spatial analytics and geopandas in general. I have US state files, a bunch of points that I figured out how to overlay ontop of said states. However, I can't/haven't found how to overlay ...
0
votes
1answer
19 views

Polygonize and mask a GeoTiff with GDAL and OGR

I am trying to polygonize a GeoTIFF: import numpy, sys from osgeo import gdal, ogr from osgeo.gdalconst import * gdal.UseExceptions() ds = gdal.Open('H:/Threshold/nsdvi_range.tif' srcband = ds....
-1
votes
0answers
13 views

How to Plot S57 vector chart on display [on hold]

S57 chart format has geometry in text or mathematical form that we can read using GDAL library but I don't know how to convert it on visual form that we can see on display. I want Python or C++ ...
0
votes
1answer
10 views

How to post marker to Mapbox GL map

I'm following this tutorial about Mapbox GL and flask which has been going great until the step to add markers to the map. I've tried to distill it to make it as simple as possible but it's still not ...
0
votes
1answer
21 views

How to create a GeoDataFrame points grid from a numpy.mgrid?

I'm trying to create a GeoDataFrame points grid from a numpy.mgrid. I already have created the numpy.mgrid with coordinates of future points. >>>arr = np.mgrid[-1827342.1753285176:-1827523....
0
votes
1answer
41 views

Write GeoTIFF in Python without GDAL

I have a code to transform numpy array in TIFF image using Pillow. But now I need to georeference the tiff to later use it in a GIS software. In my case, I have the latitude and longitude of each of ...
0
votes
0answers
29 views

How delete delete or mask nodata 0 value in the mask

I have raster (with 5 bands) and shapfile in the same projection. I do this script for rastersize and do mask and clip raster or crop raster with mask but I need to have just clip raster without black ...
1
vote
2answers
72 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
22 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 ...
1
vote
1answer
29 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
0answers
32 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
36 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
41 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
23 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
38 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 ...
0
votes
0answers
14 views

TypeError: can't multiply sequence by non-int of type 'numpy.float64' [on hold]

def function_to_fit(x, a, b): return (a*x) + b fit_guess = np.array([ 2., 0.]) popt, pcov = curve_fit(function_to_fit, x, y, sigma=y_err, p0=fit_guess) print("Fit Parameters:", popt) print("Fit ...
1
vote
1answer
145 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
41 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
20 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
26 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
66 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
39 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
17 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
24 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
46 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
31 views

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

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
69 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
23 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 ...
-1
votes
0answers
14 views

Counting number of turns for each route in text file using Python? [closed]

I have a text file organized as below: Begin route Location 1 - 247 1: Start at Location 1 2: Go north on hÎm 212 nguyÔn h÷u c¶nh. xi m¨ng Drive 32.2 m 3: Bear left to stay on hÎm 212 nguyÔn h÷u c¶...
1
vote
0answers
30 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
43 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
18 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
49 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
38 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
36 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
21 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
22 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 ...
0
votes
0answers
57 views

“Segmented” Buffer [closed]

I'm trying to make a buffer around a line, which I subsequently have to split in non overlapping zones (having the same length along the line). The sketches below shows an example of what I have in ...
1
vote
0answers
15 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
29 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
12 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 ...