The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [python]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
15 views

Create vector .shp file and draw several lines with various attributes (L, Z, S%, etc) from coordinates pairs

I have a set or coordinates which forms lines from two points (p1-p2, p2-p3,...., p(n-1)-p(n)), I want to create a SHP file in order to draw several lines from these points, which have several ...
0
votes
0answers
12 views

Measure the direct sunlight throught LiDAR [on hold]

I'm trying to solve a problem related to the measuring of the amount of direct sunlight that a point (X,Y,Z) recieve each day. I've got a DEM model made from a LiDAR dataset. I've been able to ...
0
votes
0answers
9 views

Running PyQGIS standalone script on Ubuntu terminal (docker)

I am running a PyQGIS standalone script on Ubuntu terminal in a QGIS docker: from qgis.core import * QgsApplication.setPrefixPath("/path/to/qgis/installation", True) qgs = QgsApplication([], False) ...
2
votes
1answer
15 views

Creating a Layer Group in GeoServer with Python

I am trying to create a Layer Group in Python using the Request module, but I am getting an HTTP 406 (Not Acceptable) error. Can someone tell me what's wrong with my code? import requests ...
0
votes
0answers
14 views

How to visualise vehicle trajectory data on road maps using python? [on hold]

I have a dataset which contains, among other things, GPS coordinates of routes taken by vehicles. I am using pandas for the data analysis but I'm a complete newbie when it comes to GIS. I would like ...
0
votes
0answers
14 views

How to extract data from DAAC index

I would like to extract a MODIS land cover dataset, among other things from DAAC. I found this python tool which allows me to feed a URL and automatically download the file, and also this library ...
0
votes
0answers
13 views

GDAL Warp windows do not intersect error

I have been trying to use sentinelsat API for retrieving and processing satellite image data. I use GDAL to warp the image and the rasterio to clip my Area of interest and use it for analysis. However,...
0
votes
0answers
29 views

Open .asc file inside .tgz.tar archive without decompressing with Python and GDAL

I am trying to open an .asc file inside a .tgz.tar archive with Python and osgeo.gdal. Here is the link to the official description that this is possible by using /vsitar/ #source file name ...
0
votes
0answers
14 views

Working with street network and boundary shapefiles [on hold]

I am trying to do this: GitHub - mittrees/Treepedia_Public: Treepedia package for public use I am stuck at the first step that says that: With the street network and boundary shapefile for your ...
1
vote
1answer
32 views

Using for loop to print last messages from multiple processes?

Is there a way to use a "for" loop to print the success messages for all of the following geoprocesses? In this example, I am clipping the entire river system of Kansas to a pre-selected ecoregion, ...
2
votes
1answer
38 views

Read Pixel Values from WMTS RasterLayer in PyQGIS

I'm using a WMTS service to serve image tiles, and I want to read the pixel values of these tiles over some extent. I am able to do this with a QgsRasterLayer of a local file (.tif) without an issue, ...
0
votes
0answers
11 views

How to export a rasterio window to an image without geo-reference information?

