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

learn more… | top users | synonyms

3
votes
2answers
55 views

merge dbf files - without using arcpy?

I have ~7,000 2 line dbf files (zonal stats output) that I would like merged into one table, all the same format. I have used the arcpy merge tool, as seen below. #merge tables together ...
1
vote
1answer
45 views

QGIS Processing Script will not Validate

I am writing a script for QGIS that will identify the perimeter of only external facing walls. The script is probably a little long to post directly into this post, but it is accessible here. The ...
1
vote
2answers
31 views

Error Installing GDAL python package on a MAC

I'm trying to install the [GDAL python package][1] on a Mac (OSX Yosemite) with python 2.7.9 and GDAL 1.11.3. When I try $ sudo easy_install GDAL I get a number of errors ending with: error: Setup ...
3
votes
1answer
71 views

How can I install pyproj into arcpy?

I am trying to install pyproj. I downloaded the zip folder on this page pyproj. Then I copied it to C:\Python27\ArcGIS10.3\Lib. However, when I try to import the module, I get the message ...
1
vote
2answers
84 views

Calculate the distance between two coordinates (WGS84) in ETRS89

I have an Excel-file with coordinates (WGS84). From these coordinates I create a line (shp) and transform it (ETRS89). After the transformation I calculate the distance from point to point. I do this ...
4
votes
0answers
33 views

How to unproject a UTM ESRI Shapefile over WGS84 extent boundaries

Background: I am working on a collaborative project in Python that uses GDAL/OGR to work with rasters and vectors. There is one function that attempts to project one ESRI Shapefile's coordinate ...
1
vote
1answer
47 views

ArcGIS REST API: using /addItem with secure service

Using the code below I am adding 100's of Map Services to a portal instance. The script successfully runs and adds them however the services are secure so I would like portal to store the username ...
1
vote
2answers
115 views

GDAL Translate error

I am trying to translate a .tif raster to an xyz one in Python The code is this: import sys from osgeo import gdal gdal.AllRegister() driver = gdal.GetDriverByName('Local Disk') dataset = ...
2
votes
1answer
43 views

IPython plugin not loading in QGIS 2.12

I am trying to run the IPython console plugin in QGIS 2.12 After installing the plugin there is this error: You need to install IPython 3.1.0 (and then restart QGIS) before running this ...
1
vote
1answer
31 views

rendering a single band raster - new maxvalue

I have a downloaded raster file, singlebandgray, and want to redefine it's maximum value to a higher integer value. Via the QGIS desktop it works smoothly by hand via the Properties. Via Python I was ...
2
votes
1answer
38 views

Actions undertaken in QGIS somewhere stored as Python code in a history file?

For practioners that are not willing to study all the methods for each class, it would be helpful if every action that was made within the QGIS interface can be looked up afterwards in a history file ...
3
votes
0answers
56 views

Python script to automate saving satellite images for different combinations of lat longs

PS. : This is my first try at a GIS application. Please forgive if my question is pedantic. I would like to get a series of satellite images all at the same scale centered around different points on ...
2
votes
1answer
39 views

Getting script file name as object in Python? [closed]

I'm quite new to Python and programming in general. I have created a few scripts using Python and as part of my framework/best practices for my scripts, I'd like to display when a script begins and ...
4
votes
0answers
31 views

Custom forms feature in QGIS: QMessageBox.warning closes QDialog as well

I am attempting to work with custom forms in QGIS. I have included a validate function in my code that will pop a QMessageBox() if the validation fails. My problem is that when I close the QMessageBox ...
2
votes
1answer
48 views

Fastest way to process OSM

I've been working with imposm and Python, it's fairly easy to parallelise. I've hit a performance problem when trying to associate the coordinates to the ways. Creating a dictionary from ...
3
votes
0answers
29 views

How to fill composer map with canvas data and export composition as png using Python script in QGIS

I'd like to create a Python script in QGIS that will take some data (shp + tif, in my example), use tamplate Map Composer (from a file) and export created composition to a png image. With almost no ...
3
votes
2answers
79 views

How to know if your script is executed in a QGis python console or a standard python console?

