Python is an open source interpreted programming language used in many GIS programs.

learn more… | top users | synonyms

0
votes
1answer
961 views

ArcPy SelectLayerByAttribute Error and how to control GP output layer name

I have a rather long script that first references an SDE feature class (non-versioned) to perform an attribute selection based on a SQL selection. I've been unable to figure out why the script will ...
2
votes
1answer
24 views

Exceptions for invalid files/ filenames that already exist in database

The script below is functional, but it runs into issues if it comes across duplicate files (even when overwriteOutput=True) and corrupt shapefiles when running feature to feature. Are there ...
17
votes
14answers
46k views

Full list of ISO ALPHA-2 and ISO ALPHA-3 country codes

I'm searching for a full list of countries with their country codes. Like on this page (need full and valid): http://www.nationsonline.org/oneworld/country_code_list.htm Thanks.
0
votes
1answer
12 views

Error operating on file using grass

from grass.pygrass.modules.shortcuts import raster as r gscript.run_command('g.region', ...
3
votes
1answer
153 views

Identifying flightline ID within an LAS file?

I am working with multi pulse LiDAR data that collects points along a number of lines within the flight path. From what it appears there are four scan lines within the data, at different intervals but ...
6
votes
2answers
672 views

Getting the projection of a LAS file using liblas?

I am using the python api of liblas to read/write las files. I would like to get the spatial reference information of the las file using liblas, but have been unable to figure it out. Can anyone ...
0
votes
1answer
33 views

QGIS Processing Toolbox not valid

I have a 64 bit windows 10 computer with ArcGis 10.2.2 Installed. I just downloaded QGIS the newest version 2.14 64 bit. it downloads but the processing toolbox throws this error Couldn't load ...
1
vote
1answer
23 views

gdal_polygonize returns with a strange error

i'm trying to execute gdal_polygoinize.py command. I have a main python method that takes in input a raster file and a output shapefile, and then calls a method named polygonize.py that builds and try ...
2
votes
1answer
36 views

How do I change the pixel values of raster data from QGIS python plugin

I have been trying my hand at a QGIS plugin. The plug in reads raster layer data into an array, pipes the data to a C++ program, does processing over there, and pipes my results back. After a couple ...
2
votes
1answer
37 views

Python module pyGTiff aligning data

I have been working with pyGTiff for a while and it works great. However my gis data does not have the same projection and extent. I saw that in the repository a a jupyter notebook with a test ...
1
vote
1answer
38 views

Parse and load GPX into database?

Having a PostgreSQL database, with the following tables: CREATE EXTENSION postgis; DROP TABLE IF EXISTS trips CASCADE; DROP TABLE IF EXISTS locations CASCADE; CREATE TABLE IF NOT EXISTS trips ( ...
1
vote
2answers
35 views

Extraction of raster with shapefile python

I have a raster tiff file containing vegetation index & also a shapefile of fields. I want to extract the field wise values from that raster file using GDAL. How can I do this? I can read the ...
20
votes
2answers
8k views

How do I get the pixel value of a GDAL raster under an OGR point without NumPy?

I am working on a computational model of the abundance of wild pollinators across a landscape. The model itself is complete, and I am now struggling with a post-processing step. I have my GDAL ...
0
votes
0answers
32 views

Transitioning MapServer from 32bit to 64bit: CGI Error

I am moving a mapserver system from 32bit to 64bit Windows (too many frustrations with multiple python installations). There is no straightforward MS4W installation for 64 bit. I am using Apache2.4 ...
1
vote
1answer
247 views

Is it possible to embed python in code for HTML pop-ups in ArcGIS

When clicking a point feature I want the html pop-up to not only contain the data of the feature but also an image of the area around the feature (eg. 2 km^2). The image would have the base map 'World ...
1
vote
0answers
27 views

Qgis python: no interaction with Map Canvas

I've created a simple python script to load and show two layers and zoom to the first one. It looks like the script doesn't run the last 4 lines after I uncomment'print lyr1'. Anyway the map canvas is ...
0
votes
0answers
34 views

Mapinfo wor file not working when file paths are updated using python

We did a data move and so I scripted the updating of the wor, so the old file path is changed to the new file path. It looks like it works perfectly but when I open the wor file it doesn't. When I ...
5
votes
2answers
743 views

How to access the road graph plugin in python?

I am developing a few scripts in Python for QGIS 1.8 to automate some geo-tasks and one of them would be to calculate the shortest distance from a hospital to each building in a town. I would like to ...
0
votes
0answers
17 views

Replacing path names in FME Workspace with python

I need a Python code which replaces the place holders ('%p%') in a template FME Workspace which is imported via fme_in = open(self.filename1, 'r') and writing the path name which come from a input ...
1
vote
2answers
52 views

Clustering geographical data based on point location and associated point values

Given data points with longitude, latitude, and a third property value of this point. How can I cluster points into groups (geographical sub-regions) based on the property value? I searched by google ...
0
votes
0answers
23 views

connecting Postgis, Python, Openlayers

I'm in the process of learning Geo-mapping and I'm curious to create a web-application Python-Django, Openlayers 3 and PostGIS. I need to know whether Django can be combined with PostGis and ...
1
vote
1answer
45 views

Creating a polyline with a specified slope

I would like to create a road (polyline) starting from a point, with a specified slope, until reaching the top of a hill (or going out of the DTM Raster). The dowstream slope of the DTM must always ...
3
votes
1answer
742 views

Extract data from netcdf using a shapefile polygon in python

I need to subset data from a NetCDF using a specific shapefile. The data are sea surface temperature and ocean color at 1/4 degree resolution. I have 4 polygons describing the US. Northeast ...
2
votes
1answer
450 views

Python script for dark object subtraction on Landsat 8 Imagery

Does anyone know of any python scripts that will allow me to conduct such a process? I am limited to open source software and have minor experience in Python.
1
vote
0answers
22 views

Per-pixel Descriptive Statistics through multiple Raster layers

I'm looking for computing different descriptive statistics through a set of raster layers. I need to make it with a python script capable of running into a standalone tool within the QGIS. To do so ...
5
votes
2answers
657 views

Randomly select a record to update using arcpy.da.UpdateCursor

This question is related to Correct usage of a counter using arcpy.da.UpdateCursor. What I would like to do is use a cursor with a where clause to select a number of records. For each row, the values ...
0
votes
1answer
50 views

RasterStats import zonal_stats error [on hold]

I just installed rasterstats 0.10.3 Python library on my Windows machine and everything went fine with pip installation (had to install fiona, rasterio wheels separately prior to installing ...
2
votes
1answer
124 views

pyQGIS changing Paletted Raster Layers to Grayscale

I've written a plugin which imports a number of colour geoTifs (map tiles) and works correctly but it would be great to display these as Grayscale after loading in. The geoTifs load as paletted ...
0
votes
0answers
16 views

Opendap automated download with Python in ArcMap [on hold]

I want to use python to automate the download of satellite images from OpenDap. I did find a similar post here, but I have tried using this script and it does not work How I can extract a subset of ...
0
votes
1answer
51 views

Why Does Fiona Crash Python When Creating an Output File?

I've basically followed the Fiona online manual verbatim to write an output file but my code crashes when I call Fiona.open() to create said output file. Traceback reports that the reason for the ...
0
votes
0answers
5 views

Tuning Geoserver datastore with gsconfig

I'm trying to create a datastore in Geoserver with gsconfig and it works, up to a point where i want to enable for instance "Expose primary keys" or "Support on the fly geometry simplification" tags ...
2
votes
1answer
115 views

Implement r.cross / ArcGIS Combine with GDAL

I am using GDAL to process a lot of rasters. I then need to combine all the arrays to create a single output raster that represents all the unique combinations of values. I.E the same thing as ...
2
votes
1answer
213 views

gdal_calc works but I get a Python error at the end of each process

I have a problem while using gdal_calc by a .bat file. Here is the code : call "C:\OSGeo4w64\bin\o4w_env.bat" gdal_calc ...
2
votes
1answer
34 views

QGIS Python variable not updating after new features are inserted

I have the following script that sets the a feature id automatically after a new feature is digitized. I added the function inside the project's Macro section inside openProject() function: The ...
3
votes
3answers
1k views

How to filter out multipart polygons and then buffer?

I've written a small script trying to accomplish the task described in the question title. It basically looks like: in_fc = '...' # Some shapefile goes here # Get the fields (column names) of the ...
1
vote
1answer
128 views

Using twitter coordinates in OSGeo library

I have twitter data with coordinates such as: [-7.2377761, 112.73091137] I'm working with a python geo library called osgeo. The sample code indicates creating a point like this. point = ...
3
votes
1answer
28 views

QGIS python getting number of new features to be stored in layers

I mean, how could I get the number of features that have been created in a given layer and that are pending to be saved in the layer when "Toggle editing" or "Saving layer edits"?
1
vote
1answer
177 views

Couldn't load plugin PRISM due an error when calling its classFactory() method in QGIS1.8 inWin8

When I load a plugin in QGIS ,met some problems : I had tried copy other Python27's files to QGIS's Python 27 file but it still does't work. Couldn't load plugin PRISM due an error when calling ...
1
vote
1answer
33 views

How can I obtain selected value from QGIS using python algorithm?

I'm writing an algorithm in python for QGIS and i have a function which uses a value from a selection. The problem is that when i select a value the script give me the error that the local variable ...
1
vote
1answer
24 views

QgsMapCanvas object is not callable (Ubuntu with, Eclipse, Python & QGIS 2.0)

I'm basically borrowing the code for picking up a coordinate from a mouse click from this answer : How to programatically check for a mouse click in QGIS However in a stand alone application I do ...
3
votes
1answer
43 views

Replace non-ASCII characters in QGIS Field Calculator

I want to replace all non-standard characters from fields in a dbf table in QGIS. From http://stackoverflow.com/questions/20078816/replace-non-ascii-characters-with-a-single-space I see we can use ...
0
votes
0answers
24 views

Python condition “if” problem [on hold]

I have a txt file (each column divide by TAB). In some field there are "\N" but it's like a word not a wrap. I already split and I would like write: if (a[0] == '\N' and a[1] == '\N') ... etc.. ...
0
votes
2answers
511 views

Spatial ETL Tools won't run “AttributeError: 'module' object has no attribute, etc.”

I have a python script that runs 5 Spatial ETL tools that I wish to run as a scheduled task. Each of the tools will run successfully from ArcCatalog and also from the ArcCatalog Command line. If I ...
0
votes
0answers
20 views

Remove date from beginning of filename, add to the end [on hold]

I have a group of files I'm trying to database (with improper naming conventions starting with dates) i.e. 20160524_Whatever_Whatever I'd like to remove the date and _ and append it to the end of the ...
0
votes
0answers
50 views

SAGA GIS API ERROR (import saga_api)

I want to use saga api on my Idle with Python but I have problems. First I have Windows 10 64 bit, I install SAGA GIS via OSGeo4W64 64 bit, and I have Python 2.7.11 64 bit. I follow steps for the ...
0
votes
0answers
22 views

When I open the software this message showed “Import Error No module named osr” . I am using QGIS 2.6.0 version

This is the image of the error that occurred. I was able to use the software, but I'm bothered by the error.
3
votes
2answers
146 views

Can this Be Recoded to Be More Efficient with Respect to Processing Time?

I'm very new to GIS but have been asked to parse through any given ESRI GDB file-folder without using any ESRI product. I've been trying to focus on using Fiona and Shapely as these seem to be ...
6
votes
2answers
59 views

How to use current layer name in FME PythonCaller?

In a PythonCaller (FME 2014 SP4 in Data Interop in ArcGIS 10.3), I'd like to do some conditional processing based on the layer that I'm currently processing. I'm feeding in a text file of layers ...
1
vote
1answer
36 views

How is it possible to programmatically export current view as georeferenced image with QGis?

I found the this to export the current view as image. The following code works and was accepted as answer. c = iface.activeComposers()[0].composition() image = c.printPageAsRaster(0) ...
1
vote
0answers
14 views

pyd error install qgis 2.14

I removed qgis 2.10 so i could install qgis 2.14. But when i try to install 2.14 i get errors on python .pyd packages. Every time it is a different pyd causing the error. I had this problem with ...