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
0answers
8 views

Calculate monthly sum of rainfall raster with python or shell? Gdal? [on hold]

I have rainfall data in raster file (.tif) every 3h for several years in a folder. Each file has the date into the name with the format: YYYYMMDD.HH.tiff I want to calculate daily and monthly sum of ...
0
votes
0answers
9 views

Updating GeoNode metadata using pyCSW?

We deployed our geospatial data services using GeoNode 2.10, and would like to update/import the metadata for layers published on the GeoNode. Because our metadata is stored in another server and have ...
0
votes
1answer
16 views

Converting ArcGIS Polygon data to Lat/Long? [on hold]

I have downloaded some ArcGIS data from here: ArcGIS Data and there is an explanation of the schema here: ArcGIS Data Documentation How do I convert the values in the array to lat/long? i.e. Here'...
2
votes
0answers
15 views

Re-project GeoJSON from pixel-space to lat-long in Python

I have created a GeoJSON of linestrings in pixel space using Python. However, I now need to re-project the file to match the same projections and extent of the .tiff file I wish to layer the GeoJSON ...
0
votes
0answers
8 views

Connect optimal path and optimal destination [on hold]

I have the following problem which can be solved in 2 stages: The first stage is to calculate the least cost path for transporting the produce from a pixel on the field to the edge of the road, for ...
1
vote
0answers
19 views

Python: Convert shapefile to GeoJSON whilst stripping and renaming fields

I'm writing a Python script to convert shapefiles into GeoJSONs but I would like to remove many of the fields as they are redundant and rename the ones I am retaining. Here's an extract of where I ...
3
votes
2answers
36 views

PostGIS st_makeline extra columns in result

From a table of point data, there are some groups of points that can define a line (cross sections of a water course). 'cross_section' is the name of the table with the point data, geometrypoint the ...
0
votes
0answers
30 views

Writing data from QGIS to an Excel template with Python [on hold]

