Questions tagged [python-2.7]

Version 2.7 of the Python programming language

Filter by
Sorted by
Tagged with
8
votes
3answers
4k views

Login to USGS Earth Explorer and download Landsat imagery with Python

I want to login to the USGS Earth Explorer website at http://earthexplorer.usgs.gov/ with Python and download imagery from the Landsat Archive collection just by giving it username,password,path/row (...
0
votes
0answers
66 views

Very slow ArcPy processing using PyCharm, figuring out the cause [closed]

I am working on a Windows 10 64bit machine with i7 CPU @ 3.10GHZ, 8GB RAM. I have ArcGIS Desktop 10.6 64bit patch and ArcGIS Pro. When using PyCharm linked to Python executable of ArcGIS Desktop 10....
0
votes
1answer
16 views

ArcPy to select by location not showing selected features in attribute table

I have a button where it first calculate no of features in a specific layer and then runs the "are_identical_to" and update "D". After that it checks if the no of counts in two layers is same? If not, ...
0
votes
1answer
24 views

Combobox value increment and update

I have made a custom add-in for my building ID update tool. The objective is: user will write an alphanumeric value in the combobox like 'x100'. When a user selects a bunch of polygons(building) and ...
0
votes
1answer
60 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',...
1
vote
0answers
20 views

My UpdateCursor is not working. The attribute table of my new shapefile is not updating [closed]

I am new to arcpy. I am trying to do a few things with a shapefile. First I created a new shapefile with specific dataset that I wanted to work on. So far everything works until the UpdateCursor. When ...
4
votes
1answer
69 views

Not able to update the “ACTION” field

Currently I am working on a GIS project where I have to update a field in a layer with some values to get my work done. Because the manual efforts are time consuming hence I added a custom addin to my ...
0
votes
2answers
41 views

How to access/manipulate a feature class/dataset in a personal database by using cursor via ArcPy?

I wrote an ArcPy script which uses cursors and it works fine with shapefiles. However, it does not work if I execute the same thing in a personal geodatabase. Should I use different format for a ...
1
vote
2answers
147 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? ...
0
votes
1answer
344 views

AttributeError: DescribeData: Method fieldInfo does not exist

I have a script that looks at feature class inside a .gdb and prints some simple information about the attributes field. Note- these is actually only one feature class in the .gdb. I want use the ...
1
vote
1answer
33 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
1answer
345 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
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\...
26
votes
4answers
44k views

Shapely not installing correctly

I am trying to run Shapely on a new machine, and tried both installing it from source, using the installer on its webpage, and using pip install shapely. Every reference I try to make from the library ...
8
votes
6answers
5k views

Raster reclassify using python, gdal and numpy

I would like to reclassify a raster file from a raster with 10 classes to a raster with 8 classes using pyhton, gdal and/or numpy. The classes are represented as integers. I have tried following the ...
4
votes
5answers
6k views

Import error: no module named _gdal_array

I am using python 2.7 and have gdal installed. I want to read an entire .jpg image at once and so I used statement import gdal from gdalconst import * driver = gdal.GetDriverByName('JPEG') driver....
19
votes
2answers
64k views

How to read a shapefile in Python?

My question is an extension of Vertical lines in a polygon shapefile. Kindly refer to that question first. What you will see is a method of generating vertical lines with respect to the bounding box,...
2
votes
1answer
1k views

Using Python script to stack layers from multiple directories and produce multiple outputs in ERDAS?

