Questions tagged [python]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
6 views

My dataset lists state and county FIPS codes separately. How should I combine?

I can't do a simple "concatenate" because the codes don't have leading zeroes. Are there any available APIs that I can use to geocode this data given the format? Or do I have to manipulate them so ...
0
votes
1answer
60 views

Counting lines in Python script with code block

I am writing a Python script using arcpy and the Field Calculator function (code snippet below) and getting the following error message: ERROR 000989: Python syntax error: Parsing error SyntaxError: ...
0
votes
0answers
6 views

Clip all files from multiple subfolders using multiple polygons that have the same attribute

I'd like to ask for your help completing this code since I'm new to Python. I have two dataset folders one with subfolders containing shapefiles and the other with subfolders containing raster. I'm ...
1
vote
0answers
18 views

Network Analysis Shortest path with original line segments as output

I've managed to batch run the shortest path algorithm and the shortest route (point to layer) in the output is perfect, except that I really need the individual attribute tables of the line segments ...
0
votes
3answers
7k views

Python 3.6 error import osgeo

I'm trying to install GDAL osgeo lib into Python 3.6 on Debian Stretch I installed neccessary packages like: sudo apt-get update && sudo apt-get install -y \ binutils \ libproj-dev \ ...
2
votes
1answer
53 views

ModuleNotFoundError: No module named 'osgeo' in virtualenvironment

As I am working in ubuntu. This works if I deactivate the virtual environment but after activating the environment I got the error saying no module named osgeo. Any help would be appreciated to ...
13
votes
5answers
23k views

No module named 'osgeo'

I have installed GDAL and checked on the command line, it is working and when I run the gdal2tiles.py on the command line it works but when I run the same file gdal2tiles.py with python IDLE, I get "...
27
votes
4answers
54k views

Shapely not installing correctly

I am trying to run Shapely on a new machine, and tried both installing it from source, using the installer on its webpage, and using pip install shapely. Every reference I try to make from the library ...
0
votes
0answers
15 views

Zonal stats of multiple rasters in Python

I have a python script to get the zonal stats for one raster. Trying to use the same for multiple rasters. I have seen so many answers on similar post but somehow none seems to be working on mine. ...
1
vote
0answers
59 views

Python: How to get x,y coordinates of the highest raster values located in a list of polygons

I would like to extract and convert to a shapefile the coordinates of the highest pixel values located in several polygons. Such treatment was quite straight forward to achieve in R but I'm a newbie ...
1
vote
2answers
38 views

Rasterio merging went wrong

I try to merge some multiband rasterfiles (Sentinel 2 data) with Rasterio into a single rasterfile but the result is incorrect. The files are too big to fit in my RAM completely, but I have enough ...
1
vote
1answer
9k views

Installed pywin 32 — still getting error — “No module named win32com.client.”

I'm trying to install pywin32 (32 bit 2.7) so that I can run python from ArcGIS 10.2.1 (32 bit), and have access to the pywin modules. But I am getting the error "No module named win32com.client." I ...
1
vote
1answer
58 views

Intersection of two shapely polygon geometries

I have Shapely polygon geometries, A circle(c) and list of polygons within the circle. I want to find the union of the circle with the intersections. (circle + intersections) I was trying to ...
1
vote
1answer
156 views

Calling `Rscript` from QGIS Python Console / QGIS Plugin not working

I want to run a RScript that plots some data which is fetched by a QGIS Plugin. However it returns a non zero-exist status and breaks (when running with subprocess.check_call) or just skips the ...
0
votes
0answers
20 views

PyQGIS Standalone QVectorLayer works and QRasterLayer not work without QgsApplication / initQgis()

I'm trying to make a standalone python app and I want to use in some parts of app functions of PyQGIS. I'm testing things to understand how it works. Doing tests I have found a situation that I do ...
1
vote
1answer
33 views

OGR/Python- Check whether or not points are in a polygon

I have two shapefiles, one points file and one polygon. They are in the same projection (Lat/Long). I would like to run a quick command-line command or a Python script with the OGR module that creates ...
0
votes
0answers
18 views

How to get the shortest distance from a polyline to a set of points in Python?

Here in the image, the black line is the polyline I have and the red points are the points from which I need to find the distances D1, D2, D3 and D4. The polyline data is extracted from Google ...
-1
votes
0answers
20 views

Extract Feature Service ArcGIS API Python [closed]

