Questions tagged [python-2.7]

Version 2.7 of the Python programming language

Filter by
Sorted by
Tagged with
-2
votes
0answers
22 views

Error local variable “elevation” referenced before assignment" [duplicate]

I had got this error when I try run Qwater model. "2019-09-15T19:47:05 WARNING Traceback (most recent call last): File "C:/Users/OS10/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QWater\...
0
votes
1answer
42 views

Finding intersection point between two arcs? [closed]

I am trying to find the intersection between two arcs. I have done this for line segments using shapely package. Does anyone have any advice?
1
vote
1answer
32 views

Turn string data (of GPS coordinates) into a GPS tracker = frozen map. QGIS2.14/Py2.7/Win7/LAN

I am currently involved in a student project which is to turn string GPS coordinates into a GPS tracker. This is my current work: First, the UDP data is shared through a LAN (No internet available) ...
0
votes
0answers
44 views

Using UpdateCursor in the same loop as SearchCursor

I have 2 layers, one with land plots and one with hazard zones. I want to iterate through the layer with land plots and for every plot I want to add 2 (or 3, depending on some variables) fields. Then ...
1
vote
1answer
30 views

Updating gdb with JSON?

parcelsFC = os.path.join('temp.gdb',JsonDirectoryLocation) arcpy.JSONToFeatures_conversion(parcelsFC) Created gdb with above code. How can I add attributes to gdb with another JSON file?
0
votes
1answer
90 views

Getting India map on QGIS canvas using PyQGIS?

Can I get India map extent in one click from OSM tile on canvas using PyQgis? This is my code snippet. canvas = iface.mapCanvas() urlWithParams = 'type=xyz&url=https://a.tile.openstreetmap.org/{...
1
vote
0answers
24 views

Layers being removed erroneously at Python script tool finish? [closed]

I've got two Python scripts as a tools in a standard toolbox, and when the tools finish they will sometimes remove a layer from the MXD. It is most likely to happen on the first run of the tool ...
3
votes
1answer
3k views

Error installing Shapely package using pip command

I'm using Windows 10 and python 2.7. Even though I updated pip it's getting error: ERROR: Command errored out with exit status 1: command: 'c:\python27\python.exe' -c 'import sys, setuptools, ...
1
vote
0answers
14 views

Earth Engine API (Python) Retrieves script found at a given path as a module not working

