Questions tagged [python]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
52 views

Converting every pixel of TIFF file from decimal to binary

I have a folder of .tif-files. I would like to convert every value in each of these files from decimal to binary. This code mostly works. The inner loop correctly outputs the binary equivalent for ...
0
votes
1answer
55 views

Calculating distance between two Linestring using Python

I have two linestring, each linestring represents a rail road. I am trying to calculate minimum distance between these two linestrings. Which function is efficient to do this? I have only come across ...
0
votes
0answers
35 views

OWSLIB Python WCS GetCoverage does not work

I wrote a Python script in order to read a WCS with the module OWSlib: # -*- coding: utf-8 -*- from owslib.wcs import WebCoverageService from owslib.util import Authentication ldbv_url = 'https://...
1
vote
1answer
19 views

Check if Google Earth Engine Python API is initialized

In Google Earth Engine Python API, you need to start with an initialization : import ee ee.Initialize() Is there a way to check if the ee has already been Initialized ?
0
votes
0answers
15 views

rasterio merge method to calculate mean

I am trying to mosaic some raster-datasets (~15) using rasterio.merge.merge in python. I defined a method to calculate the mean but have trouble to take the no-data-values into account. def nanmean(...
1
vote
1answer
63 views

Extracting LAS/LAZ info in a performant way with PDAL?

I can do this: import json import subprocess as sp laz_file = somefile.laz r = (sp.run(['pdal', 'info', laz_file], stderr=sp.PIPE, stdout=sp.PIPE)) json_info = json.loads(r.stdout.decode()) and ...
2
votes
1answer
88 views

exportToPdf doesn't export the layout in QGIS 3

I have a trouble exporting a print layout in QGIS 3.10 to PDF when doing it programatically. I've created a project with print layout manually and now just want to modify the content of the map with ...
0
votes
1answer
37 views

No image exported from GEE ImageCollection to Cloud Storage

I am attempting to export an ImageCollection from Google Earth Engine to Cloud Storage using python API. I work in Atom text editor using Hydrogen, which relies on Jupyter. My workstation runs Ubuntu ...
1
vote
2answers
123 views

Problems with loading Plugins (processing and other plugins)

I have the following python errors when starting the QGIS 3.14: 2020-10-21T09:21:57 CRITICAL Traceback (most recent call last): File "C:\OSGEO4~1\apps\Python37\lib\site-packages\osgeo\osr.py&...
-1
votes
1answer
41 views

Create one TIFF from several images [closed]

I have dataset with images Example image: All images have GPS coordinates. I need to stich this images in one TIFF using Python.
1
vote
0answers
26 views

GeoPandas Overlay Intersect not intersecting some areas

I have a GeoDataFrame where I want to get all intersection between the polygons comprised in it. The cope i use for this is this: intersection_list = [] for index in input_gdf.index.to_list(): # ...
1
vote
0answers
14 views

I get a transparent/empty image with Mapnik in python from a raster file

I start by selecting a raster from the website of the Swiss Federal Office. Therefore, I know, with certainty, the projection in which this layer is located. Source : https://shop.swisstopo.admin.ch/...
3
votes
1answer
78 views

Converting list into field with PyQGIS

I am trying to convert a few lists into fields. I have no problem creating the fields. I just don't have any idea on how to fill them. if result: layer = self.dlg.comboLayerLine.currentData() ...
1
vote
0answers
14 views

Getting the coordinates of the points inside of a shapefile/Getting the coordinates of the closest point if there are none

I'm working with an ERA5 (0.25x0.25 degree) temperature dataset for Europe in order to get average temperature in small statistical regions called NUTS 3. So far I've used a shapefile of the NUTS 3 ...
2
votes
1answer
34 views

Count Blanks, Spaces, and Hardcoded Nulls

I want to get counts of Blanks, Spaces, and Hardcoded Nulls in fields using arcpy.SearchCursor. Is it possible? When I try to filter am getting None values only. I tried the below code. cursorfields ...
1
vote
1answer
68 views

Extracting only part of supervised output model in Raster format

I have a svm predicted model which when applied on raster images classifies the LULC of land and writes the output to raster file. I want to use only the Land used part out of the output raster image. ...
2
votes
1answer
66 views

Unexpected Conversion Result using Pyproj

I am trying to use Pyproj to convert a location in Boston from State Plane to Latitude and Longitude. However, the result did not turn out as I expected. Here is my snippet: from pyproj import Proj, ...
1
vote
1answer
34 views

How to put QgsCheckableComboBox() into standby

I'm trying QgsCheckableComboBox() in my simple python script in QGIS. How to pause code execution while a comboBox-window is open (like a dialog box)? In my example, I want to ensure that the print() ...
0
votes
0answers
34 views

GeoPandas and Cartopy how to dynamically zoom to Multiline

I am new to GeoPandas and Cartopy. I am trying to generate map plots for different regions dynamically. When generating the image from geopandas ('df.plot()') the size is correct, but when I generate ...
0
votes
2answers
64 views

Why are the 500 meters not 500 meters? And how do I add 500 meters in x/y direction to a lat/lon point?

I wanted to create a square cell on a map with size 500m times 500m. Therefore, I wrote the following code: from pyproj import Transformer bl_lat, bl_lon = 40.64423086189233, -74.0307935018417 ...
2
votes
2answers
168 views

Reducing number of if statements in Field Calculator code block of ArcGIS Pro

I am using Python 3 in ArcGIS Pro. In plain English, my goal is calculate one field in a table using a list of values from another field. I can do this with a long list of if statements, but I can't ...
3
votes
1answer
85 views

Shapely flips lat/long coordinate

I have a pandas dataframe containing a Shapely geometry object. The shapely object (circle) was computed from the following SO https://stackoverflow.com/questions/27431528/find-the-intersection-...
0
votes
2answers
20 views

gdal.VectorTranslate fails to wrap the antimeridian on specific input

I'm trying to split a GeoJSON polygon which crosses the antimeridian. I use this solution as base gdal.VectorTranslate returns an empty file My code is: geojson_str = <some geojson string> ...
3
votes
2answers
47 views

GeoPandas distance optimisation

I have created the following function that measures the distance from one point in a GDF to all points in another GDF and returns a table back with the shortest distance for each point. It works well ...
0
votes
1answer
47 views

Issue while performing merge/mosaic of multiple TIFF files using Rioxarray Python

I am trying the following code to mosaic/merge 10 image files (.tif files) using the following code: import rioxarray from rioxarray import merge from rasterio.plot import show items = [r'D:\...
1
vote
1answer
19 views

PermissionError when trying to load the layers in an ESRI File Geodatabase

I am trying to list the layers of a file geodatabase using fiona. I would like to then pick a layer and use geopandas to extract the layer as a geodataframe: import fiona layers = fiona.listlayers(r'...
1
vote
2answers
61 views

What coordinate system is this? How can I project it to WGS84 (lat-long) system in Python?

I had an AutoCAD drawing of a floor plan. I imported it to python using Fiona and checked the metadata. The CRS is empty. When I checked the coordinates for the geometry, it was in the following form, ...
1
vote
0answers
31 views

Converting SQLite BLOB geo to Polygon in Python using SQLite3

I am trying to convert a geo column into Polygons in Python with SQLite3. I imported the file into Python and geo rows look like following first row: geo[0] = b'\x00\x01$i\x00\x00@\xd9\x94\x8b\xd6<\...
0
votes
0answers
20 views

Identify Number of Ground Control Points in DSM Using GDAL

I am trying to use GDAL (in Python) to extract metadata from a digital surface model (.tif). I am using the "gdalinfo" command and applying different flags (e.g. -stats, -mm) to get ...
0
votes
0answers
22 views

gdal_rasterize incorrect values scale after rasterization

I am trying to rasterize a .shp file (in particular it is made up by several Polygon) into .tif one by using python and the gdal_rasterize command. According to the gdal_rasterize function, I was able ...
0
votes
0answers
96 views

Pre-Processing of Sentinel-1 data using Python snappy API

While applying 'Apply-Orbit-File' to Sentinel-1 data during preprocessing via python snappy, the following error produced. Traceback (most recent call last): File "<pyshell#0>", ...
1
vote
1answer
32 views

Dissolve with stats in Python for QGIS

I’m using QGIS 3.10, PostgreSQL 10 and PostGIS 2.5. I want to dissolve within a Python script a shapefile so that the result is dissolved by one field and the number of different values of another ...
0
votes
0answers
38 views

Looping over 5D masked Numpy array Python

I am a beginner in Python and I faced a problem in maintaining the same size of the last 2 dimensions in the 5D array that I have while looping over it to do some calculations, as they represent the ...
0
votes
0answers
51 views

How to calculate object real life location from self driving car?

I have a video made from a car together with GPS information (location coordinates, altitude, speed, track to true North degrees and other. Also I have a 3gf file of g-sensor but I’m not able to parse ...
5
votes
1answer
100 views

Target a specific attribute table

I'm new to PyQGIS and I'm stuck here. So I've created a ComboBox so the user could select which layer he wants to work with. Everything's fine so far. I've also added all layers but now I'm having ...
1
vote
0answers
27 views

Using various script forms in Linux QGIS 3.12

In the last few weeks, I have noticed that various script forms in QGIS (3.12, Linux Mint 19.3) have strange cursor behaviour. Spaces in scripts are unevenly represented on the screen. This is hard to ...
1
vote
1answer
28 views

Creating new QGIS Data Source Uri

I've added vectorlayer from database using the following code # Create New Qgis Data source uri uri = QgsDataSourceUri() uri.setConnection(database_connection['host'], ...
1
vote
1answer
62 views

Return empty dataframe when reading KML file of 'Sentinel 1 Acquisition Segments' using GeoPandas

I have downloaded the KML file of 'Sentinel 1 Acquisition Segments' from this url. I have written this code to read KML file into GeoDataFrame, but the code returns empty GeoDataFrame. >>>...
0
votes
0answers
28 views

Find vertices of LineStrings within Polygon - Shapely

I would like to use Shapely to find the vertices that are located within the boundaries of a Shapely Polygon. So far, I could only manage to get it running by converting the LineString and the Polygon ...
0
votes
1answer
53 views

Checking given a coordinate (lat,long) if is in a raster image file (tif file) and how to extract it with NXN window

I am researching to complete a project. The aim is by given a coordinate I can extract the image among the raster files. How do I check if the coordinate that I have for example (51.3334198, 3.2973934)...
1
vote
0answers
24 views

Forcing boundary conditions in interpolated/kriged data?

I am using pykrige.ok import OrdinaryKriging to generate a spatially continuous field from sparse point data (see image below). The data (glacier ice thickness) are such that there is a hard boundary (...
1
vote
1answer
32 views

Determining driver, spatial reference and other props from an open GDAL layer

I have a very large network share full of data (raster, vector, sometimes mixed inside of geopackage and/or file geodatabase containers). I have a set of classes that crawl through it all and use ...
0
votes
0answers
26 views

SoilGrids Python download WebDAV

I am trying to download global GeoTIFFs following the instructions here: https://git.wur.nl/isric/soilgrids/soilgrids.notebooks/-/blob/master/markdown/webdav_from_Python.md However, I get the error &...
0
votes
1answer
33 views

Iterate through date columns in CARTO (frames, VL, etc.)

I currently have a data file that has columns for each day over an 8-month period. I am seeking of a way to create an interactive CARTO map that displays the change over time. I want to know if there ...
2
votes
1answer
53 views

QgsRectangle do not completely draw a rectangle [closed]

I create a plugin composed by his own canvas (as widget) and in this canvas the user select a rectangle (for the study zone). I used the RectangleMapTool class. However, when I draw the rectangle, it ...
0
votes
0answers
41 views

Calculating point GPS location in picture

I have camera location (GPS coordinates) and need to calculate some points (pixels, actually it’s some detected objects points) location (GPS coordinates) that are seen from the camera. I found in the ...
2
votes
1answer
52 views

Converting DataFrame with geometry column into GeoDataFrame in Pandas

I have this DataFrame: In [120]: a Out[120]: a b c 0 111 333 [POINT (0 0)] 1 222 444 [POINT (0 0)] I am trying to convert with the next line, but it fails: In [125]: b = ...
1
vote
1answer
37 views

How to average multiple GeoTIFF images?

To be short: how can I average two (or more) GeoTIFF images? Explaining: I'm working with coastal water turbidity, using NASA Worldview images. I can easily visualize them in Jupyter Lab (Windows 10) ...
1
vote
1answer
64 views

Contextily not showing basemap

I have a geopandas dataframe that contains bus boarding data. I'm trying to display a subset of the data on a plot using a Contextily basemap but the basemap does not appear. I created the geometry ...
0
votes
0answers
34 views

Self union a geodataframe whilst retaining columns of overlapping features

I have a geodataframe with overlapping polygon features. I want to mutate this to create a non-overlapping polygon geodataframe. I know I can merge the geometries by using unary_union as shown here: ...

1
3 4
5
6 7
188