Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [python]

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

2
votes
0answers
51 views

gdal.Open is giving none [closed]

I am having some problem with Gdal.open with my list of raster. I use Python 3 with GDAL 2.2. This is my script: import os import glob from osgeo import gdal import numpy as np import matplotlib....
2
votes
1answer
29 views

Get data from a raster using two coordinate arrays with Python

I'm trying to find a function in Python, that given two arrays with geographic coordinates, returns a list or array of raster values in those positions. that is to say: import numpy as np """geog ...
2
votes
1answer
75 views

QGIS Python ignore invalid geometries

In QGIS 3.4 I can run algorithms under the General setting "Invalid features filtering" -> "Ignore features with invalid geometries" However, when I try Processing through Python functions like the ...
1
vote
0answers
17 views

Match a custom CRS to existing (proj4 database) ones in QGIS 3

I am reading SPS files (see format definition here) from which I gather CRS information. Unfortunately, there is no ESPG reference available nor is there any standard naming scheme for Ellipsoids so ...
1
vote
2answers
160 views

Generating Steiner tree using Network X in Python?

I'm trying to generate a Steiner tree in Python using NetworkX. I have a range of geolocated nodes saved in the GeoJSON format, allowing me to visually validate the outputs in QGIS. A radially ...
0
votes
0answers
30 views

layer stack TIFF using python [duplicate]

i work with EVI MODIS and i need to stack all raster i had using python but i don't know how i'm using this backag and script to read my rasters import os import glob from osgeo import ...
1
vote
1answer
99 views

Converting LAS to TIFF using Arcpy - TIFFs writing out empty

I am using ArcPy to convert large batches of LAS files to GeoTIFF format. It seems like a lot of the data I have acquired from a particular source is giving me the same error: I am able to convert ...
2
votes
1answer
67 views

QGIS 3 Python Load all layer from geopackage

I am loading all layers from a geopackage in a QGIS 3 canvas in Python using a list with all layernames and the following code: databasepath = "X:/test.gpkg" layer = ["1","2","3","4"] for i in ...
1
vote
0answers
84 views

Accessing GPS via PyQGIS?

I am looking for a solution to connect a GPS-device on a COM-Port in QGIS 3 using Python. The GPS is working in the QGIS 3 GPS Gui as it should. As there are many changes between QGIS 2 and 3 the ...
1
vote
1answer
38 views

Converting SHP UTM to decimal lat/long

I am trying to compare a list of lat/long to a shapefile and see which points are in or out of the polygon. I have discovered my shapefile is seemingly giving points in a UTM format. Below are some of ...
0
votes
0answers
50 views

Generating Points for each Shortest Path

Python code is: import arcpy arcpy.FeatureToLine_management("Closestroute", "Featureline", "0.0001 Meters", "ATTRIBUTES") #Generate points along lines for every 1 km arcpy....
0
votes
0answers
43 views

Geoplot/Cartopy Orthographic projection won't work near equator

I am having trouble getting Geoplot's Orthographic projection to work near the equator. It works fine at locations ±90 longitude where latitude is right at 0, but if I run the code below, it fails ...
1
vote
1answer
48 views

Plugin that selects closest point features from a mouse click

I'm trying to build a plugin that would select let's say 8 closest points from a mouse click. I've found a working plugin that selects the closest feature from a mouse click here: https://www....
1
vote
1answer
62 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
0answers
43 views

Including iframe in tooltip in Marker?

Can we include an iframe in tooltip in Marker? import folium var=open("yolo.html", "r") var2 = var.read() map = folium.Map(location=[19.179180,72.972580],zoom_start=6, tiles="Mapbox Control Room") ...
2
votes
0answers
80 views

Unresponsive MessageBar in QGIS 3

I created a little plugin to geocode addresses using the HERE API and QGIS 3. Especially in batch mode, I can see that the plugin is iterating over my features in a table and my messageBar progress ...
0
votes
0answers
20 views

Map Town names to its corresponding NUTS code

Is there a way to map the Town to its corresponding NUTS code? I have a file which has IP address and Town too, but I was not able to get the NUTS code from the latitude and longitude information ...
0
votes
0answers
50 views

