Questions tagged [python-2.7]

Version 2.7 of the Python programming language

Filter by
Sorted by
Tagged with
27
votes
4answers
13k views

Making separate Python installation that can call ArcPy?

I see a lot of Q&As asking how you can create a separate Python installation (e.g. the Anaconda or Python XY distribution) that can use arcpy, while not 'breaking' the original ArcGIS python ...
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 ...
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,...
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"...
13
votes
2answers
11k views

How to polygonize raster to shapely polygons

I am seeking an open-source python solution to convert raster to polygon (no ArcPy). I did know the GDAL function to convert raster to polygon, and here is the manual: http://pcjericks.github.io/py-...
9
votes
1answer
3k views

How to style a layer from console?

I am new to the QGIS python console. I am trying to load a raster layer from the console, set the crs and a specific style from a qml file. layerPath = os.path.join(raster_dir,raster_name) fileInfo = ...
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 ...
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 ...
8
votes
3answers
3k views

RTree spatial index does not result in faster intersection computation

I have some code that I am using to determine which Shapely Polygon/MultiPolygons intersect with a number of Shapely LineStrings. Through the answers to this question the code has gone from this: ...
8
votes
3answers
4k views

Increasing speed of Python scripts using arcpy

Update 4/11/2014 It looks like the script was getting hung up on the Delete Features tool, so I switched to Truncate Table, as suggested in the answer below. I also removed the unused variables from ...
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 ...
8
votes
3answers
695 views

Find out point which falls between two parallel lines