I have a feature service server and map service server and I'd like to export them to shapefiles/geodatabase. Map Service: https://tataruang.jakarta.go.id/server/rest/services/DCKTRP/UDGL/MapServer/0 ...
-6
votes
0answers
28 views

invalid literal for int() with base 10: '' [closed]

def findSum(str1): # A temporary str1ing temp = "" # holds sum of all numbers # present in the str1ing Sum = 0 # read each character in input string for ch in ...
1
vote
1answer
191 views

Checking if two layers of features exists on same location using QGIS Python?

I have two layers named Layer1 and Layer2 containing some features. Layer2 features are overlapped on Layer1 features. Using python I want to check if a feature exists on layer2 when i select a ...
0
votes
1answer
15 views

Simplifying Polygons and MultiPolygons for Visualization

I completed a computation with Canadian Census data and discovered, when trying to visualize the results with Bokeh 2.0.2, that the Polygon and Multipolygon paths were very high resolution with a ...
1
vote
1answer
208 views

QGIS 3.4.3 Refactor fields changes symbols in fields (cp1250)

I've been using QGIS Refactor fields to change type, re-order and rename a substantial ammount of columns (statistical data). Most of them hold purely numerical values and are as such not material to ...
0
votes
2answers
34 views

Crop two rasters to common extent where pixelvalues are not nodata

I hope this doesn't get too confusing. I have two raster that overlap in a certain region. Like the following: What I would like to have, are two raster that only have values in the region where ...
1
vote
1answer
19 views

Rasterio creating composite/stack much larger than the individual bands

I am using rasterio to create a stack of eight bands and each individual band is about 1GB, but when it's stacking them the output (with a lzw compression) is a tif that's over 53GB! This seems huge ...
2
votes
3answers
3k views

Rasterizing Shapefile with attribute value as pixel value with GDAL in Python

Using suggestions and this question, the code now looks like this: from osgeo import gdal, ogr from sys import getsizeof import os # Define pixel_size and NoData value of new raster pixel_size = 1 ...
1
vote
1answer
37 views

Gram-Schmidt pan-sharpening in open source Python

I am looking to use the Gram-Schmidt pan-sharpening method in Python but I can't find any libraries that have this as an option. I found this, but I don't understand where to even go after reading it ...
1
vote
1answer
66 views

Calculate area of polygons in square meters when CRS is EPSG:25833

I have EPSG:28533 coordinates and would like to calculate its area in square meters and then transform these coordinates to EPSG:3857. I have taken the code from here to calculate the area but it does ...
5
votes
3answers
3k views

Converting NetCDF dataset array to GeoTiff using rasterio Python

I have read a NetCDF file using the netCDF4 library and then read one of its datasets ("Evapotranspiration") into a variable (variable contains array) using the following code. Subsequently now I am ...
2
votes
1answer
111 views

How to set a QgsLayoutItemLabel position by map coordinates in QGIS?

I am making a layout export function and I would like to create a QgsLayoutItemLabel at a given latitude and longitude. But in QgsLayout the position is relative xy (150,100). Is there a way to ...
1
vote
1answer
659 views

PyProj - Transform coordinate in “HK80 grid” to “WGS 84 / UTM zone 49N or 49S”

Am trying to use python pyproj to do the above conversion (convert/transform from Hong Kong GRID to Hong Kong UTM), but am getting different values from the expected result. My expected conversion ...
0
votes
1answer
88 views

Sharing WebMap through Python

I already know how to share a layer, or create a empty webmap (and add layers after its creation) through Python on ArcGIS Pro. However I could not find a way to share a Web Map trough Python. By ...
1
vote
1answer
49 views

Load raster layer from gpkg file

I'm new with PyQGIS. I need to load a raster layer from gpkg file, and i tried this way: gpkg_raster_land_layer = "GPKG:" + path_to_gpkg + ":" + layername r_layer = QgsRasterLayer(...
1
vote
2answers
68 views

Define projection of TIFF file when exporting from Python

I am struggling with getting spatial data into a readable TIFF file with the right projection. As far as I can understand, my problem is that the longitude and latitude is not saved as the projection ...
0
votes
0answers
27 views

Watershed delineation using hydrological Python library

We would like to delineate watershed polygon for a given pour point using hydrological Python library. Until now, we have tried these libraries: pyshed Grass (r.watershed) Whitetoolbox We have ...
1
vote
2answers
28 views

