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
0answers
10 views

Save pictures from different files to one file

This is my code: imagePatches = glob('C:/Users/Touati/Documents/cancer_dataset/Dataset/**/*.png', recursive=True) imagePatches.save("C:/Users/Touati/Pictures/test/{}.png".format(item),"png") I get ...
0
votes
0answers
11 views

Trying to use a SelectByAttribute_mangement after I made the XY Event layer

I imported a CSV file using the MakeXYEventLayer_management and trying to use the SelectlayerByAttribute_management function, but I am getting error message saying on "Object ID(OID)" is present.. Is ...
4
votes
0answers
26 views

Python Script Performance as an ArcGIS Tool Versus Stand-Alone

Has anyone studied the difference in running a Python script in ArcToolbox versus as a stand-alone script? I had to write a quick-and-dirty script to convert a set of RGB images to single band by ...
0
votes
1answer
14 views

Identifying intersections in ArcPy

I have two shapefiles: one containing a single polyline feature, and the other containing a number of polygons. I'm trying to use ArcPy to identify which polygons are crossed by the line, and then ...
3
votes
0answers
14 views

Python GeoPandas: How do I make a Shapely box larger

I'm creating a box that covers the the area of a GeoPandas GeoDataFrame, so that I can use it as an inverted map to later cover up unwanted spill-over data. import geopandas as gpd import geoplot as ...
1
vote
1answer
19 views

How to reverse the MultiLineString command to a list of arrays

Let's you have a list of coordinates that you can convert to a line string: coords = [((0.0, 0.0), (0.0, 20.0)), ((20.0, 0.0), (20.0, 20.0)), ((1.0569687968009744, 14.934839039628798), (5....
1
vote
1answer
23 views

Multiple shapefiles to one GeoPandas GeoDataFrame

I'm trying to vertically concatenate multiple shapefiles that reside in one directory, into one geodataframe. They all have the same table schema and same CRS. I am trying to use the code from this ...
0
votes
0answers
15 views

Installing QGIS on OSX: “QGIS requires Python 3.6” but 3.6 is already default Python

I'm trying to install QGIS on OSX Mojave from the official installer. I have system Python 3.6 installed, as the default: $ which python $ ls -al /usr/local/bin/python lrwxr-xr-x 1 me admin 44 18 ...
1
vote
1answer
22 views

Using GDAL Warp results in odd pixel sizes and gaps

I am mosaicking one meter and three meter rasters to two meters in Python with GDAL Warp using the following code: cl_string = "-of GTiff -co COMPRESS=LZW -tr 2 2 -tap -r near -overwrite \ -multi -wo ...
0
votes
0answers
9 views

Extracting surface reflectance values of stratified sampled points in Google Earth Engine

I created 400 stratified sampling points (100 for each of the four classes) using this script: https://code.earthengine.google.com/cbba16d87066b45e61e7d2f7e06bd5c5. Then I exported the result as an ...
1
vote
0answers
10 views

Dissolve Line Strings to one string - “No Shapely geometry can be created from null value”

I have a layer with 7000 LineStrings, all represent bus routes: It seems that all the bus routes are contiguous, but I'm not sure of it. I'm trying to use python shapely to dissolve all those ...
0
votes
0answers
13 views

Problem with Fill Sinks - ArcHydroTools

I'm getting use FillSinks of ArchHydroTools with Python but some problems are happen My code is: Import arcpy Import ArcHydroTools ArcHydroTools.FillSinks('projectraster.tif','fil.lyr', "10", "...
3
votes
1answer
34 views

Cheapest path through polygons and lines from point to point

I want to find the cheapest path or the least cost path from one point to another point. The points are part of a vector map and do not lie on a network. All features being part of the map have ...
5
votes
2answers
33 views

Distance to a ridge as function of angle (Python)

No success googling this for a while, but likely I just don't know correct terminology. Also, tell me if you see another exchange more suited for this. Given: A boolean 2-dim array that stores if a ...
0
votes
0answers
9 views

Open NITF containing multiple images using Python GDAL

I have a file in NITF 2.1 format, which contains multiple images within it (in ENVI speak "image segments"). But with Python's GDAL, opening the file only gives me access to the first image. How can I ...
0
votes
2answers
15 views

Geoviews Attribute error

I just installed GeoViews with success and I tried to follow one example at the first page of their site and this already gave me an error. In fact, there are two errors of the same type that occurred ...
1
vote
1answer
34 views

