Questions tagged [python-3]
Use this tag when Python 3 (or any of its dot releases) is the version you are using.
296
questions
0
votes
0
answers
21
views
Upgrade Python version and reinstall QGIS result in Python Error
Recently, i installed additional Python 3.8.15 version on my Ubuntu 20.04. python3 --version results in Python 3.8.15. The path of this version of python is: /usr/local/bin/python3 .It is set as ...
0
votes
0
answers
18
views
Remove NaNs of DWD's HYRAS-DE-PRE Netcdf clipped with shapefile
I have a netCDF file from the German Weather Service (DWD), with daily precipitation sums (HYRAS-DE-PRE) https://opendata.dwd.de/climate_environment/CDC/grids_germany/daily/hyras_de/precipitation/...
3
votes
1
answer
47
views
Esri Data Loading Tools don't generate data loading workspace
Recently, I deployed the Esri Data Loading Tools Python package into my cloned environment within ArcGIS Pro 3.0.3. With the process pretty fool-proof, given Esri's package manager interface, I was ...
1
vote
1
answer
196
views
shapely | Binary mask of Polygons' intersection
Goal: Create a binary 2d-array, that represents Points of intersection of a square Polygon with a MultiPolygon.
from typing import List, Tuple
import numpy.typing as npt
from shapely.geometry import ...
1
vote
1
answer
326
views
Shapely Polygons | Calculate Intersection of Union
Goal: Calculate 8 different Intersection of Union area numbers, each concerning the intersection of 3 MultiPolygons.
There are 3 sources, each representing the same 8 groups of shapes.
Mathematically, ...
0
votes
0
answers
62
views
Managing style file in ArcPy using ArcGIS Pro
I am trying to update a geoprocessing service that was in ArcMap to ArcGIS Pro. The geoprocessing services use a style file for its legend and I want to update certain legends but I have no idea how. ...
0
votes
1
answer
256
views
Folium TimeSliderChoropleth with tooltip?
I have followed an online example of using Folium to create a choropleth map with a timeslider, similar to what Aoife Currano has done in this magnificent post on mapping the spread of COVID back in ...
0
votes
2
answers
92
views
Lon and Lat flipped when converting MODIS to Lat Lon
I found a code online that plots MCD19A2 tiles correctly, but I need to make manipulations to the data, and not just plot directly so I am making my own code for that.
I basically copied the code I ...
0
votes
0
answers
387
views
How to add a tooltip to a Folium TimeSliderChoropleth map?
I have created a choropleth map in the Python library Folium using a TimeSlider plugin, and to this map I am trying to add a tooltip so that a user can interact dynamically with underlying data. I've ...
0
votes
0
answers
32
views
Load GRASS raster layer in QGIS, with Python console
Is there any suitable set of Python commands that I could use to load GRASS raster layer in QGIS Python console?
I tried this simple code:
from qgis.core import QgsRasterLayer
from PyQt5.QtCore import ...
1
vote
0
answers
233
views
Why will Geopandas not read geopackage into dataframe? [closed]
I am trying to read in a geopackage as a dataframe using Geopandas. I am using Python 3.8, Geopandas 0.10.2, and Fiona 1.8.20. The geopackage I was using to test this is publicly available in any of ...
2
votes
2
answers
430
views
Draw a normal from a point to a line
How to draw a normal LineString (AB) to existing LineString (CDEF) from a given Point (A)?
Shapely version == 1.5.16
0
votes
1
answer
133
views
How do I open certain window from raster file
I have a geodataframe with some bounds and I'd like to open that specifc box from the raster file. Lets say my raster file is name data.tiff so my current code is like:
import rasterio as rio
from ...
0
votes
1
answer
703
views
Xarray Dataset to raster - ValueError: failed to prevent overwriting existing key grid_mapping in attrs
I have a netcdf file located here http://thredds.northwestknowledge.net:8080/thredds/catalog/TERRACLIMATE_ALL/data/catalog.html?dataset=TERRACLIMATE_ALL_SCAN/data/TerraClimate_tmin_1958.nc.
I am ...
0
votes
1
answer
190
views
gdal.Warp - set env var
I set up an ubuntu 18.04 EC2 through AWS that "On Start" will run a python script in which will download a .tif from an s3 bucket and project it from EPSG:4326 to EPSG:3857 using gdal.Warp()....
0
votes
1
answer
118
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 ...
1
vote
0
answers
72
views
Visualize transformation when reprojecting from Mercator to equirectangular
I am trying to visualize the map distortion that occurs when reprojecting from Mercator to equirectangular coordinate systems. The actual reprojection is not difficult, but I want to save images (...
1
vote
1
answer
245
views
Trying to use GDAL in Windows Apache WSGI with Python 3.9.5 from OSGeo4W
Not much is missing and I'm going crazy. I'm pulling my hair out to get GDAL running under WSGI in Windows Apache using a Python 3.9.5 Installation from OSGeo4W.
I have installed QGIS 3.24.2 with GDAL ...
1
vote
0
answers
77
views
Fatal error using orfeo toolbox (otb 8.0.0) algorithm Computeconfusionmatrix in QGIS 3.22
I tried to compute a confusion matrix of a raster classification with otb's Computeconfusionmatrix using vector data (polygons) as reference input. When I run the same algorithm in mapla (otb ...
1
vote
1
answer
96
views
Error with new QGIS version no attribute 'isatty'
I have a make QGIS plugin it work on QGIS 3.10
But when I try to make it work on QGIS 3.14 + I dot some error
I have install QGIS 3.22.5 and I have see few error:
pip install pythonnet have to be ...
7
votes
1
answer
248
views
Add parameter to connect in Python
I have a plugin in QGIS 3.4.
I have connected layer.selectionChanged.connect(self.AfterSelection) and I call the selected layer to know which feature is selected, but when I use the 'Clear Selection' ...
1
vote
0
answers
130
views
Is there a rioxarray version of xarray pad
I have a geocoded raster that I'd like to pad with NaNs to 64 x 64 pixels. I've tested rioxarray.DataArray.pad_box(), which does work, but it's a bit complex to calculate new bounding box corners that ...
1
vote
2
answers
595
views
rio.write_crs() leaves empty crs
I have a dataset ds which looks like this:
<xarray.Dataset>
Dimensions: (time: 42, long: 1383, lat: 586)
Coordinates:
* time (time) datetime64[ns] 1979-01-01 1980-01-01 ... 2020-...
0
votes
1
answer
282
views
Create a function that will return geodataframe
I have created the following function to take Origin = str, Destination = str, line = shapely.geometry.linestring.LineString, node = GeoDataFrame
def create_lines_df(Origin, Destination, line_, nodes_)...
3
votes
1
answer
697
views
Converting ArcGIS Spatially Enabled Dataframe to GeoJSON
I've got a spatially enabled dataframe (SEDF) I'm trying to convert to a GeoJSON. Normally I do this as a 2 step process by creating a featureclass then converting that into a GeoJSON with SEDF....
1
vote
1
answer
464
views
Changing GeoJSON key name
I have a multi-level GeoJSON file and I need to create a new geometry field within it that is a copy of the old geometry field but with a different key name. The new geometry field would exist in the ...
0
votes
0
answers
813
views
GDAL not installing for Python on Windows
I have used pip install GDAL in the command prompt to install the GDAL package in my Python Library (Python 3.6). It has successfully installed - version 3.3.3
However, when I go into Visual Studio ...
1
vote
1
answer
1k
views
Subsetting a Pandas dataframe based on latitude and longitude values and coordinates of a circular boundary in Python
I have a dataset with coordinates (LAT and LON) and boundary coordinates of a circle (shown in the figure below). I want to subset a dataset based on coordinates of this circular boundary for getting ...
1
vote
1
answer
519
views
How can I use the Python osgeo/ogr library to export a feature layer to CSV with geometries coded as WKT?
How can I read in a layer's data using the python osgeo/ogr library and then export the whole attribute table and an extra column with the geometries coded as WKT to a CSV format?
I know that this is ...
1
vote
1
answer
172
views
Exporting NetCDF file in MODIS sinusoidal grid with xarray
I have 18 TIFF files in the MODIS sinusoidal grid I would like to convert to one file in NetCDF format. I have converted the tifs to an xarray xarray.core.dataset.Dataset format called stacked. At ...
1
vote
1
answer
665
views
Exporting geodataframe to shapefile to match DBF format of ArcGIS export
I have a shapefile I created with GeoPandas that I am unable to use in a 3rd party application. The problem seems to lie with differences in how integer fields are being interpreted vs a shapefile ...
0
votes
1
answer
70
views
Update point fields with fields in intersecting polygon
I get new points (inspections) every day. Each point falls within a polygon (district).
I need to update 3 fields (Week, RecycleRt, RecyCollDay) in the point feature class with the district fields.
I ...
1
vote
1
answer
122
views
Error using SQL statement in ogr2ogr with Python string formatter
I am iterating through a list of shapefiles and extracting subsets of each shapefile to save as a KML using ogr2ogr. How can I extract the subset based on multiple conditions while using string ...
2
votes
1
answer
414
views
Polygon simplification without intersection in GeoPandas/Shapely
Is there an in-the-can solution for simplifying a boundary that won't intersect the original poly?
Something like .convex_hull but with a fillet option possibly?
For example, .simplify() produces ...
1
vote
0
answers
90
views
QGIS 3.20 failed dependency in qgis_core on libQt5Concurrent
I wrote a Python application that successfully uses QGIS on OSX. I now want to 'freeze' it. Building an app after using the kyngchaos packages resulted in all sorts of issues finding components. I ...
5
votes
1
answer
308
views
Difference between LINESTRING((x1 x2), (x3 x4), (x5 x6), (x7 x8)) and LineString([(x1,x2), (x3,x4), (x5,x6), (x7,x8)])
I am a little confused about how objects are being defined and represented and mostly because some of the solutions I find for solving issues I have demand that the input data be in an other form than ...
2
votes
0
answers
207
views
Shapefile topo projections not displaying all data using geopandas, geoplot, and matplotlib
I'm currently trying to display topographic map data for an area. Although the data that is displayed is showing up correctly, there are visible chunks missing from the final projection. I don't have ...
2
votes
1
answer
692
views
Converting PBF to GeoJSON using python3-gdal module
How can I use the module python3-gdal to convert .pbf into .geojson using Python?
I've been exploring ogr in python3-gdal module but I can't figure out how to make it work.
I do a request, the ...
4
votes
1
answer
214
views
Split the column into several and unpivot the columns
I currently have 2 columns NOM_CONCAT and Number of concat(COUNT_RSF_)
which is composed of" concat "from 0 to 5
A1, B1, C1 ...
A2
A3, B3
.
.
My goal and to separate the column ...
0
votes
2
answers
144
views
Does not display Map in Rstudio using Python Package - GEEMAP
I am trying to use the GEEMAP package of Python in RStudio-1.4.1106.
After importing the packages and running the code shown below MAP is not displayed rather it displays the MAP attributes in the ...
1
vote
1
answer
726
views
Transform Google Earth Engine script to Python with Landsat 8 temporal data
I am doing a study for my work and I need to adapt my Google Earth Engine script in Python, but I am encountering some problems.
Here is a Google Earth Engine script:
//Importing image and geometry:
...
2
votes
1
answer
477
views
FionaDeprecationWarning: Collection.__next__() is buggy and will be removed in Fiona 2.0. Switch to `next(iter(collection))`. record = next(c)
I have some Python3 code used to import shapefiles using fiona. This is the main set of lines:
I created some code (Python3) with these lines:
c = fiona.open(dataDir + "/" + sourceFile, ...
1
vote
1
answer
1k
views
Extracting only roads through Overpass API query
I am using overpass API and querying the api for ways,as a result it gives points, whereas I need only lines, multiline strings and polygons. But while using the following code, I get a GeoJSON file ...
0
votes
0
answers
74
views
How to check integrity of Python-processed shapefile
In my QGIS project of American railroads, using USGS Base Topo Layer and shapefiles giving railroad details as of 2015, I have used the Python-3 pyshp library to edit the dbf database, adding some ...
0
votes
2
answers
917
views
Executing QGIS tools in Python from Linux Shell [duplicate]
I would like to execute a Python script which uses QGIS Processing tools.
On Ubuntu 20.x I installed qgis, qgis-common, python3-qgis and python3-qgis-common.
My objective is to execute the tool Exploe ...
2
votes
0
answers
471
views
Deleting GDAL created raster
I am simply trying to delete a TIF that I created with GDAL. I have tried, simply, to use shutil which errors with:
NotADirectoryError: [WinError 267] The directory name is invalid:
'T:/p003M01p0001/...
1
vote
0
answers
163
views
Why does my arcpy script's da.UpdateCursor get slower the longer it runs?
I have a layer containing pedestrian crosswalks (line features), and two layers containing street data: street segments (line features) and street nodes (point features). Every street segment has a ...
3
votes
0
answers
131
views
CalledModuleError: Module run None g.gisenv -n ended with error
I am trying to use r.horizon GRASS module(version GRASS 7.8) in Python script. But I couldn't able to access the grass modules. Everytime, I am getting the following error.
File "C:\OSGEO4~1\apps\...
2
votes
0
answers
68
views
GRASS GIS: r.out.gdal raises an exception and hangs if it's called multiple consecutive times
I'm using a small python routine (grass.script, pygrass) to handle several operations on sentinel2 imagery. I'm calling r.out.gdal inside the script and a very annoying problem occurs: when it is ...
1
vote
1
answer
186
views
Using GRASS i.segment in Python 3 stand alone script on Windows10
I installed GRASS GIS 7.8.1 on Windows 10 using a OSGeo4W.
I would like to use in a stand alone Python 3 script the i.segment GRASS tool.
I saw some related questions (e.g., Using GRASS GIS in Python ...