Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
0answers
15 views

How to query all points within 2000 meters through spatial index in python?

As you can see,I have some data and the projection epsg:4326. geometry 0 POINT (120.681175 27.989723) 1 POINT (120.70615 27.97382) . . . I want to get all points within ...
0
votes
0answers
9 views

Refreshing a composer map with Python doesn't seem to work

I want to do the equivalent of the button "Update view" in the QGIS map composer window, but directly from Python. I have the two following lines in my code, where composeur1 refers to the map ...
3
votes
0answers
26 views

Is it possible to automate sewer service line creation?

I am a GIS Tech working for a utility company, part of the asset maintenance program entails running a camera down gravity mains (sewer pipes) from the upstream manhole to the downstream manhole. ...
0
votes
0answers
15 views

Find best matching polygon in a Geopandas series [on hold]

Say I have a geopandas Series S of different polygons. Furthermore I have a Polygon P. I would like to find the most efficient way to find the polygon in S that overlaps P to the highest extent.
1
vote
1answer
12 views

Why QgsFeature.geometry() returns an empty geometry in PyQGIS?

I am a new for QGIS, working in Python. I add a buildings(.shp) vector layer into QGIS, just like this: I'd like to get the geometrys of some features, then I can do analysis on the center point. ...
0
votes
0answers
9 views

QGIS3 Python Export PNG after layout resize

I have maps being created that have nice colour banding on them for the contours. I want to be able to export the legend for that colour banding as an image so it can be imported into another ...
2
votes
0answers
17 views

Selecting weights while transferring from shapefile to network

I have a shapefile representing roads (LineStrings) and I need to transfer it to a networkx type (with the lengths as weights) so I can do some network analysis. I have used the s2g library to do so ...
0
votes
0answers
18 views

MODIS downloads using Python

I am trying to get a full-functioning download script specifically for the Modis data (Version 6) on the USG/NASA site (AppEEARS/LPDAAC). I’m running Windows 10. I know that there is an R Modis ...
1
vote
1answer
19 views

Why a QgsExpression does not evaluate a feature as expected in PyQGIS 3?

