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-2.7]

Version 2.7 of the Python programming language

0
votes
0answers
11 views

Reducing run time to extract cell values from multiband rasters? [migrated]

I have the following function and code snippet to extract cell values for multiple years, format it, and save to a list. Each raster has 365 bands -- one for each day. A separate operation is ...
0
votes
0answers
38 views

Using user input vs GetParameter in ArcPy? [on hold]

I successfully wrote a script tool in Python 2.7 that utilizes GetParameterAsText but I keep seeing tutorials about input and rawinput. What is the difference and in what scenarios would input be ...
0
votes
2answers
45 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
28 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
46 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
20 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
28 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
39 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
52 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 ...
5
votes
1answer
161 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
19 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
74 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
10 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
34 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
30 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
64 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
60 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
32 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
142 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
47 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
50 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
34 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
160 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
49 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
47 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
59 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
0answers
33 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
110 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
56 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
43 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
66 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? ...
2
votes
1answer
485 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
29 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
34 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
33 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
80 views

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

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", "\"...
0
votes
1answer
40 views

comparing parcel ids from two tables with arcpy.da.SearchCursor

My goal is to compare parcel IDs from two tables, one is a standalone shapefile and the other is a feature class inside a geodatabase (SQL Server). Both tables field name is "PARID" and the values are ...
0
votes
1answer
184 views

Getting a token access to feature layer using Postman and Python

I am trying to query a feature server using postman as ESRI'S documentation: https://developers.arcgis.com/labs/rest/get-an-access-token/ I have succesfully added the Authorization to the body of the ...
2
votes
0answers
33 views

Clipping outside QGIS with PyQGIS?

This is my first script and I having a problem trying to clip a shp file. I'm running on a linux server and this is my code: #! python from datetime import date from qgis.core import * from PyQt4....
0
votes
1answer
34 views

gdal.Warp cutline creates empty file when run on the server, but works perfectly fine through Python command line

Trying to cut geotif with a shp file. When I open Python command line interpreter and run from osgeo import gdal gdal.Warp(outfile, infile,format='GTiff', cutlineDSName=shpfile, srcSRS='EPSG:4326',...
0
votes
0answers
56 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 ...
0
votes
2answers
51 views

Iterating through tables in map document and replacing workspace paths using ArcPy?

I am using Python 2.7 and ArcGIS 10.4.1 to create a script that walks through folders and scans for mxds. I use a set to get unique data sources and copy the data to a new folder keeping the same data ...
1
vote
0answers
53 views

ArcPy not seeing ArcSDE datasets from IDLE or PyScripter? [duplicate]

I tested the code below from ArcCatalog 10.5's python console and IDLE+PyScripter. While in ArcCatalog everything works correctly(code is supposed to list available datasets and feature layers), in ...
4
votes
1answer
176 views

python GDAL 'GetDriverByName', argument 1 of type 'char const *'

i want to use python GDAL to convert some rasters files but i take error in the create new tiff image and specific in the line driver= gdal.GetDriverByName('GTiff') update : python version 2.7 64 ...
0
votes
1answer
147 views

Creating standalone python Script using PyQGIS?

I have written a code which solve my problem for Demand Allocation. I have Input (.csv)File and Output is also (.csv) File. However I have to integrate this script in Java Application.(https://...
0
votes
1answer
139 views

Integrate QGIS Plugin with Java Project [closed]

I have a Java Application. I am using QGIS to solve one such module of my Java Application. I have written code in python console within QGIS.Is there any way to integrate both of these? I am ...
3
votes
1answer
119 views

Select Layer By Location gives ERROR 000840 ({select_features} as arcpy.Polygon)

I tried to select SC27060054 point object using polygon. r"Project\project.DBO.Qo" is a point layer. import arcpy p1 = arcpy.Point(254426.380, 4664270.258) p2 = arcpy.Point(254432.730, 4664270.258)...
1
vote
0answers
307 views

ValueError: array is too big

I'm trying to get the value of a pixel from a coordinate. The problem is when I use a large image, so this error appears Traceback (most recent call last): File "D:\algoritmo\teste_read_2.py",...
0
votes
1answer
52 views

Intersecting polygons from different layers based on common values using ArcPy? [closed]

I have two polygon shapefiles (ShapeA and ShapeB) that share some areas. The shapefiles have one attribute in common (CODE) and I would like to do a selection, where I select all the polygons in one ...
0
votes
1answer
27 views

List Esri GRID files from unique data sources in a CSV file using Python 2.7 and arcpy

I have a CSV file with a list of unique data sources extracted from an ArcGIS map document. I would like to list all ESRI GRID rasters that appear in the list. One example is: G:\GIS\Depts\Ex\PA\DB\...