Questions tagged [python]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
54 views

Calculate area and perimeter of coordinate points in Python

I have a set of points that make up a polygon. I need to find the area and perimeter for the shape in Python. I have used the shapely library to calculate the area and perimeter but it is nonsensical ...
2
votes
1answer
26 views

Meaning of different elements of delivered json-Data-Structure when geocoding with Python and OpenStreetMap

I'm trying to do some geocoding in Python with the library geocoder and OpenStreetMap: import geocoder g = geocoder.osm('11 Wall Street, New York') print(g.json) Where can I get information about the ...
1
vote
0answers
17 views

How to reproject using gdal.warp

I am trying to reproject the raster data to "EPSG:4326", but getting this error : RuntimeError: Translating source or target SRS failed: EPSG:4326 and my code is: filename = 'mosaic_band1_1....
1
vote
1answer
210 views

How to get the file name from docked browser in QGIS 3x

Within QGIS 3x, there is a browser docked on the left hand side. I would like to use this in a python plug-in, how can I use the highlighted file and path within a Python Script? For instance to ...
4
votes
1answer
74 views

Make QGIS use a conda virtual environment for python libraries

I wanted to install a plugin, but it requires scipy. Thus I realized that QGIS use the default python3 installation. I tried to launch it from a conda virtual environment, as advised in this related ...
0
votes
1answer
22 views

Python - No module named '_gdal_array' only on virtual env

I'm trying to import gdal_array in python but I get ModuleNotFoundError: No module named '_gdal_array'. The strange thing is that this problem does not occur if I use system's python 3.8. It only ...
7
votes
6answers
6k views

Is there a way to disable code autocomplete in the Python window in ArcGIS 10.0

