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.

1
vote
0answers
16 views

Qgis python ComboBox: Combination of fixed and free Items

I want to built a ComboBox to select a given plotting scale out of a list or ask for a different scale (e.g. '1:625') as Textinput in the same ComboBox. The combobox is changed to 'editable' and I'm ...
1
vote
1answer
43 views

Delaunay triangulation algorithm in shapely producing erratic result

I would like to triangulate the following polygon: The wkt for the geometry is given as follows: POLYGON ((3 0, 2 0, 2 0.75, 2.5 0.75, 2.5 0.6, 2.25 0.6, 2.25 0.2, 3 0.2, 3 0)) I ran this code to ...
0
votes
0answers
51 views

Flipping raster with Python

I am trying to calculate summary statistics for a raster file. I am encountering a problem when loading my raster into Python. When I load the raster and I plot it, it is flipped 180 degrees. This ...
0
votes
1answer
57 views

GDAL installation on MAC OSX via conda fails, linked due to Libpoppler and font configuration

When installing GDAL via Conda, install fails, on OSX Mojave and Python 3.7: dlopen(/Users/tomkom/anaconda3/lib/python3.7/site-packages/osgeo/_gdal.cpython-37m-darwin.so, 2): Library not loaded: @...
1
vote
1answer
51 views

Writing Coverage Filter in Planet API

I am in the process of building a script for my degree capstone project with the use of arcpy and the Planet API module. Currently it takes a GeoJSON created from a simple spatial join and in turn ...
0
votes
0answers
27 views

Combine two Geotif Files using Python GDAL

I have a python project where I have two geotiff files providing different types of information (File A and File B). There is a region of overlap between both files. What is the best way to extract ...
1
vote
2answers
39 views

qgis_version_2: add layer or group of layers always on the top of the legendInterface / Insert the layer at the top of the ToC

I have a code which is adding raster layeror group of raster layers, its working fine. I want to know if there is a way to add layer or group of the layers always on the top of the legend Interface? ...
0
votes
1answer
62 views

How can I resample a image or imagecollection to a higher resolution in Google Earth Engine Python API

I try to use resample and reproject function in GEE to downscale the MODIS 250 products into 240m in order to correspond the 8*8 Landsat 30m pixels for furture purpose. I used a Landsat image for ...
1
vote
1answer
47 views

QgsLayerTree alternative in QGIS 2.x

I developed a plugin for QGIS 3.x but I need to adjust it to work with QGIS 2.x too. Here is code which is working nice with QGIS 3.x: root = QgsProject.instance().layerTreeRoot() #QgsLayerTree ...
0
votes
0answers
25 views

Creating a custom “flat” projection definition in proj4

I want to create a simple, custom projection in proj4. I need it to be completly flat ( rectangular coordinates ). Starts in point (0,0), meters as unit, everything else - as simple as possible. What ...
0
votes
1answer
15 views

Transforming to GPS coordinates using projections with osgeo with Python

I am trying to transform a shapefile and its datum to GPS (EPSG Projection 4326 - WGS 84) but I get very different result on Google Earth, I write: from osgeo import ogr, osr file_name = 'POIS.shp' ...
1
vote
0answers
40 views

Create continuous line network using PostgreSQL [closed]

I have shapefile which doesn’t have continuous network. I want to connect it to the nearest line and create continuous line from it. the postgis table has three columns- gid,objectid and geom.The geom ...
2
votes
1answer
41 views

Getting angle of point generated from DEM in Raster using Field Calculator in ArcGIS Desktop?

I am trying to calculate the angle of some specific points generated from flow direction in ArcMap 10.2. I converted the DEM to flow direction and then to points. I am trying to convert the grid_code ...
0
votes
0answers
33 views

Geodataframe not plotting properly in geopandas

I am playing around with the gdf.plot method which is supposed to facilitate plotting geodataframes using geopandas. The reason is that I would like to avoid jumping from QGIS to python while ...
2
votes
1answer
29 views

Writing Non Spatial Table into Geopackage - Python

