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.

0
votes
1answer
57 views

For loop can not find the next raster object in the geodatabase. OSError: “” does not exist

I'm trying to convert a list of rasters in a geodatabase to integer type and rename them with a specific folder name as the prefix. This first block of code moves the ASCII rasters into the ...
1
vote
0answers
34 views

Rasterizing Shapefile in different projection/extent from sample raster in Python?

I have a road network shapefile that I'm trying to rasterize and combine with the DEM raster. I created the road network shapefile from a dataset (using fiona) and therefore it has no projection. What ...
-1
votes
1answer
61 views

Python - Creating a shapefile from a bounding box coordinates list [closed]

There is already few existing questions about this topic, but I unfortunately did not find something that could fix my problem... I have a point Lat, Long coordinate i.e. Lat= 10 and Long = 10. I ...
1
vote
0answers
18 views

SQL Error while using v.distance through simple python editor in grass

I try to execute the following code: grass.run_command('v.distance', from='tramstop', to='iso_tram', upload='cat',column='first_tram_distance', overwrite=True) but i get the "SyntaxError: invalid ...
0
votes
1answer
34 views

Changing decimal digits of extent in raster layer using Python in QGIS

I want to change the decimal digits of the raster layer extent in QGIS 3.4.3 with Python, so it ends with 0.5. My code is as follows: input = vlayer output = "Directory" extent = vlayer.extent() ...
1
vote
1answer
33 views

Argument 1 has unexpected type 'set' Error using processing in QGIS?

I am currently working on a code that adds a field to a shapefile and inputs its filepath. I understand that the processing.run has changed from qgis 2 to qgis 3 but I am not sure why I am getting ...
0
votes
1answer
22 views

Read integer field as a string for list comprehension in arcpy

I have a script that is used to update a line feature class with the start and end elevations based off of a shared ID number with a point feature class using list comprehension in arcpy. However I ...
0
votes
1answer
38 views

Geometric networks (networkx) in PyQGIS

I'm working with code from the Disconnected Islands plugin in QGIS x64 and Python 3. Normally, the plugin uses networkx to create a geometric network and ends by writing the FID of features with no ...
1
vote
0answers
26 views

PyQGIS clip results in empty layers

I am creating a Python/PyQGIS tool in QGIS 2.18 which combines a few functions: Extract several attributes from source layer Redefine a coordinate system Optional: clip the source layer with a ...
0
votes
1answer
23 views

Merging multi-polygons gives me error in shapely

I am trying to merge a bunch of either polygons or multipolygons by the merge_multi_polygons function in shapely, I am using my below code inside Spark elems=row['_c0'] ...
1
vote
0answers
53 views

QGIS Plugin: display dialog for entering username and password to connect to the database

I do not want the password and username to be saved in the QGIS project. Instead of standard QGis dialog(QgsCredentialDialog) I want to display "my dialog" for entering username and password. On the "...
2
votes
0answers
25 views

How to create LineString geometry in QGIS3?

The default geometry type for a newly created line seems to be MultiLineString. It can be changed to LineString using the Multi to Single tool while saving in memory. However, once it is exported it ...
1
vote
1answer
43 views

PyQGIS processing: Overwrite not possible