I have an Excel template and I'd like to get the information from attribute table into my template in .xls I'm new to Python but I already know how to put data from a folder to the Excel (with ...
0
votes
0answers
26 views

What signal can be used to get the selection change on a feature?

Right now I am using: self.iface.mapCanvas().selectionChanged.connect(FunctionThatReactsToTheSignal) But this one sends two signals, one for the deselection of the previous feature and one for te ...
1
vote
0answers
20 views

Hide columns in QgsAttributeTableView with Python

I use this code to initialize QgsAttributeTableView and hide some columns in it in my custom widget: def __init__(self, layer, canvas, hidden_columns, cache_size=5000, parent=None): """...
0
votes
1answer
21 views

arcpy.SelectLayerByAttribute_management reference a field and a variable

I have tried every which way but the right way. I can't seem to get the quotes in the right spot. I have a float field called speeds and I want to compare it to a float variable I am calling ...
1
vote
0answers
57 views

What is the correct way to delete temporal files from geoprocess tools in ArcGIS, ArcPy?

I found that geoprocessing tools like arcpy.gp.SegmentMeanShift makes a lot of heavy temporal files (script is shown below) that keeps lock while the script shell its open, so you can't delete them, ...
3
votes
1answer
43 views

Error using rasterio's sample method

I'm using rasterio's sample function to get values from a (single-layer) raster based on a list of x,y locations: for val in myraster.sample(locations): print(val) This works fine for the first ...
1
vote
1answer
27 views

GeoPandas does not identify points inside polygon

I am trying to intersect some points with a polygon in GeoPandas. First I create a Point GeoDataFrame from a text file. import geopandas as gp import numpy as np import pandas as pd from shapely....
0
votes
0answers
14 views

How to populate an item's tables list for a ArcGIS API for Python Map Service Item?

I am trying to obtain a specific table from a Map Service item, however the table list is empty. The layers list correctly reports back 5 layers. My code snippet below: search_result = gis....
2
votes
2answers
27 views

Programmatically determining version of ArcGIS API for Python?

I would like to obtain the version of ArcGIS API for Python for logging/diagnostic purposes. Is there a way to determine this before a connection is made? I know that once I have the GIS object, I ...
2
votes
1answer
28 views

How to get the source name of a feature layer

I have feature layers that have a different name in the TOC then that they do in the GDB. I cannot change either of these and I need the name of the feature class from the GDB in order to make my ...
0
votes
0answers
26 views

Changing Color of Border After Clipping using Google Earth Engine?

I require nighttime satellite imagery over a particular geometry, clipped by Census Tract. I have uploaded shapefiles into EE. I am going to loop through particular shapes and dates to export images ...
2
votes
1answer
48 views

Getting spatially referenced tiles from WMTS

I have been able to download tiles from a WMTS request in .tif format using owslib in standalone python: from owslib.wmts import WebMapTileService wmts = WebMapTileService('wmts_url') img = wmts....
0
votes
1answer
23 views

Count number of pixels from .msk in Python to derive study area size

Apologies I am totally new to GIS in Python. I am trying to find out the total area of the Barents Sea mask the NSIDC use to calculate their products and therefore I need to know how many pixels the ...
-2
votes
0answers
21 views

Polygons vector shapefile conversion to xyz format using Python [on hold]

I have to convert a vector multipolygons shapefile to an xyz file where x and y are the lon and lat of points in the vector file extent, and z is equal to 0 for a point outside polygons, and equals 1 ...
0
votes
0answers
10 views

How to join the Least Cost Path with Optimal Destination?

I have the following problem which can be solved in 2 stages: The first stage is to calculate the least cost path for transporting the produce from a pixel on the field to the edge of the road, for ...
0
votes
0answers
37 views

Converting NetCDF dataset array to GeoTiff using rasterio Python

I have read a NetCDF file using the netCDF4 library and then read one of its datasets ("Evapotranspiration") into a variable (variable contains array) using the following code. Subsequently now I am ...
0
votes
0answers
18 views

Python matplotlib not available error with QGIS 3.6 Noosa despite upgrading Python on Mac

While generating contours in QGIS 3.6 Noosa on Mac I get an error saying "python matplotlib not available". I've downloaded the latest Python version but the problem persists.
1
vote
0answers
26 views

Python rasterio for saving GeoTIFF files and read in ArcGIS or QGIS

After following the steps in the tutorial of the Planet website (https://developers.planet.com/tutorials/convert-planetscope-imagery-from-radiance-to-reflectance/), I want to save each individual band ...
0
votes
0answers
24 views

.xyz file(coordinate files) in python [closed]

I have got a .xyz file (coordinate file which contains coordinates of atoms). Is there a way to convert it to .txt file in python? OR How can I read and write on a .xyz files in python ?
1
vote
1answer
18 views

Parsing an input parameter to gdal:rastercalculator formula in QGIS 3.6 Python script

For training purposes I'm writing a QGIS 3.6 Python script. The script takes as inputs a raster layer and band, and three float numbers (refmult, refadd, sunel) and computes a simple formula: ((layer@...
1
vote
1answer
65 views

Drawing graticule with GDAL/OGR

I'm trying to generate a graticule with user-defined range of latitude, longitude, and interval; however, my code only displays one line of latitude and one line of longitude when loading it in QGIS. ...
0
votes
0answers
18 views

Error with Script Publishing Service from MXD with UNC Paths

I have script that attempts to publish a service which consists of a single tiff. I am using boilerplate ESRI code for this one: # initialize imagery_date = 'some date' folder_name = 'name of ...
0
votes
0answers
26 views

Python rasterio save GeoTIFF files

After following the steps in the tutorial of the Planet website (https://developers.planet.com/tutorials/convert-planetscope-imagery-from-radiance-to-reflectance/), I want to save each individual band ...
2
votes
0answers
44 views

OpenCV Remap image from rectified image coordinates

I have orthorectified a drone image using ground control points. This results in a (4096 x 2160) array of recified X coordinates and a (4096 x 2160) array of Y coordinates. I want to remap the ...
0
votes
0answers
26 views

How convert OSM relation to GeoJSON -based all kind of relation member roles

I just want to convert OSM data to GeoJSON where it is pretty simple with node and way tags of OSM data, but relation which is giving complex can't find the logic to convert OSM relation to GeoJSON ...
0
votes
1answer
34 views

Replicate QGIS operations in PyQGIS [closed]

What is the best practice for calling QGIS/SAGA/GRASS algorithms from pure Python e.g. the command prompt or in PyCharm? I know that from QGIS -> Processing -> History, I can retrieve the code and ...
1
vote
0answers
25 views

Blank MapCanvas Window [on hold]

I am constructing a GUI using PyQT4 and QGis. Rigth now I can open the MapCanvas whith same buttons of Zoom In/Out using this code: from qgis.gui import * from qgis.core import * from qgis.PyQt.QtGui ...
1
vote
1answer
83 views

List of lat-long, need values in a raster

Apologies in advance as I am not a GIS specialist by any means. I have a set of 1 million points and I'm trying to find their values in a geotiff raster. I've tried various versions of this answer ...
1
vote
1answer
23 views

How do I open / move the focus to a layout in ArcGIS Pro using Python?

I have an ArcGIS Pro project which contains multiple layouts. I've got a Python toolbox with a script which, among other things, chooses which of the layouts is appropriate for a specific map. At ...
2
votes
0answers
43 views

Files locked after running a Python script

I can run a Python script that uses qgsVectorLayer, qgsRasterLayer and many functions like processing:runalg("qgis.difference"......) and os.popen("gdalwarp -q -cutline.......) but if I want to run it ...
-1
votes
0answers
22 views

QGIS 3.4 using pygis for deleting columns v2

I have tried now to implement the code from BERA into the code from J. Monticolo. in order to get a script that is able to delete a set of columns from an attribute table. Previos Post. But I am ...
0
votes
1answer
25 views

Create mean raster stack from raster stack

I am trying to create a mean stack image(1 panchromatic layer) from a stacked tiff image(13 panchromatic layers). How do i go about doing this? My code: from osgeo import gdal import numpy as np #...
1
vote
0answers
17 views

Extracting certain landcover type in CONUS with Google Earth Engine?

I am new to Google Earth Engine and I would like to export the pixels with landcover type of deciduous broadleaf forest (MCD12Q1 with LC_Type1 equals to 4) in google earth engine. And the following is ...
0
votes
2answers
119 views

Testing if os.path.exists with ArcPy?

I am having trouble getting the os.path.exists to recognize that a file exists. I keep getting "File does not exist". I reduced the code to the absolute necessary to address my question. I believe ...
0
votes
1answer
30 views

Keep getting “no such file or directory” DriverError in GeoPandas [closed]

I am new to using GeoPandas and Jupyter Notebook. I am able to define a name, let's say regions as regions = gpd.read_file('FilePathHere.shp') Then I am able to plot the shapefile. When I start a ...
1
vote
1answer
21 views

Is it possible to print a map in PyQgis3 of a database table without rendering the layer in the project gui?

There is a way to print a map using pyqgis3 without rendering the vector layer in the project interface? (by giving just the connection to the table, the map extent and the style )
-1
votes
0answers
39 views

How to georeference image in QGIS using Python code? [closed]

I stitched images from my drone and I have longitude and latitude of centre of image. Also I know that drone was taking images from 50m height and focal length of camera is 35mm. Image is oriented to ...
2
votes
0answers
50 views

Rasterizing polygon grid in Python (geopandas & rasterio)

I am trying to rasterize a custom polygon grid with one or more columns. Preferably I'd like to create multiband rasters from multiple GeoDataFrame columns (in polygon grid), but I have got stuck even ...
-1
votes
1answer
34 views

Classify polygons with Random Forest on Python

I have a segmentation shapefile made with e-cognition containing many polygons of which a part classified for the train file. I would like to classify them by applying labels (e.g. water, vegetation, ...
1
vote
0answers
29 views

Computing GPS points accuracy

I have stand alone GPS points and RTK points collected at the same time and I want to compute the accuracy (1 sigma) of the GPS points. Using the haversine formula, I computed the distance between the ...
0
votes
0answers
29 views

Installing third-party Python Packages to Work With ArcPy and ArcGIS Pro?

My employer does not grant me permissions to use Python package managers like pip or conda since the websites that host these data are blocked. In ArcMap 10.x I have been able to install third-party ...
0
votes
0answers
18 views

import qgis.core in Spyder- DLL load failed

First off, I'm working with QGIS 3.4.5, Spyder 3.6 installed through ArcGIS Pro (2.3.2) python package manager on Windows 10. I can't get the qgis.core module to load and I need some help. I'm ...
1
vote
0answers
39 views

Changing CRS of geometry in geopandas dataframe efficiently?

I have a shapefile which I am converting into a geopandas dataframe. The CRS of this shapefile is epsg:4326 and I want to convert this to epsg:3857. import geopandas as gp file_path = 'zip_poly.shp' ...