Splitting aerial photography into images with GPS coordinates

Splitting aerial photography into images with GPS coordinates Given this folder structure of (four) Oblique and (one) Vertical aerial photography of 10 cm resolution: dir/Orientations/footprints.cpg ...
0
votes
0answers
25 views

Connect Mapnik to MSSQL

I want to connect Mapnik to MSSQL Spatial SDE, but I don't know how to do this. import mapnik m = mapnik.Map(256,256) mapnik.load_map(m, "test.xml") m.zoom_all() mapnik.render_to_file(m, "2.png") ...
2
votes
1answer
54 views

Split GeoTIFF into multiple cells with Rasterio

I'd like to create training data for a machine learning pipeline. To do this I want to take a large raster and split it into multiple equal sized cells. I have a very basic loop for generating the ...
2
votes
1answer
95 views

Feedback from a QGIS map posted on a web page [closed]

I have QGIS version 3.4.2-Madeira and I'm still a beginner with this software. I have created a web mapping service that actually is hosted by a QGIS server. In order to do this, I've used the ...
0
votes
0answers
97 views

CSV to GeoTIFF (Python)

Trying to convert a CSV file (3 columns: Lon, Lat, Ref) to .tif GeoTIFF (the Ref values) using gdal. Using Python 3.6, I am getting the error below. What am I doing wrong? C:\ProgramData\Anaconda2\...
1
vote
1answer
162 views

Snap points shapefile to line shapefile using shapely

I have 2 datasets: 1) a road network shapefile which has many polylines and 2) a bus stop shapefile which has many points representing bus stops. My points shapefile has CRS of EPSG 4326 and my line ...
1
vote
1answer
52 views

Copy files to a new folder if the file name matches value from a specific field in a feature class

I have this folder with bunch of .jp2 files, and from this folder I need to copy only the files that their name matches the value name from a specific field in a feature class. Right now I can print ...
0
votes
1answer
58 views

Arcpy Geocoding Script Fails (vague messaging)

Using ArcMap 10.6 to load a Python script that will geocode 25,000 addresses. It looks like it fail during the actual gecoding attempt with an error: ERROR 000010: Geocode addresses failed.Failed to ...
0
votes
2answers
47 views

GRASS r.viewshed from Python with multiple raster tiles

I'm new to GRASS and struggling to do a viewshed across multiple tiles. I have got the GRASS r.viewshed function working from Python as follows for a single tile: gis_path = os.path.join(output_dir, '...
0
votes
1answer
59 views

Combining points close to one another

I need an approach to combine points close one to another into a common point. I can take an average of points' {lat, long} to create one point. How I can do this with ArcMap or Python? I have an ...
2
votes
1answer
30 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 ...
0
votes
2answers
133 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
87 views

AttributeError: 'QgsRasterLayer' object has no attribute 'pendingFields'

Remember i am using Python Version 3.6.2 QGIS Version 3.2 while running my code i am getting this error: fields = selectedLayer.pendingFields() AttributeError: 'QgsRasterLayer' object has no ...
1
vote
0answers
33 views

Can't write closing square bracket

I am unable to write the closing square bracket in QGIS Python console or editor, unless automatic parentheses insertion is enabled. Parenthesis and curly brackets work fine. Keyboard layout is ...
3
votes
1answer
124 views

GeoPandas spatial join and count

I have following two GeoDataFrames. One with the crime count per polygon per year. Polygon Year total_crime shape_area geometry 0 0 2009 1 3.266388e+06 ...
0
votes
0answers
30 views

OGR Python: Copying features from one datasource to another works with shapefile but not with geopackage

I have a shp/dbf EPSG4674 input datasource, and I want to copy features from one layer of this input datasource, create a new output datasource and write these features to that output datasource. As ...
1
vote
0answers
50 views

Read status and XY-coordinates from GPS-widget with Python (QGIS 3)

Is there a way to access the status and the XY-coordinates from a GPS-connection established by the GPS-widget in QGIS 3 via python? I want to establish the connection with the widget to have better ...
1
vote
0answers
64 views

Nonlinear regression in Google Earth Engine on each pixel in an image collection using GEE's servers

