Questions tagged [python]
Python is an open source interpreted programming language used in many GIS programs.
10,926
questions
0
votes
0
answers
15
views
Editing a QGIS script to use field values as input parameters rather than introducing a constant value
I have edited the QGISPolygonSplitting.py script of Pedro Venancio (https://github.com/PedroVenancio/qgis_polygon_splitting) to use values of a selected field as input parameters rather than ...
2
votes
0
answers
24
views
Want to use PostgreSQL db and ST_AsMVT() to develop a tile server, assuming my start point is a GeoTIFF
So basically I want to use ST_AsMVT() function to generate a web server that generates vectors tiles for me, which can then can be accessed through a link like "http://localhost:8080/{z}/{x}/{y}....
0
votes
1
answer
16
views
plt.title not displaying
I am unable to add plt.title
import numpy as np
import geopandas as gpd
from shapely.geometry.polygon import LinearRing
import pyproj
import cartopy.crs as ccrs
import cartopy.feature as cfeature
...
1
vote
0
answers
19
views
QGIS 3.x Python - Some VectorLayer signals not working?
I'm writing a plugin and was really hoping to get the featureAdded signal when the user is interacting with a VectorLayer object in the plugin, but I never see that signal. To try and figure out what'...
0
votes
0
answers
20
views
Ground Classification, without any classified data? (Laspy, Python)
Im new in here and this topics.
I am trying to classify ground point in .las file. Points are never classified which is 0.
I read something about, if number of return is 1, we can declare it as ...
0
votes
0
answers
23
views
Discrepancy in output volume calculation for same rasters in QGIS and Rasterio
I have been comparing my volume calculation results on the same rasters with QGIS Raster Surface Volume tool and the following python script:
import rasterio
import numpy as np
filename = 'D:/raster....
0
votes
0
answers
25
views
Holes closing near extent boarder
I have a shapefile that looks like this:
the yellow polygone is a sqare of full extent size (not separate polygons) with class 0. Polygons of other colors have another classes (1, 2).
If to look ...
0
votes
0
answers
7
views
Issue in searching & downloading Sentinel-5P data within proxy environment
I am trying to download sentinel-5p data by using the following code:
from sentinel5dl import search, download
result = search(
polygon='POLYGON((7.8 49.3,13.4 49.3,13.4 52.8,7.8 52.8,7.8 49....
1
vote
1
answer
25
views
How to geocode the polygon of a street, instead of just a point
I want to geocode many street addresses using GeoPy/GeoPandas, but the results of my queries only return points. Is it possible to obtain the entire polygon of a street, i.e., when it begins and ends?
...
1
vote
0
answers
29
views
Converting Lambert conformal conic to Lat/Lng
I'd like to convert the following geographic representation to Lat / Lng (I guess this is called Lambert conformal conic, but it's the first time I've ever seen this).
Projection: Lambert conformal ...
-2
votes
0
answers
20
views
Python equivalent to QGIS Raster Surface Volume Tool
I've been using the QGIS tool "Raster Surface Volume" https://docs.qgis.org/3.22/en/docs/user_manual/processing_algs/qgis/rasteranalysis.html#raster-surface-volume to calculate the volume ...
0
votes
0
answers
15
views
Rasterio error RuntimeWarning: overflow encountered in reduce return
I have extracted a mask from a raster in order to test out multiple volume calculations between QGIS and Python
I'm using rasterio to read in the tiff image and calculate its volume:
import rasterio
...
-1
votes
0
answers
8
views
How to fuse (fusion) Optical and SAR data using python? [closed]
Optical data (Sentinel 2 or Landsat 8) and SAR data (Sentinel 1)
0
votes
0
answers
11
views
Using Folium.DivIcon to plot multiple LineStrings Length on 1 map
I have the following GeoDataFrame "melissa_segs" which is a result of an exploded Polygon and CRS is 'ESRI:102009'
poly_id
vertex_id
seg_length
geometry
0
1
103.0
LINESTRING (-1224668.715 ...
1
vote
1
answer
20
views
How can I activate GeoTIFF compression in QGIS 3.x gdal_translate?
I am a beginner at Python so please excuse this stupid question. I am working on a simple QGIS plug-in for saving GeoTIFFs and I want to give the user the option to switch on compression when saving ...
-2
votes
1
answer
34
views
Seeking Python module to find volume of xyz data [closed]
I have an xyz file in the following format:
720567.698,733950.021,-4.20
720567.698,733949.021,-4.04
720567.698,733948.021,-3.86
720567.698,733947.021,-3.68
720567.698,733946.021,-3.45
720567.698,...
1
vote
0
answers
20
views
QGIS: 'Incorrect parameter value for AGGREGATES' when using Aggregate in a Python-Processing-Script
I am currently working on a QGIS-Python-Processing-Script that creates an automated street register for a printed city map as a CSV file.
In that context I want to give the user the option to choose ...
1
vote
0
answers
26
views
Extract value from raster layer according circular buffer from vector layer ,Anaconda
I have 2 layers raster and vector , vector is have one value coordinate , i try to read it and create buffer of 5 km , i did it and save the new buffer as polygon .shp file format, but the problem is ...
0
votes
1
answer
27
views
Converting a NetCDF with multiple variables to GeoTIFF calling GDAL_TRANSLATE function from Python
gdal_translate -a_srs EPSG:4326 NETCDF:"file_name.nc":variable_name output_file_name.tif -a_ullr -9.21200 53.28058 -8.88045 53.11338
I am working on some NetCDF files that include multiple ...
1
vote
0
answers
45
views
Shapefile field precision change python
I have a shapefile where some columns from the attribute table of this shapefile have "Double" datatype with precision 15 (see below)
How can I change it to have precision 2 using Python?
...
-1
votes
0
answers
16
views
I m computing queens contiguity PySal weigth but i have problem that w.n!=dataframe dimension [closed]
Im computing the spatial weights in GeoDataFrame but i have a different dimensions between the weights dim and the rows dim... because I want these two dim to be equal!!!
w_queen = weights.contiguity....
1
vote
0
answers
15
views
Georeference and Rotate an image using GDAL and python
I have a drone image with no spatial reference (ungeoreferenced). I know from some calculations the coordinates of the upper left corner, and X and Y resolutions. I was able to georeference the image ...
1
vote
1
answer
17
views
Why is h3.polyfill(geojson, 15) returning empty list for this polygon?
I have a polygon the size of an office block in WGS84 coordinate system.
When I run h3.polyfill at resolution 15 it should return a large number of h3 res15 addresses whose centroids are contained in ...
0
votes
0
answers
13
views
Earth Engine only upload files if they don't exist - CLI
I am uploading images to an image collection using the EE command line interface. The problem is that I am uploading more than 3,000 images. So after the first 3,000 finish and I go to upload again ...
1
vote
0
answers
11
views
How to use gdal2tiles in python and skip/exclude blank tiles
I am using gdal2tiles in python. It all works well. In gdal the flag -x can be used to ignore empty tiles, however in the gdal2tiles documentation there does not appear to be an option for this ...
1
vote
1
answer
23
views
Increase map size with subplots and Cartopy
I try to make subplot maps with Cartopy using data from xarray tutorial and increase each map in vertical size, but failed. Also making colorbar at each specific subplots.
import matplotlib.pyplot as ...
1
vote
0
answers
19
views
QGIS 3 QgsVectorFileWriter.writeAsVectorFormat creates empty shapefile
the code below only creates empty shapefiles layernew, looks fine in the display ,correct crs etc. It doesn;t error just shp's are all 1 kb it was modified from a qgis 2 whiich did work
...
2
votes
0
answers
16
views
Unable to convert Sentinel-5P NetCDF file to GeoTIFF using xarray python
I am trying to convert Sentinel-5P NetCDF file (available at https://drive.google.com/file/d/1zw8kSPZPRIu_YDxixIlOByPCY19GNMbz/view?usp=sharing) to GeoTIFF using the following code:
import xarray
...
-2
votes
0
answers
50
views
RuntimeError: input(): lost sys.stdin [closed]
I am having problem converting my .py file into .exe as I keep getting a lost sys.stdin runtime error.
I am new to Python.
import math
print(' please give all measurements in metres)
...
1
vote
1
answer
24
views
How to convert crs_wkt starting with GEOGCRS to a ogc_wkt string (to use rioxarray.reproject_match)
I have two xarray data arrays (1. land_data, 2. climate_data) that I want to reproject and match (rio.reproject_match()):
climate_data_matched = climate_data.rio.reproject_match(land_data)
Land data ...
0
votes
1
answer
40
views
How to loop for create a multi-page TIFF (Layer Stack)
So far I use python to create a layer stack for each pair of TIF files now l am looking for the solution to loop this process.
This is my code for creating a layer stack.
import os
from osgeo import ...
1
vote
1
answer
28
views
GeoPandas reading coordinates in inverse order
I have no knowledge or experience related to geosciences. I have a list of addresses from Rio and I used GeoPy's geocoding (the Google API) to find the coordinates associated with these addresses. ...
2
votes
0
answers
28
views
Weighted zonal statistics in Python
I'm asking something similar than Weighted zonal statistics in Python and/or R. I know very well the R-side of this question, but I can't figure out the answer for Python.
So far I can compute non-...
0
votes
1
answer
34
views
Why do rioxarray reprojection and pyproj transform give different values when selecting a pixel by point coordinates?
I'm opening this grib file using rioxarray and reprojecting to WGS84 in the following manner with the goal of grabbing pixel values by coordinates.
import rioxarray
url = 'https://noaa-hrrr-bdp-pds....
0
votes
0
answers
14
views
ST_AsRaster equivalent function in Python
I have a table in PostgreSQL such as the one below.
fid
name
rating
geometry
osgb43210
Smith Street
1
POLYGON ((507300.52 428808.91, 507299.2 428814.15, 507298.48 428813.98, 507299.37 428808.68, ...
0
votes
0
answers
11
views
Reading Sentinel-5P data throws "UnicodeDecodeError" using rioxarray Python
I am trying to read Sentinel-5p data using following code:
import rioxarray
netcdf_fname = r'D:\Projects\S5P_OFFL_L2__CH4____20220509T074431_20220509T092601_23678_02_020301_20220510T234447.nc'
rds = ...
1
vote
1
answer
21
views
Extract by polygon from a rioxarray's raster
I'm attempting to extract NBR mean value from MODIS data based on a set of polygons. The polygon set has overlapping everywhere (don't blame me, it's not my work nor my idea). The shapefile is ...
0
votes
1
answer
24
views
Converting GEE Javascript to Python using geemap not working
I'm looking to convert my code to calculate the mean 30 year precipitation from ERA5 in GEE into Python so that I can run it in the ee python command line tool. I tried using the geemap conversion ...
0
votes
0
answers
32
views
Can't read a shapefile in geopandas due to encoding
I'm working with ArGIS Desktop 10.5 and python 2.7, and just installed geopandas to try it out.
However, when I tried to read a shapefile, I received an encoding error:
import arcpy
import geopandas ...
0
votes
0
answers
10
views
Automate Aligning 2 orthomosaic with Python?
I’m trying to geo-reference an orthomosaic to another one automatically with python. Basically, I have 1 orthomosaic from 2020 year and 1 from 2021. The resolution of the ortho is 2 cm.
Currently we ...
0
votes
0
answers
15
views
Plotly Dash - TypeError: Object of type Polygon is not JSON serializable
I am attempting to plot choropleth map using dash and mapbox. At runtime, I am getting an error "TypeError: Object of type Polygon is not JSON serializable".
sample data and code:
import ...
0
votes
1
answer
26
views
What does "del aprx" at the end of Python code do?
More of a general/theoretical question:
Often times a Python code for ArcGIS Pro requires the statement "del aprx" at the very end, what does this statement do and is it necessary?
I ...
1
vote
1
answer
28
views
geopandas error "OSError: could not find or load spatialindex_c-64.dll" in PyCharm using OSGeo4W paths
Using https://spatialgalaxy.net/2018/02/13/quick-guide-to-getting-started-with-pyqgis3-on-windows/ I created a .bat file to load the OSGeo4W and QGIS paths into PyCharm. Now I am getting an error ...
0
votes
0
answers
16
views
How to stack multiple bands from many dates in Python?
I have this folders:
and inside them there are sentinel2's raster bands. I'd like to stack them and return the stacked tiff to its folder. How do I do that?
1
vote
1
answer
24
views
QgsVectorLayer no attribute setLayerName QGIS 3
What's the equivalent in QGIS3 of
layer = QgsVectorLayer.setLayerName()
1
vote
0
answers
16
views
Can I uninitalize earthengine?
I'm benchmarking different implementation of a workflow based on the GEE Python API. The code does something as the following:
%%timeit
ee.Initialize()
# do ee related stuff
I would assume that ...
0
votes
1
answer
25
views
Add projection to rioxarray dataset in Python
I've downloaded a netcdf from the Climate Data Store and would like to write a CRS to it, so I can clip it for a shapefile. However, I get an error when assigning a CRS. Below my script and what is ...
1
vote
0
answers
26
views
rasterio mask fill nodata with np.nan: TypeError: Cannot convert fill_value nan to dtype uint8
I'm facing troubles while reading a raster dataset having uint8 value when trying to fill the nodata gaps with np.nan.
The following function works like a charm for opening a GeoTIFF DEM (having ...
2
votes
2
answers
38
views
Getting wrong coordinates converting UTM to lon/lat with Proj
I have tried many ways to convert UTM to lon/lat, and getting always the same weird result.
Getting UTM and lon/lat for a point using GoogleEarth:
from pyproj import Proj
lon = -40.729124
lat = -20....
0
votes
1
answer
26
views
Insert a waypoint into a POSTGIS table with psycopg2 and ST_GeographyFromText
I am trying to insert a waypoint into a table with 1 foreign key refererance and a geography point in PostGIS. I am having no luck.
The table structure is
CREATE TABLE route
(id serial ...