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
8 views

pyqgis intersects and update field

i have two different polygons layers(one postgis layer and other is temporary shp from QGIS) That layers they have common fields names (id,field_1) but different geometries. i want the first polygon ...
1
vote
0answers
29 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
38 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 ...
2
votes
1answer
80 views
+100

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
13 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 ...
1
vote
1answer
45 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
9 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
18 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
22 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
52 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
50 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
29 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
71 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
46 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
42 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
28 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
89 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
43 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
44 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
46 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
32 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
106 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
42 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
35 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
43 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
277 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
28 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
29 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
30 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
53 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
39 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
112 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
27 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
29 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
9 views

How to change column's widget type on QGIS using Python [duplicate]

I need to automate customization of column's widget type in QGIS using Python, I know how to do it throw feature propreties>Fields, as shown in the picture below, but I can not find a python code that ...
0
votes
0answers
47 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
49 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
129 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
102 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
114 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
100 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)...
0
votes
0answers
31 views

Are there any of this concepts: 'last selected object', 'last query' or 'last cursor position' in ArcGIS Desktop?

Are there any of these concepts: 'last selected object', 'last query' or 'last cursor position' in ArcGIS? I want to use them in my python script. I think this will be an easy way to solve the task. ...
0
votes
0answers
143 views

Google Earth Engine Python API: indexing error with batch export to ImageCollection asset

Using the GEE Python API (Python 2.7) and geetools, I am trying to add images to an ImageCollection stored as an asset in GEE. I did not find any way to add directly a set of images stored as ...
1
vote
0answers
250 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
48 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\...
0
votes
1answer
124 views

Python script parameters for Integer not working

I am using a Python library called arcpy_metadata that uses 2 datatype called max_scale and min_scale that take integers: My code for that is just: import arcpy, arcpy_metadata as md .... min_scale ...
0
votes
0answers
102 views

Clipping raster with different UTM zones using rasterio?

I have 2 Landsat images, with an overlapping area: The one on the left is in WGS84 / UTM32N (EPSG:32632), the one on the right is in WGS84 / UTM33N (EPSG: 32633). I have a polygon in WGS84 / UTM33N (...
1
vote
1answer
154 views

Export as DGN with QgsVectorFileWriter.writeAsVectorFormat

This code works in QGIS 2.14 but not in 2.18. What do I have to change to be able to export properly to DGN. From what I understand, now it tries to save in microstation V8 format instead of v7. I ...