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
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [python]

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

0
votes
0answers
3 views

PYHTON for geospatial visualization with a point moving process

How to use PYHTON to realize the visualization of a point moving process in geospatial space
1
vote
0answers
19 views

Rotate polygons by value from attribute table [on hold]

I have 60 polygons saved in one shp file. Is there a way to rotate them by the angle value stored in the attribute table? I know how to do it manually; I am looking for more automated way (Every ...
0
votes
0answers
13 views

gdal.Open error: 'NoneType' object has no attribute 'GetRasterBand'

I am running a python script which calibrates a hydrologic model, this script uses gdal from Osgeo. Following is the command I am giving python: from osgeo import gdal infile="G:\ARORA\vic_inputs\...
0
votes
1answer
33 views

Can't delete features from layer tables in QGIS

I have some layers containing DAT,MAP and TAB files, when I loaded these layers into QGIS some layers have check boxes before layer name and some layers won't like showing in below image. In the ...
0
votes
0answers
4 views

Resetting xy position of matplotlib Text object using Python? [on hold]

How can one alter a matplotlib Text object position (xy figure coordinates for example), after it has been created and inserted in a figure? Assume one created a figure with many axes as follows: ...
3
votes
0answers
34 views

Multiprocessing with geopandas

I am learning how to implement the multiprocessing with spatial data using the module multiprocessing. I am trying to implement a spatial intersection between a polygon file and a grid file. I am ...
-1
votes
0answers
9 views

Numpy array to shapefile [on hold]

i want to convert a numpy array to a shapefile (GeoJSON or ESRI). My array represents an classification (damage=1, no damage=0). I want to do this for two arrays, and afterwards intersect the polygons....
1
vote
0answers
20 views

Convert an OGR File to a Raster

i tried out this recipe from the GDAL/OGR cookbook: from osgeo import gdal, ogr # Define pixel_size and NoData value of new raster pixel_size = 25 NoData_value = -9999 # Filename of input OGR file ...
2
votes
0answers
14 views

Using a Python IDE with OSGeo

I have the latest version of OSGeo4W64 installed on my Windows machine. I find it very convenient to have all the Python modules for QGIS, GDAL and GRASS all in one place. I would like to set up an ...
0
votes
2answers
34 views

Arcpy - Python script select many values from attribute table raster

I run this simple script, line-by-line, and I get the error Runtime error SyntaxError: can't assign to literal (, line 1) What am I doing wrong? import arcpy # Set workspace arcpy.env.workspace = ...
3
votes
2answers
27 views

Getting coordinates from mouse click in QGIS 3 (python plugin)

I am trying to get coordinates from a mouse click in QGIS 3 and python 3 using the plugin builder. I have tried using the response from this post, and i can manage to get the coordinates printed to ...
0
votes
0answers
25 views

“Computation timed out” when trying to get the size of an ImageCollection in Google Earth Engine python installation

I'm trying to get the size of an ImageCollection but get "computation timed out" while processing the getInfo() request. I'm using the python jupyter installation and I'm unsure how to make a callback ...
0
votes
0answers
10 views

Extracting rainfall data from a netCDF file for a catchment in Python [on hold]

I need to extract rainfall data (including lat, lon, time) from a netCDF file for a catchment. I have the catchment shapefile (that means, I have the catchment boundary). How can I do it in Python?
0
votes
0answers
16 views

Avoid duplicate labels using PyQgis code [on hold]

I am trying to label street's names. Each street includes multiple sections. I have many repeats of the same street's name. I want to avoid it. I can't find any information how to do it. It must be ...
1
vote
0answers
18 views

Reset Python 3 Installation - ArcGIS Pro / QGIS

I am having an issue with both ArcGIS Pro and QGIS - both applications fail to consistently initialise / operate as intended when they do start up. I have recently been trying to get Python 3 to work ...
2
votes
0answers
21 views

gdal_translate does not crop the GeoTIFF file [on hold]

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
16 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
35 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
31 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
14 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
47 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....
2
votes
1answer
47 views
+50

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
23 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
28 views

Polygonize and mask a GeoTiff with GDAL and OGR [on hold]

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
22 views

How to Plot S57 vector chart on display [closed]

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
38 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
47 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
31 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
75 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 ...
2
votes
1answer
40 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
33 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
37 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
45 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
31 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
22 views

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

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
148 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
45 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
27 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
69 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
43 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
20 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
51 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
33 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 ...