Calculating minimum distance in meters of two polygons (defined in lat/long coordinates)?

I'm new to GIS and I'm a bit lost in the terms and concepts, so I'm not sure I'm asking a valid question, but I need to calculate the minimum distance (in meters) of two polygons which are defined in ...
3
votes
1answer
67 views

Using libraries other than PyQGIS to develop plugin for QGIS?

I develop a plugin for QGIS. Before to integreted it in the QGIS I developped it with GIS library (Fiona, shapely, geopandas, ...) and it work well. Now I try to build it with plugin_builder of QGIS. ...
0
votes
1answer
23 views

ERROR 000732: Output Location: Dataset results does not exist or is not supported?

I'm trying to use MosaicToNewRaster but a lot of errors are appears. One of them is: ERROR 000732: Output Location: Dataset results does not exist or is not supported My code is: import ...
2
votes
1answer
23 views

geopandas.intersects() over each row

In trying to answer this question I ran into problems with geopandas.GeoSeries intersects methods. I have the following line and polygon: import pandas as pd import geopandas import pickle line = ...
1
vote
0answers
14 views

gdal_merge novalue

I managed to run gdal_merge for multiple geotiles (jpeg). I am using the following options: command = "gdal_merge.py -init 0 -a_nodata 0 -co COMPRESS=LZW -co BIGTIFF=YES -o "+out_bez+" -of gtiff " +...
0
votes
0answers
14 views

Bar chart of capitals by latitude in 5 degree increments in the lower left of the figure [on hold]

Trying to figure out how to plot a bar graph with my lat and long data (minus Alaska and Hawaii)... The bar graph also needs to be in 5 degree increments. Here is my code so far for the 3 part image.....
2
votes
0answers
39 views

Write selected features to shapefile using OGR and Python

I have two shapefiles that intersect: one containing a line, and the other containing polygons. I'm trying to use OGR and Python to create a buffer around the line and select polygons within it, then ...
0
votes
1answer
15 views

Display longitude latitude points on xy raster file in meters and with projection of Albers Conical Equal Area

I'm new to Python and I have a data set which contains longitude and latitude coordinates(WGS84) points, and a .img raster file of CONUS in meters and with the projection of Albers Conical Equal Area. ...
1
vote
0answers
18 views

Cut line at intersection using Shapely

I'm trying to cut a line at the intersection, if a line crosses another line within a single multilinestring then and the end of the line is below a maximum distance threshold then it swaps the end of ...
-1
votes
0answers
25 views

Creating a Geo package layer Qgis-3.2 version [on hold]

how to create a Geo package layer in python Qgis version 3.2? In Qgis vector layer not support the field name more than 10 characters. So, I have to create a layer using geo package its create a ...
0
votes
1answer
22 views

ERROR 1: NUMPY driver was compiled against GDAL 2.1, but the current library version is 2.2

When running my Python program, the following error came out: ERROR 1: NUMPY driver was compiled against GDAL 2.1, but the current library version is 2.2 What can I do to fix this?
0
votes
0answers
18 views

Installing OSGEO and GDAL in Ubuntu

I'm trying to run a Python program which needs to import from osgeo import gdal, ogr import osgeo.ogr, osgeo.osr from osgeo.gdalconst import * But when I run it outputs Traceback (most recent call ...
0
votes
0answers
29 views

GeoPackage attribute field [on hold]

How to get GeoPackage layer attribute fields and values in Python Qgis (3.2 version) and then how to rename the attribute field names?
-1
votes
0answers
32 views

Change filename of QGIS layer in Python? [on hold]