When I run following code in QGIS 2.18: layer = iface.activeLayer() expression = QgsExpression( u'"area" > 2e8 AND "area" < 3e8' ) feats = [ feat for feat in layer.getFeatures() ...
0
votes
1answer
26 views

Merge multiple ASCII files into single GeoTIFF file with multiple bands [on hold]

Is there a way to combine multiple ASCII (text) files into a single TIFF file with multiple bands (Band1, Band2 ...) using GDAL or Python?
0
votes
1answer
22 views

Loading map from canvas in QGIS Composer created with Python?

I'm new to using Python to automate stuff in QGIS. I've used the following code to create a new map composer in QGIS: # create a new composer c1test = iface.createNewComposer("mon premier composeur")...
0
votes
1answer
25 views

Error of copying GCPs information from GeoTIFF to another TIFF

I have two images, one is Sentinel-1 HH-pol TIFF file and it contains projections and 399 GCPs information and the other is SigmaNought TIFF file, it doesn't have GCPs and projections information. I ...
0
votes
0answers
16 views

Google Earth Engine API: localhost refused to connect

I'm trying to implement this https://github.com/samsammurphy/gee-atmcorr-S2 in Google Earth Engine using Docker Toolbox for atmospheric correction. Everything seems to work except when I copy/paste ...
0
votes
1answer
20 views

QGIS Spatial Index uses bounding boxes; how to get actual nearest line to a known point

I have looked at lots of answers referring to this same issue, and tried using QGIS Spatial Indexes and iterating through the line features in the spatial index to calculate the distance between a ...
-5
votes
0answers
24 views

Write a jython script which will place the face of a person from one picture onto an inanimate object on a second image [on hold]

I'm a bit confused on how I would do this with jython it is python code.
1
vote
0answers
16 views

Can't set OGR layer geometry type in Python

I'm trying to create a layer of geometry type polygon, with a feature of geometry type polygon, and a geometry of type polygon. However, no matter how I attempt to set the geom type of the feature, ...
0
votes
0answers
16 views

Color rendering issue: from Code editor platform to Google Earth Engine Python API [on hold]

I have done NDVI on code editor platform. The color and code links are given below: https://code.earthengine.google.co.in/85b906aed53883b305de4881c4921443 I have used Python API of Earth engine to ...
0
votes
0answers
10 views

Band names not exporting when using Python API and Google Earth Engine [on hold]

I am using the Python API to work with GEE, but am unable to export the band names from a multiband image. When I check the band names using image.bandNames().getInfo(), they are correct, but once ...
0
votes
1answer
36 views

gdal/geopandas data object compatibility in python

Is it possible to convert an ogr datasource into a geopandas GeoDataFrame without writing the datasource first as a physical file and reading it back? I am referring to something like import ogr, ...
3
votes
1answer
34 views

Using shapely.affinity and affine_transform?

I have shapely.geometry Point: from shapely.geometry import Point point1 = Point(0, 100, 200) and I want to swap coordinates Y and Z: from shapely.affinity import affine_transform matrix = [1,0,0, ...
1
vote
0answers
10 views

Setup shadedrelief background in basemap using a cropped orthographic projection

I'm trying to plot a sector of the world in basemap using an orthographic projection and I would like to have a shadedrelief background. If I don't use shadedrelief everything works fine: import ...
3
votes
1answer
44 views

Python/PostGIS - Type “Geometry” Does Not Exist

I am a total novice with both PostGIS and Python - I am just trying to get this game running. I have followed the instructions here and here and am now at a dead end. I have pgAdmin 4 downloaded and ...
0
votes
2answers
22 views

Convert XYZ coordinates in .txt files to .tif files?

I have many .txt files containing UTM XYZ coordinates of my study area. The content of each .txt file looks like this: 493932.0669,5426301.1910,0.468 497932.0669,5426301.1910,0.421 501932.0669,...
0
votes
0answers
10 views

error with “pywin32-221.win32-py2.7.exe” installation

I am trying to download MGET to run random forest model. Before downloading MGET, I need to install pywin32 Python package. While running "pywin32-221.win32-py2.7.exe" for my windows 10, ArcGIS 10.4.1,...
1
vote
1answer
31 views

Accessing information inside an .sd file using python

I want to know if there is a way to list all folders/files inside a .sd file using Python. Below is what I am currently working with. I am writing a script that will access our ArcGIS Online ...
0
votes
1answer
10 views

ValueError: Invalid field type <class 'bytes'>?

This error ValueError: Invalid field type is caused at the last line of this code: fs.to_file(out,encoding='iso8859_7') Full code: q=gpd.read_file(fname + "\ASTENOT\simplify_centerline.shp",...
3
votes
1answer
26 views

Get xy coordinates of QgsMapCanvas in PyQGIS 3?

I am trying to get the QgsMapCanvas coordinates when they change using PyQt5 and PyQGIS 3. What I have used for that: self.canvas.scaleChanged.connect(lambda: self.showScale(self.canvas.scale())) ...
2
votes
1answer
48 views

How do I write a GeoPandas dataframe into a single file (preferably JSON or GeoPackage)?

I'm new to GIS and having a basic beginner problem. I've got data in the form of a geopackage .gpkg from GADM.org. I can read in and use the data without problem using Geopandas (via built-in Fiona)....
-1
votes
0answers
20 views

Modifying script using custom class? [on hold]

Given a parcels.shp with the attributes of FID, SHAPE, LANDUSE, and VALUE I need to modify this script to generate a list of values in the format: FID: import parcelclass myparcel = parcelclass....
-3
votes
0answers
24 views

How do I break this Python script down by its elements? [duplicate]

I took a shot at breaking this down by element type but unsure how successful I was as I am a beginner. Please let me know what to correct and/or what I missed. import arcpy from arcpy import env ...
1
vote
1answer
125 views

Where is official documentation of gdal/ogr?

Where can I find the official docs for gdal/ogr python API? I am looking for something comprehensive which shows all the classes with descriptions of their attributes, methods and input/output types....
1
vote
1answer
38 views

S57 Driver doesn't support update Error

I am trying to load S-57 file with pyQGIS with code below self.canvas = QgsMapCanvas() # self.canvas.useImageToRender(False) self.canvas.show() # Lay our widgets out in the main window using a # ...
0
votes
1answer
27 views

Generating a raster layer with intersecting line lengths as cell values

I have a polyline vector layer and a template raster dataset. For this polyline vector layer I would like to generate a new raster dataset based on the template raster dataset, but in which each cell ...
2
votes
0answers
17 views

Is it possible to create a QGIS workspace with pre-loaded layers, styles and print templates with Python?

I am building a python tool which aggregates data from a number of sources and generates some web-maps from this data. I was wondering if it is possible (maybe using PyQGIS) to create a QGIS3 ...
0
votes
0answers
9 views

DLL error and 1073741511 error running GRASS from external Python script

I am struggling to run any GRASS 7.4.1 Session from outside using Python 2.7.15 with Spyder IDLE. While setting up the GRASS bin and GRASS environment are as follows are all good and showing no ...
1
vote
2answers
141 views

Invalid multipolygon of valid individual polygons

Could anyone please explain this to me? The polygons all have valid geometry but the resulting multipolygon somehow doesn't. The following script: from shapely.geometry import Polygon, MultiPolygon ...
1
vote
1answer
15 views

PyQgis v3 addAttribute

I'm currently updating a plugin that I wrote a long time ago for Qgis v2. I have a line that add attributes to a vector layer written as below but it's getting an error: provider.addAttributes([ ...
0
votes
0answers
3 views

Extracting pwv using MODIS

I have downloaded MODIS data and I have also viewed using hdfview. I want to obtain precipitable water vapor(pwv) as a function of time for specific longitude and latitude. I am new to python ...
1
vote
1answer
27 views

Split and merge polygons by ID and Feature value in python or QGIS

I have a spatial dataset with two major columns: county_name and group_ID. The spatial polygons are represented by each county_name. Some counties share the same group_ID, while some counties contain ...
0
votes
0answers
29 views

Performing interpolation to create heatmap in Python?

I'm doing lots of interpolation to create heatmaps in QGIS recently and would like to move everything to Python to complete my workflow in one place. I've found some tutorials like this post and this ...
1
vote
0answers
16 views

How to cut pixel size rectangle from GeoTIFF image with GDAL Python

I have GeoTIFF image with EPSG "4326" and longitude, latitude of a point in the image. I need to cut a sub-image from the original image around the point (lng,lat) with the size of 128x128 pixels.
1
vote
0answers
12 views

batch saving 10m DTM layers using python console

I am attempting to batch save 300 10m DTM tiles all in the same Raster type 'Float 32-bit' for using to create a VRT. At present I cannot create a VRT using the original Raster layers as some of the ...
0
votes
0answers
13 views

python-netcdf4: Writing file leaves CRS as 'undefined' and extent not correct

I am trying to write a netcdf file in my file system and then open it in QGIS for visualization purposes. I have 3 numpy arrays with size 234 rows and 217 columns. One contains the latitudes in each ...
0
votes
0answers
18 views

Earth Engine: downloaded image contains only 1 pixel after mosaic with python version

I followed the tutorial of getting a free-cloud landsat8 image from the official site with python version. But I got only 1 pixel with the function getDownloadUrl.Here's the code def maskClouds(image)...
0
votes
0answers
15 views

Merging datasets from different timeframes in geopandas

I have two datasets on neighborhoods in municipalities rom two different years. Due to administrative restructuring some data cannot be matched on the given id. When I plot the unmatched data there is ...
0
votes
1answer
13 views

Import PostGis tables into a GeoDataframe unexpected : 'AttributeError: 'NoneType' object has no attribute 'encode''

When I try to import two of my tables from postgis to geopandas I have an error. I guess the problem is due to my geometry columun, but I don't know why. engine = create_engine('postgresql+psycopg2://...
3
votes
0answers
27 views

Why can't I transpose a raster across the pole with rasterio or gdal, and how could it be done?

I have a raster in e.g epsg:4326, it covers all world, from 180E to 180W, from 90S to 90N. I want to re-project a part of it to epsg:3031 and also change the grid size and resolution. Here is a ...
1
vote
1answer
38 views

Joining attributes after selecting one polygon which intersects another using geopandas?

To select the polygons which overlap other layer's polygons, I came up with this code based on what I found on this site: import geopandas as gpd import fiona import os import sys # Get the current ...
0
votes
0answers
20 views

Getting attributes from JSON arcpy

I'm trying to get the first attribute element in the JSON list. This data is from the operational layer which I am able to parse through. However, I can't seem to get the attributes from the first ...
0
votes
3answers
59 views

Have DEM, need polygon outlining region above a certain elevation

I have a DEM in HGT format. I need to isolate all areas above a certain elevation and view them as polygons. Something like this (let's say the pink polygon is everything above 1000m): Seems like ...