Questions tagged [python]

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

Filter by
Sorted by
Tagged with
4
votes
2answers
68 views

QGIS - Python Error on Startup (Ubuntu 18.04)

After installing the 3.4.x Madeira LTR release, upon opening QGIS I am encountering the following error: Couldn't load SIP module. Python support will be disabled. Traceback (most recent call last):...
0
votes
1answer
53 views

Creating 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
84 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 in Python, including the pixels with value 0. Related questions: Converting ...
2
votes
1answer
44 views

Fixing 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
126 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
1answer
45 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
1answer
30 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
24 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 ...
2
votes
0answers
18 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
95 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
69 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
36 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
1answer
52 views

Updating 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
39 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
35 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
43 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
54 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 "...
1
vote
1answer
28 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
43 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
78 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
88 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
68 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
51 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
25 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
41 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
54 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
33 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
64 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
90 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
18 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
58 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
55 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
49 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='...
1
vote
1answer
63 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
112 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
111 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
45 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
62 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
28 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
29 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
70 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
36 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
42 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....
2
votes
0answers
24 views

Run Schelling's model of segregation on a geographical map instead of the matplotlib plot or grid

If you don't know what is Schelling's model of segregation, you can read it here. I have written the following code to run the Schelling's model of segregation simulation. import matplotlib.pyplot ...
1
vote
0answers
57 views

Raster nodata = -3.4028234663852886e+38 [closed]

I'm very new to raster manipulation, and I'm getting a nodata value of -3.4028234663852886e+38 when importing USGS NED 1/3 arc-second n41w074 1 x 1 degree IMG using rasterio on Python. What is it ...
2
votes
2answers
45 views

Creating new GRASS locations while looping in Python script

I am making a Python script for processing my data. import grass.script as grass import numpy as np def main(): f = open("D:\\Glaciers_selected.csv", 'r') fl = f.readlines() for x in ...
0
votes
0answers
39 views

Creating virtual tiles of raster in Python?

I have a large raster and want to analyze it on smaller subsets but also want to save space so I am trying to avoid actually tiling the raster. Is there a way to make virtual tiles that python can ...
1
vote
1answer
284 views

AttributeError: 'NoneType' object has no attribute 'bounds'

I have the following geodataframes, corresponding to a regular grid: id grid_id geometry 0 48 0 (POLYGON ((2.052457758079306 41.42493869117656... 1 49 1 ...
1
vote
1answer
75 views

Get non-masked values of multiband numpy masked array

I am working on a multiband image with python. I imported my image as a masked numpy array of shape (bands, rows, cols) using rasterio. The mask is the same for all bands. I would like to get the ...