Is there any way to detect if a script is computed on QGIS python console or not? Any attribute or test to assess it?
5
votes
2answers
105 views

Field Editor with Python: select by attribute & open table (QGIS)

I want to search on number values (>, = etc.) within a column and open table for the selected ones. It's an easy task within field calculator, but I want to see how it's build up with the python ...
0
votes
1answer
46 views

GeoJSON properties not displaying in popup-leaflet GeoDjango

I want to show the markers in different colours based on column(rastervalues) values in leaflet. My geojson data is {'geojson': "[{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'ge ...
1
vote
0answers
29 views

Python's logging module not working with ArcPy [duplicate]

I have a Python script imported to an Arc toolbox. It uses Python's logging module for message recording. import logging import time import os, sys import arcpy ...
1
vote
0answers
24 views

Geocoding and SRID - can't get desired SRID

I want to geocode a set of addresses with GoogleMaps, store the results in a different SRID in a PostGIS table and then project it in QGIS over a layer with the identical SRID. So far, it has been a ...
1
vote
0answers
14 views

Subset of spatial data causes slow SQL Spatial STIntersects

I've been having an issue were a specific subset of data causes an SQL spatial intersect to run extremely slowly. I am running sets of 1000 points against a subset of polygon layer to be intersected. ...
0
votes
0answers
5 views

Converting branched multiline into series of single lines in shapely

If I have a multiline string representing a branched network with a common starting point (red network in pic below): Does anyone know how to convert this to a set of individual single linestrings ...
1
vote
0answers
24 views

Interpolating every X distance along line in shapely

If I have a shapely multiline object that contains many lines whose total length each is 50km (when traced from the origin), and I want to interpolate along the multiline every X meters (let's say ...
1
vote
1answer
55 views

How to set conditional imports for a PyQGis script running inner or outer of QGIS?

Related to Cannot run standalone QGIS script I try to detect if my script is run from a QGIS instance (through the plugin) or from a standard python console. This detection will enable conditional ...
3
votes
1answer
82 views

Convert KML to GeoJSON with ogr2ogr and remove KML special attributes

I'm trying to convert KML to GeoJSON (or some other formats) using ogr2ogr (look at this question). It's all working fine, except of one problem: I'm always receiving these metadata attributes with ...
2
votes
1answer
39 views

Working Windows Standalone .EXE From QGIS Python Script Using PyInstaller?

Has anyone been able to create a working standalone Windows .EXE file from a QGIS Python Script Using PyInstaller?
2
votes
3answers
87 views

If else if in ArcMap Field Calculator (Python)

Help! I think I am missing something that must be so obvious but I cannot figure out what I am doing wrong. Here's some background: I have one short integer field (MajAspNum) that has values ...
7
votes
0answers
139 views

gdalwarp producing empty rasters when called from python script, but not via command line

I'm trying to aggregate some raster data (all .tif) up to a coarser resolution (from .05 degree to .25 degree) using gdalwarp in python, but the command is not working. Instead of getting an output ...
-2
votes
0answers
57 views

Running geometry check on all feature classes in personal/file geodatabase?

Anybody can help me out and build a small Python script to do the following: browsing though all feature classes (also include those in the dataset) in an personal or file geodatabase Run the ...
5
votes
1answer
87 views

Sequentially distilling several raster data sets into final map based on first time pixel’s value was greater than zero?

I have 120 daily data sets that contain a value only when a threshold temperature is exceeded. If the threshold has been reached that pixel was assigned a value indicating the day it occurred (the ...
4
votes
1answer
74 views

Python and ArcObjects- Stand Alone open MXD

I wrote a Python function using comtypes to access ArcObjects to programmatically change the size of layer symbols in an MXD. The function works great in the Python window of ArcMap. However, I need ...
2
votes
1answer
37 views

Raster interpolation with gdalwarp, and replicating with python API

My problem is similar to this: Replicating result of gdalwarp using gdal Python bindings. I want to resample a raster using bilinear interpolation, which I've done successfully with gdalwarp by adding ...
3
votes
1answer
88 views

Using Update Cursor, populate field

I am trying to write a script where you preemptively select features and then go to the tool which calls for the feature layer and it populates fields based on certain criteria which I will design of ...
3
votes
0answers
36 views

Resampling netcdf file

I have several years of precipitation data from CHIRPS that has a resolution of 0.05 degree. I'm currently working on a recharge script that has static data resolution of 0.01 degree. I'm trying to ...
3
votes
2answers
72 views

Changing pixel size in 'asc' file using Qgis?

I have soil data and BioClim data from Australia soil data: rows 2200 columns 1400 pixel size 0.0025, -0.0025 255 BioClim data: rows 660 columsn 420 pixel size 0.00833333, -0.00833333 I am ...
2
votes
3answers
60 views

ASCII file with latitude, longitude and data to GeoTiff using Python

I have a .asc file with three columns of data: longitude, latitude and a data value. Each latitude and longitude point represents the location of a centriod of a 1/8 degree unprojected grid. I want ...
2
votes
1answer
74 views

Capturing Output Messages from GRASS when Running Python Scripts

Thanks to the excellent documentation here: https://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly#Python:_GRASS_GIS_7 I've figured out how to access GRASS modules in ...
1
vote
1answer
35 views

fiona ValueError: invalid literal for int() with base 10: 'str'

Why below code does not work- import fiona from fiona.crs import from_epsg my_schema = {'geometry': 'Point', 'properties': {'mean_in': 'str', 'total_h1': 'str', 'total_h2': 'str', 'LOS': 'str', ...
1
vote
0answers
33 views

Geopandas and Zonal Statistic error

I'm trying to use Geopandas and zonal statistic from rasterstats together. I run this code import geopandas as gpd from rasterstats import zonal_stats geodf = gpd.read_file("SHP/shape.shp") ...
1
vote
0answers
24 views

How to access a feature by specific field value using python ogr in an efficient way?

I have one point layer and one polygon layer with a common identifier attribute field called "N", same objects amounts but Feature IDs (FID) are different. I have to iterate on the first one and what ...
1
vote
0answers
38 views

Write stacks of GeoTIFF image to NetCDF by chunk size

I converted GeoTIFF image stacks to NetCDF file with writing data by Index order (layer by layer) (this was a main solution). The problem is, it writes slowly (for 25 images - 1Gb takes 90 seconds). ...
1
vote
1answer
29 views

GRID-file: get max extent for all z-values above given value

I have a GRID-file with a quite large extent. For an automatic workflow I need the maximum extent/bounding-box for all z-values that are over a certain range. For example: Get the maximum extent for ...
1
vote
0answers
24 views

python handling case in address (lowercase,uppercase) [closed]

I'm working on a python QGIS plugin that takes address info from specific parcels and lists it. The data is in various cases and I'm having a hard time figuring out how to handle it. My data looks ...
0
votes
0answers
20 views

Using shapely and geopandas in pyspark

I'm new to geospatial analysis and trying to start the analysis using python. Since the data is too huge we are trying to make use of hadoop and spark to get the analysis done. I would like to use ...
3
votes
1answer
72 views

PyQGIS couldn't import processing with standalone script

I have read post on that problem (How can I access `processing` with Python?). The problem is even with a sys.path.append it couldn't import processing. It's very frustrated. Here the code I used: ...
0
votes
0answers
14 views

Specifying column to use in gdal_translate

I am using gdal_translate to convert a tiff file to ascii. The tiff file is a raster with several columns in the attribute table. How do I specify to gdal_translate, which column to use for creating ...
0
votes
0answers
30 views

How to “INSERT” geotiff raster into postgresql/postgis table using psycopg2

Can someone walk me through how to insert a raster into a prebuilt postgresql table? The table has the postgis extension and I've been able to manually insert a geotiff using raster2pgsql, but I would ...
1
vote
0answers
20 views

Use QgsRasterCalculator inside function

I'm relatively new to PyQGIS and I'm building a plugin to perform some calculations between raster layers. I was seeking to use the QgsRasterCalculator for some operations, however, the function that ...
0
votes
0answers
15 views

Processing toolbox on Google Cloud compute engine

I used to utilize the QGIS python console to do GIS batch operations on my local machine. Computation times are rapidly increasing and I'm switching to a virtual machine solution in the cloud. How ...