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
7
votes
3answers
10k views

Handling KML/CSV with geopandas - DriverError: unsupported driver: u'CSV'

I'm trying to import a dataset of UK postcode districts UK postcode districts from Google Fusion tables into geopandas with the aim of splicing it to a dataset of house prices. The problem is that ...
0
votes
0answers
20 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 ...
2
votes
0answers
5k views

Python Band.SetNoDataValue(), sets all bands at once

Can someone tell me what I am doing wrong? I want to set bands 1 and three to 255, and band 2 to 0. The code below only should only set band 2, but gdalinfo shows that all bands get set to 0. ...
1
vote
1answer
110 views

QGIS 3 PyQGIS Script - Merge Layers and Export to csv with KML geom field

I previously had a script in 2.18 that exported csv files with kml geometry's file by file. I'm now wanting to move to QGIS 3 and do the same process except Merge the point layers then add the ...
1
vote
2answers
70 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 ...
0
votes
0answers
13 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 ...
2
votes
0answers
22 views

How to set the extent with gdal_rasterize, the “-te” does not work

I am using gdal_rasterize to clip mask by shapefile. However, the parameter "-te" does not work. I use subprocess to call GDAL util: import subprocess # define paths to raster and vector inraster = ...
2
votes
1answer
1k views

Converting XML to polyline shapefile?

I want to convert this XML file to a polyline shapefile. <?xml version="1.0" encoding="utf-8" standalone="yes"?> <ci nc="BMSKDMA10" nl="BMskDMA10" mt="6" ct="DM" dtt="17342" dtu="15/01/2016 ...
2
votes
1answer
32 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, ...
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 ...
0
votes
1answer
64 views

geopandas.overlay() doesn't work in google colaboratory this return AttributeError: 'NoneType' object has no attribute 'intersection'

When I try to make an intersection between two Geodataframes in Google colab, I get the following error message: Here is my code: link1 = 'https://drive.google.com/open?id=...
0
votes
1answer
47 views

Using Python interpreter other than that of QGIS interpreter?

This is a straightforward question but I've been looking for a solution for such a long time. The document "IDE Settings for Developing QGIS" says: 'on Windows you need to make sure you that you have ...
1
vote
1answer
46 views

Calculating destination point using Python

I am trying to write a function that calculates the GPS (decimal) coordinates of a point that is far of a given distance from a given point. Let say that we start from point 1 (The stripe of Dublin) ...
0
votes
0answers
10 views

mapproxy seeding optimisation. Internal HTTP error

We are using mapproxy for caching our own big data from geoserver. When I run seed : mapproxy-seed -continue -f mapproxy.yaml -s seed.yaml the terminal sometimes throws this warning (like in this ...
1
vote
1answer
247 views

Unable to load layers from MSSQL PyQGIS

I have a plugin that loads layers from SQL Server 2008. It has worked before but when I reset my PC, i wasn't able to backup my plugins. I am left with an older copy. Below is my python code to load ...
0
votes
1answer
27 views

Using raster calculator with GDAL in Python to make sum?

I have 130 rasters in a folder and I would like to create a new raster containing the sum of the 130 raster cell values. How can I do this?
2
votes
3answers
9k views

Visualizing.tif image using Python

I am trying to read a hyperspectral image in Uint16 .tif format and visualize it. I use GDAL in Python to read the data and everything works perfectly when I use matplotlib to show one band of the ...
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
30 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, ...
1
vote
1answer
33 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
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
1answer
38 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 ...
1
vote
1answer
27 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
0answers
37 views

Linear Referencing using Python only [on hold]

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 = ...
-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 ...
5
votes
2answers
6k views

Generating polygon representing rough 100km circle around latitude/longitude point using Python?

Given a latitude/longitude point anywhere on earth, I would like to assemble a polygon that roughly resembles a circle with a 100km radius around that point. It doesn't have to be pin-point accurate, ...
0
votes
0answers
25 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
18 views

Unable to activate analytic asset in satellite Imagery

I was trying to import the map of Melbourne. I was able to fetch the details from API coordinates but when i am trying to check the analytic asset status, it is returning inactive. # extract image ...
2
votes
2answers
8k views

Return random string from a list of strings? Field Calculator, Python

I am having an issue with producing the correct syntax to place random strings from a list of min into fields with the field calculator. I have tried the following code: import random ran = ['kid'...
0
votes
1answer
33 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
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
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
1answer
236 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
2answers
5k views

Python 3.6 error import osgeo

I'm trying to install GDAL osgeo lib into Python 3.6 on Debian Stretch I installed neccessary packages like: sudo apt-get update && sudo apt-get install -y \ binutils \ libproj-dev \ ...
1
vote
2answers
42 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: ...
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....
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?
0
votes
2answers
117 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 ...
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 ...
1
vote
0answers
21 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 ...
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
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 ...
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
1answer
59 views

Multiprocess Spatial Join with Spatial Index

I'm a newbie in implementing GIS on Python, but the lack of any GIS software at the office has forced me to learn about it. I have a huge grid (a multipolygon) that I'm currently filling out with ...
1
vote
1answer
188 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 ...
0
votes
0answers
19 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
37 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, ...
8
votes
3answers
4k views

Login to USGS Earth Explorer and download Landsat imagery with Python

I want to login to the USGS Earth Explorer website at http://earthexplorer.usgs.gov/ with Python and download imagery from the Landsat Archive collection just by giving it username,password,path/row (...
-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 ...
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 ...