Just wondering how to write a non spatial (aspatial) table to geopackage using python. I have attempted using Fiona, geopackage = 'some_geo.gpkg' layer = 'test_layer' schema = {'geometry': {'type'...
1
vote
1answer
33 views

Extracting raster

I've been using my own code to extract multiple rasters using a single shapefile. I've just substituted the strings (inputs, file paths etc.) to my code: import subprocess, os, glob, gdal ...
1
vote
1answer
71 views

Can Gdal.Translate() return an object instead of writing a file?

I have some Python GDAL code I am using to convert a GeoTIFF file to PNG. The code uses the gdal.Translate() function which generates a new file each time I run it. However, I was wondering if there ...
1
vote
1answer
32 views

Planet API not being accepted for quick search but is on stats

As is similar on another post about this problem I receive the error, "message": "Please enter your API key, or email and password.", "errors": [] when trying the script, #API key stored as an ...
0
votes
0answers
35 views

Different values between original raster and cropped raster with rasterio.mask

I have a large sentinel-2 image and I want to clip it according polygons which are stored in a geojson file. My code is: df = gpd.read_file(os.path.join(geojson_folder,geojson_file)) df.head() ...
0
votes
1answer
27 views

Text File MultiPolygon/Polygon to PostgreSQL using Python/Psycopg2

I am writing a python script attempting to insert GeoJSON Polygon coordinates into a Postgres table. I am writing a basic insertion code since I am new to GIS domain. The code look like this: ...
1
vote
0answers
13 views

QgisPlugin_Faculty

This is the formula for calculating stdev. My goal is to get raster but I'm getting a result in python console [ ] insted of raster. formula_st = '((' + str(k) + '-2)/(' + str(k) + '-1)*C + (1/' + ...
0
votes
0answers
106 views

DLL Load Failed: The specified module could not be found -Anaconda 3 on win10

I know that this question has been asked a lot (e.g., here, here, here, and here), but none of the solutions worked for me. I downloaded the latest Anaconda version (file name - Anaconda3-2018.12-...
2
votes
0answers
54 views

Adding new field and calculating in PyQGIS

I'm trying to write a script using QGIS 3.4. What I want to achieve is an Excel-style calculation where I can create a new field "field2" and calculate the difference between a current and previous ...
0
votes
1answer
41 views

Passing dictionary to map function

I have a points feature collection and have added the latitude and longitude to each point's properties as well. Now I want to do a processing on each point and want to use the map function. The ...
0
votes
1answer
28 views

Multiple LAS files- Define Projection [closed]

I am looking for some help drafting code to define the coordinate system for multiple las files. I have seen plenty on how to batch define projections with rasters and shapefiles, but nothing on las ...
1
vote
0answers
62 views

Error in reproject vector file using GeoPandas

I have a vector file (in this case shp file) and I read it with GeoPandas (gpd). vector_folder = r'C:\poly' vector_file = 'poly.shp' df = gpd.read_file(os.path.join(vector_folder,vector_file)) df ...
0
votes
1answer
38 views

Open 4d NetCDF subdatasets with GDAL in Python

I have NetCDF files containing subdatasets with 4 dimensions: time, height, latitude, longitude. Here is an example of the output of GDAL GetSubDatasets(): ('NETCDF:"Martinique_ALT22.nc":height', '[...
0
votes
1answer
49 views

Spatial overlays : Union between multiline and multipolygon with geopandas

I try to overlays (apply union) my multipolygon on the multiline with GeoPandas, but it seem like the GeoPandas overlay function work only with (Multi)polygon. Is there any way to make that with ...
2
votes
0answers
45 views

How to get raster layer metadata in python for QGIS 3.6? [closed]

I am loading imagery as raster layer through a URL. I need to store its metadata as JSON string in db for future reference. I tried getting the metadata via layer.metadata() and then tried to get ...
1
vote
0answers
74 views

Calculating distance between point and MultiPolygon Geoseries object in Python [closed]

I want to calculate the distance of a point from the Multiploygon geoseries object created using cascaded_union function of GeoPandas. Following is my code: import numpy as np import pandas as pd ...
2
votes
0answers
29 views

Downloading subset of MODIS data through HTTPS [closed]

I need to download 'MYD04_3K - MODIS/Aqua Aerosol 5-Min L2 Swath 3km' data for India. I found two ways to download it: Go to the website and select product details etc. I have been able to automate ...
0
votes
1answer
56 views

Why GDAL is not running in Python 3.7.2 powershell

I installed GDAL 2.4.0 core and GDAL-2.4.0.win32-py3.7 to run my code but it is not working
0
votes
1answer
54 views

How to cast Geometry to Geography in PostGIS/Postgres with sqlalchemy + geoalchemy

Some PostGIS functions behave differently based on the arguments types. Example: ST_Distance will calculate projected units distances for geometry arguments and meters distances for geography ...
1
vote
1answer
44 views

GDAL Python API - statistics valid percent information

I would like to know if the STATISTICS_VALID_PERCENT (percentage of valid (not nodata) pixels) information is accessible through the GDAL Python API? It seems to be missing from the GetStatistics ...
0
votes
0answers
23 views

Would like to randomly sample points from within a polygon using Python [duplicate]

I would like to achieve something similar to the ArcGIS Create Random Points tool using geopandas, shapely, or rasterio. I aim to have a polygon with some holes in it (removed by subtracting buffered ...
3
votes
0answers
36 views

Indexing to Open Data Cube not working for land cover map

I'm trying to index a clipped version of ESA's 2015 land cover map into an Open Data Cube instance. I've written a product specification yaml and a yaml for te actual product itself and it indexes ...
1
vote
3answers
92 views

Is it possible for ArcMap to treat data types (numbers as text) correctly when importing from a text file?

I am creating a text/csv file (using a python script). The file contains data to import into ArcMap. I have several fields that look like numbers but have leading zeros ("0012") etc. that I want to ...
1
vote
2answers
80 views

Python crashes after reading a certain number of mxd files

In one of my work, I need to go through about a few thousand mxd files, get some information from each MapDocument object (scale, printing paper size, map title, etc.), and write those information to ...
3
votes
1answer
63 views

What is the minimum `metadata` specification for the Open Data Cube?

There is a standard metadata definition here, but I would like to create a new one, with only the absolutely required fields. What is the minimum set of values that can be used to define a metadata ...
1
vote
1answer
74 views

QGIS 3 Processing Script refer to input layer

I'm new to Python and trying to figure out how to write my first Processing Script using QGIS 3.6 on Windows 10. I'm using the default template provided in QGIS 3 (Toolbox > New script from template)....
1
vote
1answer
43 views

Applying coordinate systems and projections to unprojected images

I have a folder with many unprojected images (i.e. LocX_1_LocY_1.tiff to LocX_32_LocY_32.tiff) which have a naming convention that is associated with a text file that has surveyed locations of the ...
3
votes
1answer
27 views

PyQGIS - how to override maximum number of features in combobox

Is there a simple way, how to override a maximum number of displayed features in QgsFeatureListComboBox? It seems that there is a hardcoded limit set to 100 features (in QgsFeatureFilterModel). ...
2
votes
1answer
40 views

Calculating areas of polygons inside other polygons with GeoPandas

I have 2 geodataframes: GDF1 is an area with overlapping polygons divided into 3 classes: (cleaning, infra and maintenance) (the black lines donates the overlapping polygons) GDF2 consists of ...
0
votes
1answer
80 views

Dissolving polygons to single part features with Python (shapely and fiona)?

I used the code from Dissolving polygons based on multiple attributes with Python (shapely and fiona)? to dissolve a shapefile using shapely and fiona. However the output creates multi-part geometries....
0
votes
0answers
28 views

SIP API Error - QGIS Noosa

I have QGIS Noosa installed on two separate PCs working on Xubuntu. Both the PCs are configured for the same QGIS repository. However, on one of the PCs, I have the following error: Traceback (...
0
votes
0answers
45 views

Difference between haversine formula & geodesic distance for calculating distance

Background I have Vehicle driving data which includes Lat/Long points of a particular route. I drive in that route for 2 times. The driving data in that route is around 20 minutes. (Approximately ...
1
vote
0answers
37 views

Calling external plugins downloaded via Plugins through a separate out of QGIS Python Script

I was wondering if I could produce webpages daily by automatically creating a standalone python script, outside of QGIS. My webpage should ideally contain various layers and an interpolation on top ...
2
votes
1answer
148 views

Creating square buffers around points using shapely? [duplicate]

I am trying to create square buffers around given points, I am able to create circular buffers but how do I create square ones? from shapely.ops import transform from shapely.geometry import Point ...
2
votes
1answer
41 views

Find out which Python executable QGIS is using on Mac OS

I'm trying to find the path to the Python executable QGIS 3.6 is using on Mac OS. Usually (i.e. Python "outside" of QGIS) I'd: import sys print(sys.executable) But that only gives me the path to ...
0
votes
1answer
48 views

GDAL Open ZIP returns None

I'm trying to open Sentinel-2 bands directly from the .zip L2A files with GDAL, but this only returns a None. Unzipping the folder prior to reading the file yield better results, but still randomly ...