I have a QGIS plugin that runs the v.clean algorithm two times (first time snap, second break) on a chosen layer: output = self.dlg.directory.text() params_snap = { 'input' : input, ...
0
votes
0answers
17 views

OS X PYTHONPATH for QGIS Standalone Apps?

What's the correct PYTHONPATH for OS X and QGIS 3.4? I want to make a QGIS standalone app but get the "ModuleNotFoundError: No module named 'qgis'" error. This happens after following the OS X ...
-1
votes
1answer
41 views

Reading bathymetry for coordinate with Python? [closed]

I need the water depth at specific coordinates and my geoscientist are offering me a dataset in either TIFF or XYZ/txt format with data points each 2km. I will typically be extracting about 1000000 ...
0
votes
2answers
51 views

I have NDVI layer in Earth Engine. I want to assign and calculate area of good and bad ndvi area

var mergedCollection = s2.map(function(image) { return image.select(['B8', 'B4'], ['NIR', 'red']) }) var mergedAllFunction = function(image) { var ndvi = image.normalizedDifference(['...
1
vote
1answer
36 views

Raw user input for QGIS and Python

I am using Python 3.7 and QGIS 3.4 to run a number of processes, and while I draft and debug my script I want to be able to occasionally stop, check if I want to continue, and then do so. Usually, I ...
1
vote
1answer
22 views

Exception raised when saving Geopandas DataFrame into a file

I am trying to apply the method to_file of a Geopandas DataFrame. My DataFrame contains a column Polygon, a column Point, a string and float columns. Here the output of the describe method: <...
0
votes
0answers
44 views

Mark Dangle Error for linestring

I will create buffer for 5 meter in start point of line string, If any other line string is within the buffer but not snapped then to mark as the startpoint as dangle error.I have attached the sample ...
1
vote
1answer
49 views

Need to convert feature classes regularly deleting/overwriting existing shapefiles and breaking the script to terminate

I know a little Python/arcpy, enough to barely get me by. My goal was to, on a regular task schedule, convert feature classes to shapefiles and overwrite existing shapefiles, but I realized that arcpy....
1
vote
1answer
66 views

Line String Self-Intersection points in PostGIS

I'm trying to get all the points from a Self-Intersection Line String but not find out the self intersection point in the below attached image. The intersection point touches on the same feature how ...
1
vote
1answer
50 views

Array in python just full of zeros when opened using GDAL

I'm working on the below script. What I'm trying to do is create a stats.txt file output which has the Land Cover Class ID, Fractional Coverage (of that class) and the number of pixels (of that class) ...
1
vote
0answers
21 views

Set picture marker symbol for a layer with arcpy - ArcGIS Pro 2.2.4 & ArcGIS 10.6 [closed]

A little UP about the question in the title. I found yet this question on a topic : Set picture marker symbol for a layer with arcpy (ArcGIS) And my question is the same. My purpose is about how to ...
3
votes
0answers
98 views

QGisPlugin : Trigger closeEvent by clicking 'X' in QgsAttributeForm

This is the code: def formOpen(dialog, layer, feature): """Function called when a connec is identified in the map""" global feature_dialog # Create class to manage Feature Form interaction ...
3
votes
1answer
121 views

Display name when hover over plugin icon in QGIS

I have made a QGIS plugin (Python) and when I hover my mouse/cursor over the icon in QGIS the name of the plugin seem to be "Plugins Toolbar". I have searched all .py scripts in the directory of the ...
0
votes
1answer
21 views

How to select a shape and round the attribute field?

# Import arcpy module import arcpy if arcpy.Exists("F:\\Atco_gis\\temp_shapefiles\\Temp_LP_Layers\\adverse_skid_area.shp"): arcpy.Delete_management("F:\\Atco_gis\\temp_shapefiles\\Temp_LP_Layers\\...
0
votes
0answers
36 views

Binary Raster (numpy array) to shapefile

i did a classification with a min/max threshold for stormdamaged areas. For that i calculated two indices (NSDVI) and (SAVI). I intersected two numpy arrays from those results. I recieve a binary ...
0
votes
1answer
59 views

How to fix 'GeoSeries' object has no attribute '_geom'

I'm working on a python script whose goal is to detect if a point is out of a row of points (gps statement from an agricultural machine). To do this, my idea is to make a buffer around the 10 points ...
2
votes
0answers
28 views

Fill masked array values with reflect padding

I have a square matrix (image) with masked values in an area. The mask corresponds to missing values in areas close to the border (always). I want to create a new image where the masked values are ...
0
votes
1answer
38 views

How to perform shapefile/raster integrated functions

Description: I'm having trouble with some Raster/Shapefile manipulation. My problem is that I have a shapefile that I would like to use to update my rastervalues with. The shapefile has multiple ...
1
vote
1answer
40 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 ...
0
votes
0answers
41 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\...
2
votes
1answer
78 views

Can't delete features from TAB layer table in QGIS if no geometry

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 ...
3
votes
0answers
54 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
vote
0answers
30 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
27 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
41 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
56 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
43 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 ...
1
vote
0answers
29 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
26 views

gdal_translate does not crop the GeoTIFF file [closed]

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

Learning to code with Python [closed]

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. ...
0
votes
0answers
30 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
58 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 ...
2
votes
1answer
89 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
1answer
25 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
62 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
67 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
45 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 ...