I am attempting to optimize the parameters for a double-logistic function on an annual MODIS NDVI time series in Google Earth Engine. I have previously looked at Non Linear Regression in Google Earth ...
2
votes
1answer
36 views

Python Fiona affecting external GDAL binaries?

Curious if anyone else has encountered this before and may have an explanation: In my Python workflow, I'm importing fiona (1.8.4) to manipulate shapefiles, and then later downstream I'm shelling out ...
0
votes
0answers
211 views

QGIS 3.4 Couldn't load SIP module. Python support will be disabled on Windows 10

I upgraded from QGIS 3.2 to 3.4 and bad things happened. On start-up I get the error. Couldn't load SIP module. Python support will be disabled. Traceback (most recent call last): File "", line 1,...
1
vote
1answer
38 views

Why does shapely intersection of two lines change behaviour when fiona module is imported?

I am having issues with calculating an intersection of two LineStrings using Shapely. Such an intersection should return a point, yet my code returns a LineString. I found a simple example of an ...
0
votes
1answer
33 views

Geopandas tick labels from a diferent coordinate system

I have a GeoDataFrame that includes points with the relevant geometries (coordinates system WGS84 EPSG:4326) gdf: Name x y Coordinates E -4.375 51.5 POINT (-4.375000000000008 51....
1
vote
0answers
95 views

Cluster points into evenly numbered groups

I need to take x number of points and equally/spatially divide them into groups. Meaning that if I had 40 points like in the image below and wanted to have 4 groups of points. Each group should have ...
0
votes
1answer
113 views

Reading a 4 band image with rasterio (python)

I am trying to view a tif satellite image which has 4 bands. I want to remove the last band (NIR) and view the RGB image only, so I am trying to split the NIR from the rest of the image. Here is my ...
0
votes
0answers
13 views

Change an existing QGIS v2.18 print composer extent to create atlas series focused on one location

I have a QGIS v2.18 project that includes a print composer layout. In the print composer I can alter the exent to match the canvas extent using the Set to Map Canvas extent button. I would like to ...
0
votes
0answers
21 views

QGIS 3 Python terminate mapTool

Using QGIS 3 I am calling a mapTool to get the coordinates of a user input on the canvas. The function is called by a button in the toolbar. Before the mapTool is loaded a UI is opened to insert ...
5
votes
2answers
171 views

QGIS 3 Get coordinates from mouse click

I am working on a small QGIS Python plugin and want to get the X/Y coordinates from a user click on the canvas. I have a small UI called from button in a toolbar. After filling the UI with information ...
2
votes
1answer
75 views

WhiteboxTools returns nan rasters when lee filtering large radarsat images

I am attempting to run the following code from WhiteboxTools: .\whitebox_tools.exe --run="LeeFilter" --input='imagery_HV_orig.tif' --output='imagery_HV_filtr.tif' --filterx=5 --filtery=5 --sigma=10.0 ...
0
votes
1answer
37 views

cartopy and xarray issues

I'm beginning to use netCDF4 data and therefore I have downloaded xarray and also cartopy (with pip). I have downloaded data from the climate data store and want to plot these data. I have a ...
6
votes
0answers
50 views

Coarse Woody Debris extraction

I created very high dense point cloud of some forest plots using terrestrial laser scanner. Then removed points above 1.3 meter to see the coarse woody debris (Fallen dead trees). Attached is the ...
0
votes
0answers
24 views

Open Pan Sharpened satellite images in Python?

I recently downloaded the SpaceNet Off Nadir dataset for work but found that the Pan-Sharpened images can't be opened in Python. I think it's probably due to the colour bands being undefined but I'm ...
0
votes
1answer
60 views

Loading all rasters in a directory and naming the variables iteratively

Hi I'm working with prism data and I already have clipped (masked) rasters (*.bil files) of a specific area for each day of a year. I'd like to open all these rasters with rasterio, convert them into ...
3
votes
3answers
181 views

Merge all shp files in a folder into one with a new field populated with the source filename

Want to merge all shp files in a folder into one with a new field populated with the source filename. Not getting any errors but not getting any outputs. Code originally taken from (How to add field ...