Earth Engine API says that require(path) returns an object that represents exported members from the required module. When I try to import ee-palettes with: palettes = require("users/gena/packages:...
2
votes
0answers
58 views

How to capture the event whenever the items inside a listview are checked

I'm developing a plugin in QGIS 2.8.2 using Pyqt 4. Well the idea is using the processing 'qgis:extractbylocation' from the QGIS algorithm provider to capture the studied area # Récupérer tous les ...
1
vote
1answer
32 views

Iterating through 2 different Geodatabases at same time using ArcPy?

I have 2 gdb's; one that contains a polygon feature class of census blocks(cb), and one that contains centroids that may lie within those census blocks. They are organized by state. Ex: FL_cb = ...
0
votes
0answers
13 views

Arcpy exporting feature by attribute in ArcMap 10.3 [duplicate]

I'd like to automate exporting each polygon feature by attribute(year) in a shapefile to seperate shapefiles named by year Now I know this exists in arcpy with 10.5 or higher using the ...
0
votes
0answers
42 views

Set default version of Python in ArcGIS to 64-bit?

This is the output from Python terminal within ArcMap 10.6.1 for Windows 10: >>> import sys, numpy, matplotlib >>> print(sys.version, numpy.__version__, matplotlib.__version__) ('2....
2
votes
1answer
50 views

Getting coordinates on click and pass it to dialog using PyQGIS?

I am creating a plugin in which i need to get coordinates by clicking on QGIS canvas so i tried the solution mentionned at Getting coordinates by clicking on QGIS Canvas with PyQGIS? but it didn't ...
1
vote
1answer
49 views

To update Point location every 1 second

I am using update cursor to change the location of a point with FID = 0 every second, but whenever I run the code my ArcGIS freezes and point doesnot move. I am visualizing an output where the point ...
1
vote
0answers
28 views

Snapping line to polygon border using PyQGIS?

I want to snap the line (completely present inside the polygon) to polygon boundary. I tried create 10 m buffer on line start and end point to get polygon and check intersection between line and ...
0
votes
2answers
100 views

How to create a weighted square lattice as well as a weighted network graph

I am planning to create a weighted square lattice for different sizes, and then label each edge with its associated weight. It's similar to this thread "How to load a weighed shapefile in networkX" ...
2
votes
1answer
30 views

I have the following multilinestring, and I am looking for finding the intersection between each pair

I have a pair of lines, which I like to find the intersect of each of one them with each other. I know for two lines I can do the following: from shapely.geometry import LineString line1 = ...
0
votes
0answers
62 views

Loading .qgs and .qpt files in standalone PyQGIS script?

I have a .qgs and .qpt files. And I would like to know if it is possible to use them in a standalone PyQGIS script? I am using QGIS 2.18 and Python 2.7 This is the template that I would like to use. ...
1
vote
0answers
22 views

JSON response to shapefile [closed]

I'm collecting road accidents from an API through a Python request and getting my response as JSON. The JSON response contains coordinates and general information as below. {u'RESPONSE': {u'RESULT': ...
1
vote
0answers
44 views

How to find which direction to flow between two points in QGIS Python? [closed]

I want to find which way direction to go based on two points and line segment. I have two layer line layer and point layer.user selects the two points in lines layer. I have to find which direction to ...
1
vote
0answers
46 views

QGIS temporary layer to PostGIS table database

I have an empty polygon table in PostgreSQL/PostGIS database with fields (id,field_1). after some processing in QGIS using pyqgis and processing toolbar I create some temporary layer like this case : ...
0
votes
1answer
91 views

How can I run an ArcPy Python Toolbox from Python3-shell?

I am trying to port an arcpy python toolbox from ArcMap to ArcGIS Pro. In ArcMap I had to use the 64-Bit-geoprocessing tool because of the size of the datasets, so I wrote a wrapper-Script for the ...
4
votes
1answer
196 views

Filter vector layer by searching through complete attribute table - limitations and improvements

In a case were I have a shapefile with a lot of attributes (predominantly text), also I don't have any information about the structure and I don't have any idea in which attribute I have to search/...
0
votes
0answers
22 views

arcpy.Project_management - different results from python shell and python command line

I am trying to transform a number of shapefiles by script using a self-defined custom transformation. When I transform the shapefile using my script in the python shell of the ArcGis GUI everything ...
2
votes
1answer
146 views

Accessing Home directory of ArcMap using ArcPy?

I want to access to a directory and set that as a arcpy.env.workspace in my Python Script Tool. However, this workspace depends on users so I cannot just use my own folders. Is there a way to access ...
1
vote
0answers
18 views

Snap pour points not recognizing sample sites as valid points when using ArcPy?

I am trying to go from a CSV of sample sites and a DEM to creating watersheds. I can process the DEM fine to stream networks and can import the points (first to event layer, then convert them to a ...
0
votes
0answers
88 views

How to upload ImageCollection from GEE to CloudStorage (Bucket) automatically Python/JavaScript [duplicate]

I have some ImageCollection with around 120 images in the GEE Web IDE. I want to upload them to a Google Cloud storage bucket. But it raises the Error: I think because the export function is only for ...
0
votes
1answer
48 views

Get Messages from Geoprocessing Service

I have created a Geoprocessing service that is hosted on a server inside our firewall (ArcGIS Enterprise 10.6). The GP service adds messages via arcpy.AddMessage("msg"). Locally, I import the toolbox ...
1
vote
1answer
86 views

Array in python just full of zeros when opened using GDAL

I'm working on the below script. What I'm trying to do is create a stats.txt file output which has the Land Cover Class ID, Fractional Coverage (of that class) and the number of pixels (of that class) ...
2
votes
1answer
91 views

How to find how grass's r.viewshed works programmatically?

I want the Python source code of Grass's Viewshed analysis. In QGIS software there is only an .exe file of that algorithm. Although I'm not sure whether it's written also in python or not. Where can ...
0
votes
1answer
37 views

PyQGIS import from UI class problem

I've tried to build a plugin from scratch to better understand the plugin structure and so on without the help of PluginBuilder or similar tools so my code could contain flaws. I went through every ...
1
vote
1answer
440 views

NumPy array to Raster file (GeoTIFF)

I converted a raster file (one band grey scale) to an numpy array and set a range to it. I Did like that: import gdal import numpy ds = gdal.Open('H:/GDAL_docs/a.tif') myarray = numpy.array(ds....
1
vote
1answer
58 views

Joining single column in ArcGIS Desktop with Spatial Join

I'm trying to automate a rather annoying workflow in ArcGIS 10.4 with a Python script. My goal is to extract data from a polygon shapefile into another polygon shapefile which is arranged as a raster (...
0
votes
1answer
64 views

Configuring ArcGIS Desktop to use already installed Python instead of own installation? [duplicate]

Whenever ArcGIS Desktop is installed, it installs its own installation of Python 2.7 plus Numpy. Yet, I already have many different versions of Python installed in my machine and do not want to have ...
1
vote
0answers
47 views

gdalcalc.py in Python 2.7 subprocess Popen - not spawning, nor any Exceptions

from subprocess import PIPE, CalledProcessError, Popen import subprocess import osgeo raster = '/home/rphillips/Desktop/tif_dir/merged.tif' raster_dir = os.path.dirname(raster) binary = raster_dir +...
1
vote
1answer
267 views

Comparing pixel values at a given point in two rasters

I have two raster images, one for land use and one for NDVI, i would like to calculate LAI based on land use. So i need to compare the pixel value in the NDVI raster and Land use raster then select ...
1
vote
1answer
55 views

Merging on specific fields

Lets say I have three shapefiles/features I want to merge: 'florida.shp', 'mississipi.shp' and 'louisiana.shp'. They all have 3 standard fields common to all: 'DFIRMID', 'SFX', and 'FIRMPAN'. I want ...
2
votes
1answer
53 views

Copying feature classes from gdb to different folder locations in Python?

I am very new to Python, and I'm trying to create a function where I'm copying over feature classes from a gdb to different folder locations as shapefiles. The script needs to be reading from a ...
1
vote
0answers
107 views

Numpy import error in OSGeo4W Shell

I and my colleagues are running into a very frustrating Python import error while using the OSGeo4W Shell. Any time we attempt to use gdal_calc in a Python script, we get the following error message: ...
1
vote
1answer
40 views

Loading shapefiles in standalone PyQGIS application without GUI

One of the related questions mentions an issue with import order, but I don't think that applies here because this is a command-line script: I'm not using Qt, only QGIS libraries. I'm trying to run ...
4
votes
1answer
113 views

Why does osr.SpatialReference return different values in python2 and 3?

Can somebody explain why the result of osr.SpatialReference() differ between Python 2 and 3? sr = osr.SpatialReference() sr.SetFromUserInput('EPSG:28992') sr.ExportToProj4() In Python 2.7 this gives ...
0
votes
1answer
83 views

Choosing correct Projection name for ArcPy?

I am trying to plug in a projection name to my code, but I think the syntax/name is incorrect. arcpy.env.outputCoordinateSystem = arcpy.SpatialReference("US Albers Equal Area Conic") When I run the ...
1
vote
0answers
68 views

Using Null Values in Raster To NumPy?

I am trying a convert a raster dataset [a simple 4 x 4] into a numpy array using RasterToNumPyArray. Here is my sample raster dataset: RasterToNumPyArray however, returns zero for Null values: ...
1
vote
2answers
129 views

replaceDataSource() works in ArcMap but not as stand-alone script

I have one script (and one alternative) that I want to use to replace a broken data source. Neither is working outside of the ArcMap Python Window. Has it something to do with the MapDocument object? ...
3
votes
1answer
853 views

Installing Arcpy in an Anaconda enviroment.

I recently uninstalled Anaconda due to a conflict with my pandas packages. I use to have it configured with my ArcGIS Pro Python 3.65 environment. Now I want to reinstall it, but for my ArcGIS ...
0
votes
1answer
31 views

Using `arcpy.Exists()` and `arcpy.Delete_management` on a temporary layer

Suppose I make a temporary layer from a feature class in a gdb: select = arcpy.MakeFeatureLayer_management("roads", "select_lyr", "FIPS_CODE = '06023'") Later I want to see if that layer exists and ...
2
votes
1answer
41 views

“AttributeError: Cannot parse SetParameterAsText” but my indexing is correct

I think I have all my indexing correct. I have 8 parameters in my script tool. 7 input and 1 derived output. Indexing for GetParameterAsText starts at 0, so logically my SetParameterAsText should ...
1
vote
1answer
39 views

Error when creating seach filter from geojson

I tried to read geojson object from .geojson and build search filter rather than set a static geojson_geometry variable. However, it did not work as it used to with the static variable. Win7 pro, Py 2....
0
votes
1answer
164 views

ExecuteError: Failed to execute. Parameters are not valid error when SelectLayerByAttribute run in Python 2.7 [duplicate]

I am running a line of code in a Python 2.7 environment using arcpy.SelectLayerByAttribute_management: fl_haz_selects = arcpy.SelectLayerByAttribute_management(S_Fld_Haz_Ar, "NEW_SELECTION", "\"...