Autocomplete slows down my workflow in the Python window, especially if I am remoted into a machine. Is there a way to disable this? Alternatively, a way to disable this and then invoke as needed (...
0
votes
0answers
30 views

How to query all points inside a geometry object

I have a table named slope. It contains the columns X, Y, Z and geometry. The aforementioned values represents the x,y,z coordinates of a geometry. i have also an object named fieldGeometry which is ...
1
vote
2answers
30 views

shapely geometry - how to preserve refrence to original feature

What is preferred method to save reference from geometry to original feature when working with shapely geometries in python? Ie. After creating STRtree and getting some result from it, there is no ...
3
votes
1answer
37 views

Removing overlapping parts of polygons from the same layer in QGIS

I'm working on a favourability mapping based on geologic inputs. One of those inputs is composed of fault zones which in my case are represented as one unique polygon layer with one attribute that ...
0
votes
0answers
16 views

What is the easiest way to install libgdal 3.3.0 and header files (gdal-devel) on Ubuntu 18.04?

I would like to pip install GDAL 3.3.0 Python package, but it requires libgdal (3.3.0 or greater) and header files (gdal-devel). APT package manager repositories only have gdal-bin 2.4.2 and libgdal-...
3
votes
1answer
548 views

Performing kNN between two 3D sets of points (pointclouds)

I have two overlapping pointclouds, for this example I take the first 10, A[0:10] and B[0:10]. They are stored as tuples, [(x, y, z),...]. I want to compare the two based on their nearest x,y,z ...
0
votes
1answer
26 views

Modifying a Python script called in a shell command in Google Colab

I am relatively new to coding and am working on a script to average 24 hourly GRIB2 files to daily files and output to a TIF. I am currently doing this in Google Colab by calling a GDAL python script ...
1
vote
1answer
45 views

How do I avoid altering the data range when writing a NumPy array into a TIF file with rasterio?

I'm using a machine learning model to automatically recognize (a specific type of) vegetation in RGB imagery. The output of this model is a binary NumPy 2d array, with '1' meaning vegetation and '0' ...
2
votes
0answers
28 views

Disconnect users who are creating locks on specific feature classes

I have a nightly Python script which updates some domains in a geodatabase. The domain owner is "AMIS". In addition to the AMIS schema in the geodatabase, there are other schemas. In order ...
1
vote
2answers
37 views

Error: 'list' object has no attribute 'segmentAlongLine'

I am trying to trim each polyline in a shapefile down to the first 15 feet of each line. The segmentAlongLine method was suggested to me, but this code is getting the AttributeError: 'list' object has ...
0
votes
0answers
16 views

Rotating point feature on line feature in ArcMap

I have a line and a point feature class in ArcMap. I want to rotate the point feature on the line feature. I will use the Symbol Rotate Option with a defined field. I have a script for Field ...
2
votes
1answer
42 views

How to calculate the corner points of a grid if centre points are know

I am working with a file which has the coordinates in WGS84 format. From this file I have calculated the Cartesian coordinates using the following code: import numpy as np import pyproj from netCDF4 ...
1
vote
1answer
28 views

Create GeoTIFF images from TIFF image using the coordinates of the four corners

I have several TIFF images which were taken from an aircraft. The images are tilted. Hence, the orientation of the images are not in parallel to the grid system. Please do refer to the below image: (...
0
votes
1answer
39 views

Regenerate an isochrone through a widget in CARTOframes

Is there a way to re-generate an isochrone in a CARTOframes map from some kind of user interaction? For example, modify the minute's value: isochrones_gdf, _ = Isolines().isochrones(stadiums_df, [15*...
4
votes
1answer
51 views

Defining coordinate system for every GeoDataFrame (shapefile) in list

I am looking to set a coordinate system for every GeoDataFrame in a list of them. So I need this: gdfs[0].crs = "EPSG:6668" gdfs[1].crs = "EPSG:6668" And so on but iteratively. I ...
0
votes
2answers
38 views

Rasterio read outshape resample does not give correct array

I have a population grid and want to decrease the resolution by a factor 2. So I would like to get a raster that has 2 times less rows and columns, a resolution that is 2 times as large as the ...
0
votes
0answers
12 views

Validating a GML file using the XSD schema in Python [closed]

I'm a beginner. Can you tell me how I can validate a GML file with an XSD schema?
3
votes
4answers
2k views

How to import GeoPandas in QGIS 3.10

Here is the situation: I've installed QGIS 3.10 with the downloadable .exe file and accepting all as predefined. The Python version used with it is 3.7.0 like here: import sys sys.version '3.7.0 (v3....
1
vote
0answers
52 views

Extend the contours of the polygon into a polygon

I would like to be able to extend the vertices of one polygon to the edge of another polygon, how does the snapping between poligons using python. The photo shows a representation of my problem. I ...
1
vote
1answer
43 views

Reading a shapefile into networkx as undirected graph

import networkx as nx from networkx.algorithms import approximation as ax Road = nx.read_shp('/Users/benjaminhendel/Downloads/scatteredroads.shp') #Reading Road Data Base = nx.read_shp('/Users/...
1
vote
1answer
41 views

What is the syntax for assigning a feature attribute value to a variable in the QGIS Advanced Python Field Calculator?

Using the QGIS Advanced Python Field Calculator, I am able to assign the new field a value from a feature an existing field using value = <Attribute_1>. I run into a problem when I am using ...
0
votes
1answer
91 views

Addressing “Invalid Manifest” error when sharing geoprocessing tool script to ArcGIS Enterprise as a web tool

I wrote a Python script which takes an input Cropland Data Layer raster dataset and a user's defined Region of Interest, and returns a pop-up message telling the user the number of acres of each crop ...
1
vote
1answer
119 views

Saving to LAS file using laspy, correctly

I have a text file, each line in the text file has X,Y and Z coordinates eg: 551124.5841823021 470778.1953796738 318.1167521614109 I want to read the data and export it to LAS format, by using laspy....
-1
votes
1answer
584 views

Calculating Sequential Field ID For Unique Identifier using Field Calculator [closed]

I have a feature class of 7308 features. I have given each feature a unique name (WM-0001 for example) as the FID's jump all over the place. I realized that my new ID's do not match up with the number ...
1
vote
1answer
66 views

Spatialite KNN - No results

SOLVED: f_table_name was not working as no spatialindex was created/defined using just the tutorial for VirtualKNN - Solution: Run the query SELECT CREATESPATIALINDEX('tablename','geom_col') Original ...
2
votes
1answer
32 views

How to calculate azimuth from the south, latitude, departure with two points?

I'm making a Line class in python and the attributes we need to put in are the first point, end point, latitude, departure, distance, and azimuth (from the South). The points consists of eastings and ...
3
votes
2answers
2k views

stack raster using GDAL and numpy dstack

I am testing Savitzky-Golay filter with my MODIS dataset. Currently I am testing for 10 rasters (but later on will use my whole dataset) only just to test how should I create my script. So my initial ...
3
votes
0answers
54 views

Reading files with Japanese filenames with GeoPandas

I'm trying to read all shapefiles in a folder using this script: import glob import geopandas as gpd infolder = r'E:/folder/test_input' shapefiles = glob.iglob(infolder+'/*.shp') gdfs = [gpd....
2
votes
1answer
31 views

Python fastest way to load overlapping part of 2 rasters with different origin to np.array

I got a problem with gdal.wrap - it works REALLY slow. On 10m raster of Poland, matching the origin of 2 rasters takes like 30 minutes. Is there an easy and fast way to take 2 rasters (of different ...
0
votes
0answers
18 views

Using QGIS RVT plugin scripts through PyQGIS

I'm trying to run the RVT Plugin algorithms via a headless version of QGIS, on a server running Ubuntu 19.01. I'm using the conda distribution of QGIS 3.18.2, installed in it's own environment using ...
2
votes
0answers
209 views

Write GeoPandas df to PostGIS - Linestring Z geometry

I am trying to write a geodataframe with Linestring Z geometry to a PostGIS table. This rise the error: ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'LineString' [SQL: INSERT INTO ...
0
votes
1answer
297 views

Connecting multiple cities on a map using MapQuest route API

I am working on any optimal vehicle routing problem. I want to start map routing on the road starting from one city A to city B to City C to city D back to city A Based on lat/lng of these cities ...
1
vote
0answers
27 views

Working with large datasets with no server [closed]

I am in a bit of a weird work environment. I'm a data-scientist type person who is now doing more and more GIS work on some very large datasets - spatial regression, some mapping, spatial correlation, ...
1
vote
1answer
303 views

Convert lat/lng to x/y pixel 2D PNG image

I have a 2D PNG map which I know the corners of my image and I also have the image size all as below: image size: 600x600 pixel top-right coordinate: (35.74706129,52.08012633) => (lat,long) ...
3
votes
1answer
38 views

Retrieve OSM data with python using a GeoJSON geometry as the boundary [closed]

I'd like to : Select OSM map from a polygon geometry defined by a .geojson file Extract data (ex : parks area, building height,...) included in the geometry Any idea?
3
votes
2answers
162 views

Converting PyQt5.QtCore.QVariant to string

I am using QGIS with the in-built Python console. I want to replace some values in a shapefile with some other values. But when I try to change the attribute values, I get an error about the data ...
4
votes
1answer
46 views

Adding Z-dimension point to layer

I have a point. I want to add to a Point layer in QGIS 3.16, but I can't get the Z-dimension working on my layer. The point is created but has no z-value... coord = qgis.utils.iface.activeLayer().crs()...
0
votes
0answers
31 views

Writing raster file from masked array

I am doing some raster subtraction to get a canopy height model and I am struggling to write the output as a raster. The original datasets were .tif files in ESPG 27700 created from LiDAR. I used ...
0
votes
1answer
33 views

Fixing this error “NoneType object is not subscriptable”

Since days and days, I could not figure out this issue. I got this error 'NoneType' object is not subscriptable. lib/python3.8/site-packages/folium/features.py The problem is at this point: layer=...
-3
votes
0answers
40 views

Making Drop Down list from layer attribute using QGIS [duplicate]

I have shapefile (.SHP) with village names of all India with different attributes like STATE, DISTRICT, SUB-DISTRICT, VILLAGE, PIN NUMBER with geometry. I want to make a dropdown list to select STATE ...
0
votes
0answers
37 views

Extrapolating arc via Python function

I am looking for a Python code/function that can extend an arc linestring up to a pre-defined length while maintaining the same arc of the original line. The idea is to repeat the configuration of the ...
1
vote
0answers
23 views

Count the polygons of the raster given by the kmeans algorithm

I am struggling with a Python problem. My plan is to compute the clustering of the kmeans algorithm for an image and to create polygons from this classification. My goal is to get the total number of ...
1
vote
0answers
49 views

How to use GDAL Warp with Python

I can populate an image with 6 GCPs using Python and GDAL. The resulting images with 6 GCPs will only display using an affine transformation in ArcGIS Pro and QGIS. In order to display the images ...
0
votes
1answer
37 views

QGIS/Python configuration

This question came from another topic: QGIS - creating VRT does nothing. MacOS High Sierra (10.13), QGIS 3.10 Coruña, GRASS 7.8, GDAL/OGR 2.4.1, Python 2.7 The installation of GRASS was tricky (qgis ...

1
2 3 4 5
198