I am facing one problem in ArcGIS. I work on a navigation database. In our database single lane streets are represented by a single Line, while a multi-lane street (street with divider in centre) is ...
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 (...
7
votes
4answers
14k views

GeoPandas: return lat and long of a centroid point

I would like to return the lat and lon or x and y from the point object in the following series as I plan to link them with an API I built that links OSM and NetworkX. The centroids will be added as ...
7
votes
3answers
7k views

How can I define the layer CRS for a memory layer in pyqgis?

How can I define the CRS for a memory layer from the QGIS project settings? vpoi = QgsVectorLayer("Point", "vectpoi", "memory") feature = QgsFeature() feature.setGeometry(QgsGeometry....
7
votes
1answer
2k views

Import functions in python Add-In logic script

I am running into an error. I have a set of functions which I want to import in the python Add-In script at the time of execution, but when I built Add-In with "import stats" line then tools are ...
7
votes
3answers
2k views

Can a folder connection in ArcMap Catalog window be added using Python?

I have created a set of general scripting tools for map automation, etc. In one of my tools a geodatabase is created in the workspace folder the script points to. Just out of curiosity, is there any ...
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 ...
7
votes
1answer
5k views

How to use QGIS field calculator in python?

I would like to use QGIS Field Calculator in Python to update the existing column based on certain conditions? How can I do this?
7
votes
2answers
2k views

How can I create a form so the user has to be authenticated to access a project?

I have a login form in QGIS and when it is loaded, python gives me an error for, apparently, not recognizing the findchild part. This is due to the fact that the form isn't loaded before the script is ...
7
votes
3answers
1k views

mosaic raster to file geodatabase yields missing raster sections

Since upgrading to ArcGIS 10.1 (SP 1) from 10.0, I've been encountering an issue when running the arcpy.MosaicToNewRaster_management() tool with output to a file geodatabase. I'm principally working ...
7
votes
1answer
1k views

What is Esri's support plan for Python 2.7 beyond 2020 for ArcGIS Desktop? [closed]

According to PEP-373, Python 2.7 will retire on January 1, 2020 (Countdown Clock). That date was pushed back 5 years for those who couldn't migrate to Python 3. According to this product life cycle ...
7
votes
2answers
3k views

How to define pycharm to understand PYQGIS and GDAL

I use pyqgis in standalone apps and I have defined paths in Windows and Python paths to take python API from outside QGIS. I have created some simple tools using pygis and GDAL in standalone script ...
6
votes
2answers
667 views

Making ArcPy interactive?

I'm developing an interface with arcgis and python. When I have only python, I can make my script interactive using: S = float(raw_input( 'Please enter the value: ')) I can open and run my script ...
6
votes
2answers
6k views

Loading Vector Layer using python console in qgis

I am using qgis2.6 version and new to pyQGIS. I tried to load a vector file using python console in qgis. I don't know where I am wrong. The layer was not loaded and does not show any error too. Help ...
6
votes
1answer
339 views

No “committedFeaturesAdded” signal after dataProvider().addFeatures() - QGiS 2.14.8

I'm working on plugin updating existing shapefile by adding new features to it. And I have a problem with signal that hasn't been emitted by QGIS, when I've added features to layer, using dataProvider(...
6
votes
1answer
183 views

ArcPy script runs longer processing time in scheduled task than in ModelBuilder?

I have a Python script that runs ArcPy and a model that is imported with a Toolbox. When directly running the model on ArcMap, it takes 4 plus minutes. It takes about the same time if running in the ...
6
votes
1answer
5k views

How can I Setup Python to recognize QGIS

I want to use QGIS and work with Python out of the console, but I'm having troubles letting the system recognize the paths of some DLLs. Since I couldn't find a good answer on the web, I wonder if I ...
6
votes
2answers
3k views

Efficient computation of nearest distance for each point to closest polygon

I'm looking for a more efficient way to compute the nearest distance between features from 2 layers, in this example for each point the nearest distance to the closest polygon. Is there a more ...
6
votes
0answers
584 views

Gdal and module import error when creating an .exe application with pyinstaller

I’ve been struggling since three days in a row to create a windows executable application from my python application. I have managed to get results but I’m not at all satisfied with the workarounds I ...
5
votes
1answer
2k views

How to add vertex to an existing polyline programatically?

I have a Polyline and would like to add new vertex to before start point or end point or at any part of the polyline using python in qgis. How can i do that?
5
votes
3answers
2k views

Getting attribute value from vector layer after mouse click in PyQGIS?

I am trying to write a piece of PyQGIS code that runs after a mouse click to collect the Map Coordinate position, and the value of a polygon vector layer within the project under the cursor position. ...
5
votes
2answers
5k views

Zooming to layer extent in PyQGIS? [closed]

Regarding my plugin pyqgis 2.2, i can load a vector layer succesfully. But when i try to zoom to the layer extent it does not work. How to do in order to zoom to the layer extent? I have just ...
5
votes
1answer
8k views

Rasterizing shapefiles with GDAL and Python?

I am trying to rasterize a shapefile, and write values from a specific column of the shapefile into the resulting GTiff. Here is what I've done so far, but that only creates a GTiff of zeros. from ...
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 ...
5
votes
2answers
681 views

Rotating geometry to specific angle using pyqgis?

I do not know how to rotate a geometry using pyqgis. Is there any sample/example code available to show me how?
5
votes
2answers
4k views

Setting up Python 2.7 to work in both QGIS and ArcGIS Desktop?

I have both ArcGIS 10.1 and QGIS 1.8 installed and both include Python 2.7 in slightly different setups and in different folders (c:\Python27\ArcGIS10.1\ and c:\Program Files (x86)\Quantum GIS Lisboa\...
5
votes
3answers
4k views

-9999 (no data value) becomes 0 when writing array to GDAL memory file

I am trying to reproject and resample (1000m ->> 30m) a raster image (shape 238X406) using gdal.ReprojectImage() function in Python. The input file has -9999 cells as no data value. The result is an ...
5
votes
3answers
5k views

Using PyScripter with ArcGIS for Desktop?

Can someone please let me know how I can set the PyScripter 2.5.3.0 x64 works with Python 2.7.3 which comes with ArcGIS what I did was: I installed the ArcGIS 10.2 I installed PyScripter 2.5.3.0 x64 ...
5
votes
1answer
4k views

How to efficiently determine which of thousands of polygons intersect with a linestring [duplicate]

I have a shapefile that contains several thousand Polygons/MultiPolygons and another shapefile that has a variable number of LineStrings. In the example below the blue Polygons are those that ...
5
votes
1answer
1k views

It is possible to get single polygon using gdal.Polygonize()?

I have to get polygon outline for all raster in our server. I tried one example raster and used gdal.Polygonize() function. With that I could produce thousands of small polygons but I only want a big ...
5
votes
1answer
2k views

ArcObjects SQL Server Connection not recognizing instance

I am trying to make a connection to a SQL Server database with SdeWorkspaceFactory. This is from my Windows 7 x64 Desktop to a Network database. If I use this: SDEWorkspace = NewObj(...
5
votes
1answer
1k views

how to open second window in my plugin for QGIS?

I create a Mainwindow for my plugin, but if I want to open a second window from this Mainwindow, with click on push button. How can I do? I tried the following function in my Main Class: dialog = ...
5
votes
2answers
449 views

Can't access GRASS GIS modules from within Python 2.7

Using the tutorials posted here, here and here, I am trying to setup a script that will make use of several GRASS GIS raster functions externally. For now I am just trying to get the tutorial script ...
5
votes
2answers
3k views

Finding the pixel coordinates using GDAL/numpy

Is there a way to get the XY cordinates of a pixel based on the array index using numpy/gdal? I have a new set of extents for a raster and, based on these newer extents, want to determine the ...
5
votes
1answer
1k views

Writing XML metadata with Python?

Some Python software I have written generates raster files via GDAL. I would like the software to create an XML metadata file for each raster so that I can include details about how the raster was ...
5
votes
0answers
192 views

PyQGIS composed Atlas generation

I have some layers : layer 1 layer 2 layer 3 and I have create styles for any labels layer using base rule styles and labels and I have create a template .qpt and I use atlas correct. In my ...
4
votes
1answer
1k views

Converting between coordinate systems for LAS file using LASPY

I am trying to convert a .las file from WGS84 to UTM17. I have some drone imagery that was used to generate a 3d point cloud/ .las file, but it is in latitude/ longitude instead of easting/ northing. ...
4
votes
2answers
883 views

How do I compare two features to test if they are identical?

What is the most efficient method for determining if two features (points, lines, or polygons) are geometrically identical? I'm not concerned about a square figure that contains eight vertices (four ...
4
votes
1answer
401 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 ...