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.

0
votes
1answer
23 views

Docker Image: Atmospheric Correction in Earth Engine

Following https://github.com/gee-community/ee-jupyter-contrib/tree/master/docker/atmcorr-ee I was able to build and run docker. And to authenticate and git clone, but while: cd gee-atmcorr-S2/...
0
votes
1answer
16 views

Unable to load file using gdal.Open

I am new to GDAL in Python (and Python in general), so as a way to begin learning, I am trying to perform basic functions such as getting extents from a single raster and printing them out. However, ...
0
votes
0answers
31 views

MacOS error when installing GDAL in conda: pyopenssl and setuptools dependency

I was trying to install GDAL on MacOS Mojave 10.14.3 using these following methods: conda install -c conda-forge gdal conda install -c conda-forge/label/gcc7 gdal conda install -c conda-forge/label/...
0
votes
1answer
43 views

Toggle unchecked button is not closing the Socket. QGIS [closed]

I have a QGIS python plugin which works fine when toggle button is checked but when i unchecked it then its not closing the socket why? here is my code def show_markers(self): s = socket.socket(...
1
vote
1answer
21 views

How to convert a multipolygon to multilines with Python?

How can I convert MultiPolygon to Multiline? I want to work with the boundary of multipolygon. In R I can just do : as(my_multi_polygone, 'SpatialLines') But I don't know how to do it in Python?
1
vote
1answer
29 views

Split polygon by MultiLineString - shapely

I'm working on splitting a polygon given a set of linestrings using the shapely python library. The problem I'm facing is that a polygon cannot be split by a MultiLineString usingshapely.ops.split(...
3
votes
1answer
56 views

QGIS 2.18: Speed up QgsFeatureRequest in Python Script

I have two input layers. The first one is a line-layer named "graph" and the second one is a point-layer named "nodes". The "graph"-layer: The graph layer holds 177350 line features which are ...
3
votes
2answers
39 views

Create a bounding box from point shapefile

I have a BigTiff image and an associate point shapefile with features. I would like to know how can I create a bounding box from that shapefile to create/clip images around that points to train a ...
1
vote
2answers
32 views

Converting DXF file to shapefile by exporting only certain fields using ArcPy?

I have a problem converting multiple DXF files into shapefiles. In particular I use the script that is shown below for conveying multiple files. But the output shapefile is very large due to the ...
0
votes
0answers
31 views

Running Linear Regression with multiple Rasters converted to a numpy array in Python

What I did was an array with Rasters from 2000 to 2018. It's temporal Resolution is 16 days. I more or less wrote my code by combining scripts that I found matching my problem. This is what I got so ...
1
vote
0answers
27 views

How to write raster in saga format with python

I try to write a raster file in SAGA GIS format (sgrd). My script is work but some information is missing in the final file (i.e output.sgrd). Here is script : from osgeo import gdal, ogr, osr import ...
0
votes
1answer
30 views

Interpolating orthodrome between two (lon,lat) points in Python?

I have a polygon that consists of a few (lon, lat) points, each pair of consequent points is considered to be connected by orthodromes. I want to interpolate the polygon with some extra points between ...
0
votes
0answers
13 views

reproject *TO* MODIS sinusoidal grid

I want a global file chopped into multiple netcdf files corresponding to the modis tiles. I currently have a directory of GLOBAL netcdf files over time. NOTE: ERA interim data is on the regular lat/...
0
votes
0answers
20 views

GDAL 202-1500 driver plugin missing

I have a machine setup with Windows 10, ArcGIS 10.2.1 and Python 2.7 from ArcGIS. I installed GDAL according to cartometric. The gdal-202-1500-core.msi and then gdal-202-1500-filegdb.msi. With Python,...
0
votes
1answer
48 views

How to fix invalid polygon with self-intersection - Python [closed]

I have a self-intersecting polygon inside a shapefile. Does there exist a Python library which spots the self-intersections and makes it possible to correct them? I have found it is possible in QGIS ...
0
votes
1answer
40 views

How to find overlapping polygons of two shapefiles - Python [closed]

I have a mkl file A and a shapefile B containing polygons, each one of them having a single feature: the name associated to the polygon. I am looking for the polygons of A which are overlapped by ...
3
votes
1answer
55 views

How to run QGIS algorithms with selected features?

In the QGIS GUI, the select-by-location algorithm has a choice to only use the selected features from the INTERSECT layer. How can I do this (or use any other algorithm) in a python script for QGIS 3? ...
1
vote
1answer
18 views

Building Docker image including IPython Notebook and EE?

I'm starting to play with EE, already tried a bit of Javascript API. Now trying the Python one. So I found https://github.com/tylere/docker-tmpnb-ee and git cloned it, then from the terminal I did ...
0
votes
1answer
34 views

Invalid geometry constructed by EE Python API

I have a problem with Python API of Google Earth Engine. I'm trying to create a vector mask of a small area based on NDVI. I take Sentinel-2 data as two bands and pass a rectangle (defined as series ...
0
votes
0answers
39 views

I have a shapefile where in I want to select features based on their feature ids

I have a list of feature ids and I am using layer.SetAttributeFilter for that but the code neither selects those features nor does it raise an error. I took help from these questions: OGR Filter ...
1
vote
0answers
30 views

Geofencing radius distribution/ratio across multiple geofences

I understand that this problem might be simple geometry, but Im using specific shapefiles for a geographical area and looking for a specific gis solution (hopefully code). Essentially Id like to find ...
0
votes
1answer
40 views

Extract Raster Information using Python

I would like to extract raster information (i.e. coordinate system, cell size) to excel file using python, how can I do that?
2
votes
0answers
36 views

QGIS BadLayerHandler - setDataProvider()

I've made a bit of a plugin to handle badlayers (I'm aware that Change datasource plugin had something for this but the code appears to have been removed now?). I've followed the advice provided in ...
2
votes
1answer
62 views

Importing GeoJSON into PostGIS with Python

I am trying to import GeoJSON file with Python to my PostgreSQL db. Here is full code: with open('C:/xampp/htdocs/app/data/'+a) as file: gj=geojson.load(file) for feature in gj['features']: geom=...
-1
votes
0answers
20 views

Splitting a line Shapefile at a regular interval Using Python [duplicate]

I have a line shapefile and I would like to split the feature at regular interval and that would generate another line shapefile in parts. I am using Python libraries of GDAL, Shapely and Fiona only.
1
vote
2answers
79 views

Create Polygon with Length, Width, and a center coordinate

Using Shapely or like library, How can I create a rectangular polygon with known Length, Width (in meters)(Drawing over EPSG: 3857), and center coordinates (EPSG: 4326)? The output needs to be in ...
0
votes
2answers
39 views

Convert GeoJSON to OSM XML using Python

I know about using ogr2ogr, and also about the nodejs module osm_geojson. However, I would like to convert GeoJSON to OSM XML from Python. Is there a library which has this capability built in? Or ...
0
votes
0answers
53 views

Write feature collection to S3

Is there a way to write a feature collection from Python memory to an S3 bucket (as Esri Shapefile, zipped Shapefile or something else) without writing it first to disk? I tried writing to a ...
1
vote
0answers
20 views

Layer spatial reference system units EPSG::32633 [closed]

I polygonized a raster with the following code: from osgeo import gdal, ogr, osr gdal.UseExceptions() srs = osr.SpatialReference() srs.ImportFromEPSG(32633) ds = gdal.Open('H:/Threshold/...
0
votes
1answer
16 views

How could a GeoJSON look that OGR recognizes more than one layer?

I load a GeoJSON with OGR and apply the method GetLayerCount(). How must the GeoJSON look like that GetLayerCount() > 1? driver = ogr.GetDriverByName("GeoJSON") dataset = driver.Open(my.geojson, 0) # ...
0
votes
1answer
33 views

Have NDVI layer and want to Calculate area(pixel area-reduce region) .in Python API for Earth Engine

I had already asked this question for Earth Engine Javascript.The link is given below I have NDVI layer in Earth Engine. I want to assign and calculate area of good and bad ndvi area I wamted to do ...
3
votes
2answers
57 views

Google Earth Engine IDE alternatives?

I'm starting to play with EE and I jumped right into the online web-based IDE for the Earth Engine JavaScript API (https://developers.google.com/earth-engine/playground). I see there is also a Python ...
0
votes
1answer
57 views

For loop can not find the next raster object in the geodatabase. OSError: “” does not exist

I'm trying to convert a list of rasters in a geodatabase to integer type and rename them with a specific folder name as the prefix. This first block of code moves the ASCII rasters into the ...
1
vote
0answers
32 views

Rasterizing Shapefile in different projection/extent from sample raster in Python?

I have a road network shapefile that I'm trying to rasterize and combine with the DEM raster. I created the road network shapefile from a dataset (using fiona) and therefore it has no projection. What ...
-1
votes
1answer
57 views

Python - Creating a shapefile from a bounding box coordinates list [closed]

There is already few existing questions about this topic, but I unfortunately did not find something that could fix my problem... I have a point Lat, Long coordinate i.e. Lat= 10 and Long = 10. I ...
1
vote
0answers
18 views

SQL Error while using v.distance through simple python editor in grass

I try to execute the following code: grass.run_command('v.distance', from='tramstop', to='iso_tram', upload='cat',column='first_tram_distance', overwrite=True) but i get the "SyntaxError: invalid ...
0
votes
1answer
33 views

Changing decimal digits of extent in raster layer using Python in QGIS

I want to change the decimal digits of the raster layer extent in QGIS 3.4.3 with Python, so it ends with 0.5. My code is as follows: input = vlayer output = "Directory" extent = vlayer.extent() ...
1
vote
1answer
33 views

Argument 1 has unexpected type 'set' Error using processing in QGIS?

I am currently working on a code that adds a field to a shapefile and inputs its filepath. I understand that the processing.run has changed from qgis 2 to qgis 3 but I am not sure why I am getting ...
0
votes
1answer
22 views

Read integer field as a string for list comprehension in arcpy

I have a script that is used to update a line feature class with the start and end elevations based off of a shared ID number with a point feature class using list comprehension in arcpy. However I ...
0
votes
1answer
37 views

Geometric networks (networkx) in PyQGIS

I'm working with code from the Disconnected Islands plugin in QGIS x64 and Python 3. Normally, the plugin uses networkx to create a geometric network and ends by writing the FID of features with no ...
1
vote
0answers
26 views

PyQGIS clip results in empty layers

I am creating a Python/PyQGIS tool in QGIS 2.18 which combines a few functions: Extract several attributes from source layer Redefine a coordinate system Optional: clip the source layer with a ...
0
votes
1answer
23 views

Merging multi-polygons gives me error in shapely

I am trying to merge a bunch of either polygons or multipolygons by the merge_multi_polygons function in shapely, I am using my below code inside Spark elems=row['_c0'] ...
1
vote
0answers
53 views

QGIS Plugin: display dialog for entering username and password to connect to the database

I do not want the password and username to be saved in the QGIS project. Instead of standard QGis dialog(QgsCredentialDialog) I want to display "my dialog" for entering username and password. On the "...
2
votes
0answers
25 views

How to create LineString geometry in QGIS3?

The default geometry type for a newly created line seems to be MultiLineString. It can be changed to LineString using the Multi to Single tool while saving in memory. However, once it is exported it ...
1
vote
1answer
41 views

PyQGIS processing: Overwrite not possible

I have a QGIS plugin that runs the v.clean algorithm two times (first time snap, second break) on a chosen layer: output = self.dlg.directory.text() params_snap = { 'input' : input, ...
0
votes
0answers
16 views

OS X PYTHONPATH for QGIS Standalone Apps?

What's the correct PYTHONPATH for OS X and QGIS 3.4? I want to make a QGIS standalone app but get the "ModuleNotFoundError: No module named 'qgis'" error. This happens after following the OS X ...
-1
votes
1answer
41 views

Reading bathymetry for coordinate with Python? [closed]

I need the water depth at specific coordinates and my geoscientist are offering me a dataset in either TIFF or XYZ/txt format with data points each 2km. I will typically be extracting about 1000000 ...
0
votes
2answers
51 views

I have NDVI layer in Earth Engine. I want to assign and calculate area of good and bad ndvi area

var mergedCollection = s2.map(function(image) { return image.select(['B8', 'B4'], ['NIR', 'red']) }) var mergedAllFunction = function(image) { var ndvi = image.normalizedDifference(['...
1
vote
1answer
35 views

Raw user input for QGIS and Python

I am using Python 3.7 and QGIS 3.4 to run a number of processes, and while I draft and debug my script I want to be able to occasionally stop, check if I want to continue, and then do so. Usually, I ...
1
vote
1answer
22 views

Exception raised when saving Geopandas DataFrame into a file

I am trying to apply the method to_file of a Geopandas DataFrame. My DataFrame contains a column Polygon, a column Point, a string and float columns. Here the output of the describe method: <...