PDAL is mixing Lat and Lon when using tindex

I am trying to extract polygon representing the extent of my .LAS file. I am using tindex to do so. When importing the resulting file, it looks like longitude coordinates are set as latitude and vice ...
-3
votes
0answers
20 views

Obtener atributos entre 2 capas que intersectan espacialmente y autorellenar los atributos al crear un nuevo objeto [closed]

Al crear una vivienda/punto sobre una manzana/poligono , obtener los datos de la manzana y autorellenar en el formulario los datos en los campos de la capa vivienda/punto. Existira un script para ...
0
votes
2answers
42 views

Convert multiple JSON files to a single shapefile or geodatabase feature in ArcGIS or Python

I have been querying one feature in Esri ArcGIS REST Service, but because it is a large data, I had to query it several times (1000 features query limit). This results in many JSON files as parts of ...
1
vote
2answers
701 views

How to run Python script in QGIS via plugin

I am an absolute beginner in QGIS no idea in this field. I just created a Python plugin with pluging builder in QGIS successfully PYTHON_PLUGINS_PATH/ MyPlugin/ ----------------- inside it contain ...
1
vote
1answer
25 views

Test Schema Lock does not catch open feature class from within ArcGIS Pro

I am working on a script tool to be run in ArcGIS Pro (version 2.4.0 with Python 3.6.8) and wish to give the user a warning message and also time to close a feature class so as to avoid the script ...
4
votes
4answers
565 views

How to use create a plugin that contains a set of processing scripts using Qgis Script feature?

I have some script that I would like to share easily. I have read here that its possible to create a plugin using a set of scripts using "Scripts/Tools group in the Processing toolbox, double-click ...
0
votes
2answers
30 views

Loop through Z coordinate of stream and create point where elevation changes by 1ft

Using ArcPy (Python 3), I am trying to create points along a line where the elevation changes by 1 ft. I was successfully able to convert my stream to 3D using a Water Surface Grid and the Interpolate ...
2
votes
1answer
38 views

QgsFillSymbol crashing QGIS [RESOLVED]

I'm trying to customize my layers from a python script. I would like to add several symbol layers to features. # Creating symbol layers symbolLayers = list() lFill = QgsSimpleFillSymbolLayer.create({ ...
3
votes
1answer
126 views

PyQGIS in PyCharm 2020

I know this problem appears over and over again, but maybe someone can help me. I've read many articles on GIS StackExchange on the topic and I'm referring to this post: Why does QGIS 3.2 "...
3
votes
1answer
79 views
+100

Calculate new band for satellite image after predict values with RF

I have satellite image which contains 3 different bands. I'm using Python (jupyter notebook) in order to calculate new band by applying random forest regression. My problem is that after I have ...
-1
votes
0answers
10 views

Contiguity weighting with “touch” predicate in PySAL? [closed]

I want to compute a contiguity weight matrix in PySAL. I've looked at Queen and Rook contiguity, but I realised some of my data share no vertices, they only have touching edges. In order words, I ...
1
vote
1answer
39 views

How do you validate longitude and latitude coordinates in Python?

I am working on a bunch of shapefile data, and I need to process it and after some kind of processing, I need to feed the data to an indexer (in this case ElasticSearch). The problem is I just ...
0
votes
2answers
800 views

Add custom maps in Mapbox as tile layer in Folium

I was trying to create a map in Folium using a custom map built tile layer created with Mapbox Studio (using 3 different datasets and a satellite basemap). I was wondering if there is a simple way to ...
-1
votes
0answers
13 views

Q: Scripting the generation of DEMs from Sentinel-1 imagery? [closed]

I'm interested in ways to automate the generation of DEMs from Sentinel-1 SAR data over a particular region. Is there a way to script the DEM generation, preferably from Python?
3
votes
1answer
98 views

Setting DXF colors via Fiona

One might expect that the "Color" CAD field would control this, but the driver doesn't allow it to be set. schema = {'Layer': 'str', 'Color': 'int'} with fiona.open(path, 'w', 'DXF', schema=schema) ...
-3
votes
0answers
17 views

How do I filter out all unique file names in a Windows 10 folder? [closed]

I have a folder that commonly has files go in and out of it via task scheduler. These files (.docx, .pdf, .png) are added to the folder through another script and are added with a duplicate named file ...

1
2 3 4 5
173