I am using ERDAS Imagine 2013 and am trying to create a Python script that takes lists created in another script containing the path to each scene's raw data folder and base image ID's (for example ...
0
votes
1answer
760 views

Python problem using GDAL

I used the instructions at https://pythongisandstuff.wordpress.com/2011/07/07/installing-gdal-and-ogr-for-python-on-windows/ I downloaded the following files: GDAL-1.11.1.win-amd64-py2.7.msi gdal-...
1
vote
1answer
246 views

django-raster rendering raster url

i want to add raster functionality in django using postgis database using django-raster package and this docs. here my code : models.py from django.contrib.gis.db import models class RasterWithName(...
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?
0
votes
0answers
54 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
2answers
3k views

OSgeo4W64 Windows 7 & ImportError: No Module Named Site

I realize this question has been asked a lot, but I was not able to resolve my issue through the answers posted elsewhere... I am new to Python, gdal, OSgeo4W, etc. but have experience with ArcGIS. I'...
0
votes
1answer
585 views

Installing Python bindings for 64-bit Python on Windows

I installed GDAL and its Python bindings from GISInternals. While I believe that GDAL was installed correctly, the Python bindings have an issue. After opening a file with gdal.open I cannot read ...
8
votes
1answer
8k views

Rasterize a shapefile with Geopandas or fiona - python

I need to rasterize a really simple shapefile a bit like this http://tinyurl.com/odfbanu. Which is just a shapefile coutaining counties in the US.I have seen this previous answer : GDAL RasterizeLayer ...
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
93 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/{...
3
votes
2answers
2k views

Error 000212 Cannot create XY event source from arcpy.MakeXYEventLayer_management?

I am using ArcPy to create an output feature layer. I am using the command: arcpy.MakeXYEventLayer_management(wells, "longitude", "latitude", wells_layer, GEOGCS, ""), where wells is my input csv ...
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
4k 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
1answer
1k views

Unexpected output when using gdal_rasterize?

I used the following code for converting my layer into raster format but I get a tif file that is completely black or white... from osgeo import gdal, ogr # Define pixel_size and NoData value of ...
8
votes
2answers
1k views

Calling GRASS functions from external Python?

I have GRASS 6.4.3 svn installed on my machine running Windows 7. Also in my machine, I installed Python 2.7.3 for Windows. Now I need to call GRASS libraries from Python and not within the Python ...
3
votes
2answers
913 views

Loading non-spatial data via CSV using PyQGIS for standalone script?

I am trying to load a .shp file, and a non-spatial data table .csv file. Then join the table to the shapefile. Both files have a primary key. Here is my code: countyLayer = QgsVectorLayer(...
1
vote
1answer
68 views

Get Path of my toolboxes ESRI addins Python 2.7

I need my toolboxes path. These are in the installation folder (toolboxes) but when using the function: dir_tools = os.path.join(os.path.dirname(__file__),r'toolboxs\parametros.tbx') result: C:\...
1
vote
0answers
15 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:...
4
votes
1answer
162 views

PyQGIS spatial operators(contains,equals,etc.) w.r.t. layer geometries(polygon,point,line,etc.)

I am trying to implement QGIS spatial query functionality in my plugin. I want to eliminate spatial operators which are not suitable for certain geometries. For eg. when I select layer with point ...
2
votes
0answers
60 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
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
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 = ...
7
votes
4answers
3k views

Using Sqlite, Python 2.7 and Spatialite?

I am trying to spatially enable my sqlite database: import sqlite3 db = r'c:\temp\mydata.sqlite' conn = sqlite3.connect(db) conn.enable_load_extension(True) cur = conn.cursor() cur.execute(r"SELECT ...
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 ...
2
votes
2answers
9k views

Import shapefile is not working in pyshp?

I am just trying to use "pyshp" package to open shapefile in Python and use the Attribute data for further development. Firstly I have downloaded pyshp package for python 2.7 and installed it in my ...
0
votes
0answers
52 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
58 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
42 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 ...
1
vote
0answers
34 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 ...
18
votes
1answer
25k views

GDAL/Python: How do I get coordinate system name from SpatialReference?

In Python, using GDAL, I've extracted a raster's projection as a WKT string as follows: wkt = dataset.GetProjection() # wkt is 'PROJCS["GDA_1994_Transverse_Mercator",GEOGCS["GDA_1994",DATUM["GDA_1994"...
5
votes
2answers
2k views

Reading/writing utf-8 encoded data using Fiona?

So I have a 'cpg' file with my 'in_file' shapefile data (definitely set to 'utf-8'). I was using 'meta' to create the same schema/crs as 'in_file'...though it runs, my text fields are borked on ...
0
votes
2answers
153 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
659 views

Adding a Property (attribute) to a geometry in Shapely/Fiona

Once you have line and polygon geometries, intersection using Shapely is very straight forward. What I did after that is to integrate all the looped 'intersected' geometries into a MultiLineString. ...