Questions tagged [python]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

Calculate the number of faces

I am a beginner in PyQGIS. I need to make a program to count the number of faces in a geometry. The number of fields I want to calculate is inside a shapefile. How do I do that? the number of fields ...
0
votes
0answers
5 views

How do I use PyQGIS to modify an attribute within a dictionary in a layer's attribute table?

I am automating the process of putting data collected in the field for a city's sewer system into QGis. With this script, I am trying to transfer the "tc" (top of casting, it's an elevation value) ...
1
vote
1answer
10 views

Iterating through table for IDW says parameters are not valid

I have a table with precipitation data from 5 weather stations and I am trying to iterate through the table to perform IDW on each field (month of precipitation). import arcpy from arcpy import env ...
0
votes
0answers
15 views

QGIS polygon to line with neighbor info

Is it possible to create lines from polygons with information about neighbors in QGIS? I would like to do this for land plots. There is a tool in ArcMap that works like a charm, but I do not see ...
0
votes
0answers
14 views

How to create polygons from centroids in Python for an interactive map

I have a geopandas dataframe where each record is a point. I am making an application using Flask and Python and would like to display an interactive map in HTML where the points would be transformed ...
1
vote
0answers
27 views

Converting a raster pixel by pixel to vector cells in Python

Problem Today I needed to convert raster to a shapefile with rectangular polygons representing each pixel of the raster, including the pixels with value 0. Related questions: Converting raster ...
1
vote
0answers
13 views

How to fix colors of LISA Cluster maps from Pysal

I am using the LISA Cluster package from Pysal to create a LISA (Local Indicator of Spatial Autocorrelation) map. As the example of the documentation shows, the color lightblue is used to identify ...
0
votes
1answer
51 views

Getting latitudes and longitudes in between start and end coordinates and spaced at equal distance

I have a csv file which has the latitude and longitudes values , I need to find the coordinates in between the start and the end latitude and longitude which must be equally spaced at the interval of ...
1
vote
0answers
21 views

How to not overwrite with NoData values when updating a raster file using a numpy array?

I have a numpy array (called out_window) with the following values: out_window: [[[499 498 481] [494 490 464] [483 480 -1] [482 -1 -1]]] This numpy array was obtained by clipping a raster ...
0
votes
0answers
16 views

Extracting current and future individual RCPs (2.6, 4.5, 6.0 and 8.5) for Current, 2050 and 2070 and specific months [on hold]

Worldclim has several GCMs (global climate models). Has Four RCPs (representative concentration pathways) (2.5, 4.5, 6.0 and 8.5). Has three time steps (Current, 2050 and 2070). How can I use R or ...
0
votes
1answer
22 views

GetRasterBand()Method for GDAL in Python

I'm working on getting the NDVI value of Landsat imagery 2018 using band 4 and 5 but I have encountered a slight problem. import osgeo from osgeo import gdal#gdal, data conversion tool from ...
0
votes
0answers
27 views

Infer stops and traffic signal from GPS traces [on hold]

I work in a hive database of GPS traces. I would like to know whether there is a library in Python or in R (OR SIMILAR PROJECTS) that deals with the same. My approach is to calculate distance between ...
0
votes
0answers
16 views

Speed- and COG-aware trajectory interpolation/resampling using Python

I have a set of ship trajectory points that were irregularly sampled and I would like to resample them to a fixed frequency (e.g. every minute). Rather than just linearly interpolating between ...
-1
votes
0answers
30 views

Python Script that flags incorrect attribute numbers based on another attribute's number [on hold]

I have an Excel file that contains two columns. One column is a shape area field for impervious surface and the other column is a stormwater fee constant based on the impervious surface. The ...
2
votes
0answers
12 views

Horizontal color lines artifacts / bug with GDAL Tiff

I would like to document a bug I encountered, and scratched my head against several hours: I wrote a python script for extracting (cropping) many images from a big TIF image. I used both gdal....
1
vote
1answer
55 views

Find in between coordinates for the given latitude and longitude from a CSV file

I have a CSV file which has the latitude and longitude values for the start and the end coordinates as follows. In these the first lon and lat values are the start point then the second coordinates ...
3
votes
1answer
28 views

Value NAN in netcdf4 file for lat&lon using python