Is there a simple way to change the filename of a layer while operating in QGIS. (The obvious way is to close the layer, rename the file, and open it again. However, renaming it with a simpler ...
2
votes
0answers
22 views

GDAL processing output to memory in Pyqgis

How do I save GDAL processing output rasters to a temporary layer? Using 'memory:' for vector processes works fine, but I couldn't get it to work for GDAL processes. output_rast = self....
0
votes
1answer
35 views

Can't read shapefile in Python

I'm trying to read in a shapefile and keep getting a File Not Found error and this exception: ShapefileException: Unable to open /Users/name/Documents/shapefile.shp Here's what I've got: import ...
1
vote
0answers
24 views

Underlying distribution of points in an ellipse

I'm attempting to generate both a uniform distribution and a normal distribution of points that fall within an ellipse shape, made from a centre point, semi major and minor and rotation in degrees. I ...
0
votes
0answers
9 views

gdal.ComputeProximity always returns 0-value raster

I try to create a raster layer with the smallest distance to cells with targeted value so I use gdal.ComputeProximity(). But I must do something wrong because my output raster contains only 0 values. ...
0
votes
0answers
14 views

How to create a grid with help of a JSON file which consist 16 values for different polygons [closed]

I have a JSON file which consist of polygon coordinates for 16 polygons. How do I create a grid and name the grid cell with the respective id of that grid cell, and in the end I have to compare which ...
0
votes
0answers
22 views

USGS dataset accept [closed]

I want to make a project using data from Landsat-8. I have registered on the site but I have an error "dataset_invalid" when I'm trying to request images. What should I do? Which datasetName can I use?...
2
votes
1answer
46 views

Forcing QgsTask to cancel in QGIS plugin?

I want to force closing Qgis project (QgsTask) in some point NOTE: QgsProject.instance().clear() # NOT WORKING QgsTaskManager().cancelAll() # NOT WORKING QgsTask.cancel() # NOT ...
1
vote
0answers
15 views

Postgis to GML in python or c# [closed]

I know that there is great tool called ogr2ogr. It is a command line to and using it I can get some data from postgres and write it down to GML. Looks great but I would like to have some more ...
2
votes
1answer
37 views

IDW interpolation in Python in QGIS 3.4

I have a problem with IDW interpolation. I need to use canvas extent and other attributes (I created an option with only attribute 0, other attributes aren't working). The documentation is not very ...
1
vote
0answers
26 views

Error : Could not load source layer for INPUT

Very simple piece of code. I'm trying to run this as a stand alone Python script, not in the console. Keeps giving the error "Could not load source layer for INPUT" , shape not found. But the os....
2
votes
1answer
30 views

Convert worldfile for jpg to worldfile for png

I am using 3 band jpeg files with 1 band png masks for image analysis. The names match except for extension, and I am merging the jpgs using gdalbuildvrt, then gdal_translate to generate a geotiff. I ...
1
vote
0answers
12 views

GDAL - Polygonize multiband raster and save pixel values of each band to corresponding attribute fields

I'm trying to polygonize 2 band raster(which was previously reclassified) and put values of each band into seperate attribute table column. Both bands overlap each other perfectly. This piece of code ...
1
vote
0answers
22 views

Is it possible to put grid lines with coordinates in a PyQGIS standalone script?

I just want to know is it possible to put gridlines and border with coordinates (lat, lon) in an image in a standalone pyqgis script. I have checked almost all cookbooks about python ang qgis and ...
0
votes
1answer
35 views

Quickly find all polygons that overlap with two or more polygons in Shapely

I have a set of Polygons (in Shapely) that I wish to find all intersections that are comprised of overlaps of two or more polygons. I have been working based off the code found in this answer. I have ...
0
votes
2answers
40 views

How to inverse the orientation of the holes coordinates of a polygon in geopandas

I have a polygon shapefile which I am reading with geopandas. The polygon contains holes. My purpose is to add a random point inside each hole. In order to create the points inside the holes (...
0
votes
0answers
15 views

ExecuteError when loading rasters using ArcPy Mosaic to Raster tool and Python multiprocessing

I'm attempting to merge thousands of rasters into a smaller more manageable number using the Mosaic to NewRaster_management tool in ArcPy. The code I've written works just fine when I run it the ...
0
votes
0answers
35 views

How to determine which point lies in which polygon from a list of multiple polygons

I am new to python and currently working with Json file and I need to determine the location of each tweet and represent the grid in which they are present with the count of tweets in each grid cell.I ...
-1
votes
0answers
16 views

Python script for extract variables from Modis data [closed]

I am using Modis data, of LAI and Fpar which I want to extract separately, like LAI and Fpar both variables I want to separate. I am using ArcGIS for this but the tool takes only one tails for input ...
1
vote
1answer
33 views

Intersection function returns multiple coordinates

I am trying to find intersection vertices of two polygons defined below PG = Polygon([(0.0,0.0), (0.0,4.0), (2.0, 0.0)]) QG = shapely.affinity.rotate(PG, 10.0, origin="centroid") print(PG....
-1
votes
0answers
14 views

ArcPy Near Tool not reporting distance [closed]

I am trying to use the Near Tool in ArcPy. The tool has populated the NEAR_FID field, but unfortunately the NEAR_DIST field is 0 for all rows. This problem was reported in 2016 (https://community....