I would like to export a rasterio window to an image. import rasterio def export_window(w, path): number_of_bands, height, width = w.shape profile = { "driver": "JPEG", "...
0
votes
0answers
14 views

Number of features does not match for my classification of each pixel

I'm running a rating on a my clip from Sentinel-2 as a reference to the diagram shown on: https://github.com/ceholden/open-geo-tutorial/blob/master/Python/chapters/chapter_5_classification.ipynb ...
1
vote
1answer
34 views

Get the longest route from collection of polygons

const startPoint = [x,y]; const nodes = [[x,y], [x,y]....]; const polygons = [...]; const createConnectedPath = (startPoint, nodes, polygons) => { // The path should follow the center of each ...
0
votes
1answer
40 views

GDAL Delete geopackage layer

This seems like it ought to be straightforward: from osgeo import gdal gpkg = gdal.OpenEx('path_to_gpk',gdal.OF_VERBOSE_ERROR,allowed_drivers=['GPKG']) error = gpkg.DeleteLayer(0) After running this ...
-2
votes
0answers
23 views

Linear Referencing - Python only [duplicate]

I am using shapely to snap points to a line. This is the piece of code I use result['geometry'] = result.apply(lambda row: shply_line.interpolate(shply_line.project( row.geometry)), axis=1) How do I ...
0
votes
0answers
38 views

Linear Referencing using Python only [closed]

I am using shapely to snap points to a line. This is the piece of code I use import geopandas as gpd gdf_segments = gpd.read_file("line.shp") shply_line = gdf_segments.geometry.unary_union point = ...
0
votes
0answers
27 views

QGIS Python SyntaxError file=sys.stderr) File “C:\OSGeo4W64\apps\Python37\lib\site.py”, line 177

I am executing a .py file from a windows .bat file for doing a QGIS Desktop 3.8.3 geoprocessing task. I am using the following .bat file : @echo off call C:\OSGeo4W64\bin\o4w_env.bat REM Change ...
1
vote
1answer
26 views

QGIS ordered set from layer.getFeatures()

I need a list of all values of a certain field in a QGIS dataset. To get this, I am using for festure in layer.getFeatures(): value=feature[fieldname] This is kind of working, but I have two ...
1
vote
1answer
30 views

Adding Addtional Styles to GeoServer via Python

I am having difficulties in adding additional styles to GeoServer Layers using pythons Requests module. The below code works perfectly up to the try block. It will successfully publish layer from an ...
0
votes
1answer
29 views

Adding M values using Python

Is there a python library that can be used to make a line shapefile m-aware? To be achieved only using python code and not arcpy libraries
1
vote
2answers
75 views

When calcuating distance between points on Earth why are my Haversine vs. Geodesic calculations wildy diverging?

I am getting wildly diverging distances using two approximations to calculate distance between points on Earth's surface. I am using the Haversine (vectorized) approximation (spherical earth) and the ...
1
vote
0answers
23 views

Export ALL selected raster layers in QGIS

I am working in QGIS 3.8.3 in Windows 10, I have to export all the selected raster layers, is there any way of doing this instead of exporting them one by one? I only would like to export all of ...
1
vote
1answer
43 views

Finding percentage of intersection in polygon

For two given polygons generated in this code, how do I find the percentage of intersection on the rectangle? [The polygon was created using the Alphashape function] (Linked to Finding points of ...
0
votes
0answers
10 views

Formatting widget value to avoid scientific notation

I have visualized a geodataframe using CARTOframes (v1.0b3). The map contains a formula widget that shows the count of the features displayed on the viewport. This is my code: Map(Layer(disagree_lgdf,...
1
vote
0answers
37 views

Finding points of intersection in polygon?

For two given polygons generated as shown below, how do I find the points that are intersected on the rectangle by the circle? [The polygon was created using the Alphashape function] (Similar to ...
1
vote
2answers
44 views

QGIS Python ImportError: No module named builtins

When I am executing a python script for doing a geoprocessing task using QGIS Desktop 3.8.3 (executed using a windows .bat file), I am getting an import error. from builtins import zip ImportError: ...
2
votes
1answer
62 views

Making meridians converge to both poles?

def transformx(lon, lat): x = lon*(90-lat)/90 y = lat return x, y What is the formula to make the meridians converge to both poles like the picture attached?
1
vote
1answer
38 views

Reference to raster list

I am writing my first Python plugin. There was a problem during work. The plugin is designed to select a raster and calculate the statistics for the area bounded by the vector. I have created a list ...
0
votes
0answers
20 views

SQL Queries using Python/PyQgis after connecting to database [closed]

In QGIS I connected to a SQL database using MSSQL. I now want to read one (or more) tables from that database and extract some data. Any hints on how to do it?
1
vote
0answers
39 views

Python: distance of point to polygon border

I want to measure the distance of a point(lat,long) to a the border of a Polygon. So I have created the polygon with the coordinates. from shapely.geometry import Polygon, Point Polygon(zip(lon_list, ...
-2
votes
0answers
26 views

Get number of points in MultiLineString

How to get number of points in a MultiLineString using Shapely? intPoints = MultiLineString((372 130, 319. 109), (320 109, 300 101), (300 101, 150 40), (100 20, 92 17)) I want to perform this ...
0
votes
1answer
35 views

Selecting coordinates of points below DEM (DTM)

I have a DEM file and a big list of X,Y,Z point (about 1M). Each of them can be below or above the DEM file. Is there a quick way to select the x,y,z points below the DEM file using Python? I did ...
0
votes
0answers
77 views

QGIS Python Error : No module named 'encodings'

I have written a python code which uses the 'Raster Surface Volume' algorithm of QGIS Desktop 3.8.3. When I execute the python code, I am getting an error : The system cannot find the path specified....
0
votes
0answers
24 views

Random Forest classification for satellite imagery in python [closed]

I have a subset of an imagery data from triplesat satellite which I have labeled myself using polygons in SNAP. As I exprted my labeled subset, I got a tif file and a .data file including info of the ...
1
vote
1answer
65 views

QGIS plugin mouseClickEvent

I am writing a plugin which shows a graph in a qGraphicsView based on some selected points. I want to be able to read out points clicking in the graph, so I've written a mosePressEvent eventhandler ...
0
votes
0answers
20 views

Legend of GeoDataFrame does not sort categorical data values

I try to plot a map of temperature with geopandas in Google Colaboratory. This is my dataset: id = '1LOywA8JPP6vOFDP-CBOBgkSmX7zv2pDc' downloaded = drive.CreateFile({'id':id}) downloaded....
-1
votes
0answers
35 views

Using gdal_rasterize gives ERROR 1

I'm trying to rasterize a single-band raster, the NDVI from sentinel 2 but I have problems with gdal_rasterize. gdalinfo -proj4 C:\Users\....\....\clip_NDVI.tif gdal_rasterize -a "id" -l myshapefile ...
0
votes
0answers
21 views

Snapping value = 0 in Qgis

I am building pipes network, I need check connection between of pipes. I want to pipes must snap and tolerance has value = 0. Is there any tool to check and fix this things. I know Topology Checker ...
2
votes
2answers
53 views

Reversing coordinates of MultiPoint using Shapely?

How to reverse the cooridnates order of this MultiPoint: MULTIPOINT (92 169, 100 163.552380952381, 105.2167832167832 160, 266.7552447552447 50, 290 34.17142857142857, 302 26) to this: MULTIPOINT (...
2
votes
2answers
112 views

rasterio “invalid dtype: 'bool'”

I want to write a binary raster to disk. I have the numpy array whose dtype is: dtype('bool') I try to open a GTiff for writing: img_output = rasterio.open( "../../binary_output.tif", ...
1
vote
0answers
23 views

Layer failed to load using PyQGIS on macOS Mojave

The following is the code that I wrote with the help of PyQGIS Developer Cookbook from qgis.core import * from qgis.gui import * import os #Reference to QgsApplication qgs = QgsApplication([], False)...
2
votes
1answer
86 views

Getting elevation for multiple lat long coordinates in Python

I have seen the answer to Elevation info for multiple lat long coordinates and I would like to be able to do this with a python script instead. I cannot use Googles API because I have 8000 points. I ...
1
vote
0answers
39 views

Distance between centriod of the polygon and each and every point of the polygon [closed]

I'm trying to calculate the distance between centriod of the polygon and each and every point of the polygon using GeoPandas Python I need to find the distance between centroid(18.9568383649 72....
1
vote
0answers
23 views

Get all road intersecting a polygon

I am trying to read from a local instance of the OpenStreetMap database all roads intersecting a boundary coming from another database. I actually get a result with the following piece of code: #...
0
votes
1answer
30 views

Writing shapefile of multiple geometry using Python [duplicate]

How to make a shapefile containing points, polygon, and line using python shapely or pyshp?
1
vote
1answer
36 views

Does ArcGIS Server 10.7.x always provide/support both Python 2.7 and 3.6, or sometimes the 2.7 one only?

Reading this ESRI support information from the Internet (select English language at the bottom of the page, other translations aren't always updated), it's not clear to me if a 10.7.x version of ...
1
vote
0answers
24 views

How remove a duplicated coordinate in multipoints using GeoPandas?

I have shapefile river data in line format, import this data with GeoPandas and apply it to a .boundary to get as initial and final coordinates of each line. But as lines intersect a coordinate may ...
0
votes
0answers
33 views

Landsat temporal images or scenes not overlapping each other [closed]

I am new to Landsat images. I am trying to gather temporal images of Landsat 7. First I downloaded images of same path and row for same place in different time stamp. I then then cropped a square ...
2
votes
2answers
57 views

Get field names in attribute table with Python

I have a geopackage file, with a layer called "MyLayer". Within this I have an attribute table with approx 20 attributes. I can read in each attribute individually like: import geopandas as gpd ...