I have two file netcdf4 ( latlon and other file without latlon) i open the 2 file in the same code and i choose one variable and the two variable lon and lat when i write lon i have the value nan i ...
1
vote
0answers
28 views

Downloading XYZ tiles within QGIS? [duplicate]

I understand that it is possible to use a Python expression formula to batch download XYZ tiles within QGIS. I also understand that that expression/formula has been written and has previously appeared ...
1
vote
0answers
25 views

How can I update a subset of raster values using open source python (rasterio, for instance)?

I have a source raster data set (tif file) and a number of polygon features. For each one of those polygons I need to: a) 'clip' the raster. b) change values of those clipped raster cells (with the ...
0
votes
0answers
27 views

Joining file pair for batch gdal_merge.py

I am new to Python and I have been going through past questions and searching trying to determine best way to batch mosaic files. I have a list of .tifs that have been converted from .hdf files I am ...
1
vote
0answers
22 views

Calling a temporary layer in PyQGIS

I have the following PyQGIS script (see below) which works fine except from one issue: The input vector layer I would like to use is a temporary file. How can I call a temporary layer (which does not ...
2
votes
0answers
36 views

Delayed function calling inside QgsTask

I try to add a function to the qt event loop via QTimer.singleShot(...) from within a QgsTask. However the function is never executed. I wrote a short script that isolates this issue: import time ...
0
votes
0answers
33 views

Constructing boundary polygon around raster image when mask layer is ill-defined using GDAL with Python?

I have a raster image and I want to construct a new vector layer that has the boundary of the raster, using python. Below is a sample of the image. The problem is that the nodata value is set to "...
0
votes
1answer
22 views

Insert empty VIEWS into QGIS from PostgreSQL using PyQGIS

The Aim: I am trying to insert a number of empty VIEWS into QGIS using PyQGIS. These VIEWS have been created and stored in a PostgreSQL database. I want to also ensure i can successfully re-open ...
0
votes
1answer
31 views

clipping a vector layer with another vector layer using python

Sorry if this there is a really obvious solution to this question. I did not have any luck googling and looking at different books. I have an OSM vector layer that I want to clip with another vector ...
0
votes
0answers
40 views

Read contents of KML file into CSV format using Python (BeautifulSoup)

I have a KML file called Layers.KML which has multiple sub folders - Tree_Heights_Elevations, 20190516 - Chain Link Fence, 20190516 - Clearing Limits, 2016-0516 - Solar Array . ...
0
votes
1answer
46 views

Reprojecting data with GeoPandas using 'to_crs'?

I am trying to reproject a polygon so that it has the same projection than a raster dataset. raster.crs CRS({'proj': 'tmerc', 'lat_0': 0, 'lon_0': -183, 'k': 0.9996, 'x_0': 500000, 'y_0': 0, 'datum': ...
1
vote
1answer
31 views

Method 'to_crs' to reproject with GeoPandas is missing

I am trying to reproject data using GeoPandas' to_crs method but it seems to be missing. When I type hasattr(gpd, 'to_crs') I get FALSE. Also, when I type dir(geopandas) in the command prompt it doesn'...
1
vote
2answers
40 views

How to calculate number of vertices in GeoPandas

Is there any method to count number of vertices of polygon (or multipolygon etc.) that is in 'geometry' column in datatable, but using GeoPandas? Example: Let's say I have polygon POLYGON ((552971....
2
votes
0answers
21 views

Creating Swath View from Point data using Python?

My situation Input: point data from planting file Feature Attribute: [('DeletionFlag', 'C', 1, 0), ['Field', 'C', 254, 0], ['Dataset', 'C', 254, 0], ['Product', 'C', 254, 0], ['Obj__Id', 'N', 15,...
2
votes
1answer
26 views

Sentinelsat: Error trying to download from Norweigan mirror colhub.met.no

I am trying to download the Sentinel 2 images over an area of Western Norway. Since the ESA archive is very slow, I am trying to use the Norwegian mirror for Sentinel instead (https://colhub.met.no/#/...
2
votes
1answer
32 views

QGIS dll load fail with from qgis._core import *

I have a error in console python, I tried using pyqgis without qgis interface. My problem is when I use: from qgis.core import * Console's the message is: from qgis.core import * Traceback (most ...
1
vote
0answers
31 views

All 0s result from raster calculator in python

Raster calculator is not working correctly for a single calculation using a standalone Python script. I am trying to add 1 to a pre-existing raster. It processes, but the resulting tiff file is all 0s....
1
vote
1answer
59 views

QGIS script for filling fields in attribute table

I want to write a script that will fill field values in the attribute table the following way: There are dots with attributes and lines I am creating. I want the script to use the field value of the ...
0
votes
0answers
23 views

Visualizing queue length with colored Polylines - Folium

I have a bunch of PolyLines that i want to color code based on the length. I managed to change the color of the entire line, based on the length of a line segment (between 2 of 6 points), but I am ...
-3
votes
1answer
16 views

run function multiple times [closed]

i have a list: my_list[8000,8001,8002] function: def print_function(number): print(number) What do i want? I want to run the function multiple times, in this example 3 times with the numbers ...
0
votes
1answer
35 views

Remove Cloud Cover with Python Earth Engine API

I am attempting to use google's cloudscore methodology to remove clouds from LANDSAT8 imagery. I am using python to do this. I can get this to work in java from the web code editor, but am unable to ...
1
vote
0answers
47 views

How can I compute confusion matrix using Python [closed]

My project is about "Extracting water and urban features from satellite images". I have extracted urban and water features using Python code. Now, I want to do accuracy assessment. I know two primary ...
2
votes
1answer
32 views

Unable to load geometry field from geodataframe to a PostgreSQL table 'geometry' field

I am trying to load a geodataframe to a PostgreSQL table, but I am struggling with the geometry field. First I read feature class using Geopandas: geodata = (r'path_to_gdb', driver='FileGDB', layer='...
0
votes
1answer
34 views

Cannot access LibKML driver using OGR in Python

I am trying to read a kmz file using OGR in Python. I believe the standard driver for reading .kmz files is LibKML (Can ogr2ogr read .kmz files? How?), but I am only getting None when I am building ...
2
votes
2answers
102 views

How to load the geometry field of a feature class to PostgreSQL?

I am trying to load a polygon feature class in a file geodatabse to a PostgreSQL table (extension PostGIS installed). This the process I'm following: I create table in PostgreSQL with required fields ...
2
votes
1answer
65 views

Creating equally spaced coordinates on California state map created with basemap?

I have created a California state map with basemap Python library and this shapefile. Code is below from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt fig, ax = plt.subplots(...
2
votes
1answer
37 views

arcpy.da.NumPyArrayToTable() RuntimeError: Unspecified error

Using arcpy for ArcGIS Desktop 10.7.1... In order to append data from a Pandas data frame to an ArcGIS table, I am attempting to create a temporary in-memory table from the Pandas data frame as ...
1
vote
1answer
29 views

Opening EOS netCDF4/HDF5 file with correct format using xarray?

I am using xarray (version 0.12.2) to work with the MODIS/Terra+Aqua MAIAC Land Aerosol Optical Depth dataset (MCD19A2.006). xarray successfully opens that dataset with the correct variables and ...
1
vote
0answers
11 views

Setting layer blending as additive with opacity in Kepler GL for Python

I'm using KeplerGL in python (in a Jupyter notebook) to plot polygons on a map with different layers. After setting the layers, I've tried to find where can I edit their opacity when adding them up, ...
1
vote
0answers
23 views

Geopackage vector data type

I am reading a shapefile in Python using geopandas, join some tabular data and export to geopackage using geopandas. The entire process is very easy. However, when I export the vector data, the file ...
0
votes
1answer
30 views

Finding overlapping areas between two or more GeoTIFF files

How can one programmatically understand overlapping areas between two or more GeoTIFF files captured at various timestamps for the same location?
0
votes
0answers
24 views

Unsupervised classification using Python? [duplicate]

Is there a way to use unsupervised classification with satellite images to determine similar regions using python with gdal or with any library?
1
vote
1answer
31 views

Error on Line 109 of Creating Random Points in Layer Bounds Tool

I am using the latest version of QGIS 3.6.3 and I am getting the same error regardless of what I do when trying to run the Create Random Points in Layer Bounds tool. Here is the error: QGIS version: ...
1
vote
1answer
32 views

Calculate area, length, width of rectangles in shapefile with Python

I have a list of rectangles imported from a shapefile into Python in degrees. (EPSG:4326) rectangles = [{'type': 'Polygon', 'coordinates': [[(-61.55002968237319, 73.546895599812856), (-61....