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

learn more… | top users | synonyms

0
votes
0answers
22 views

ApplySymbologyFromLayer does not work in my python code

I have a layer file. I make a button in ArcGIS 10 with .NET. I want to change layer symbology with the layer file. For this purpose, I write python code and execute it from C#. If the following code ...
3
votes
1answer
58 views

How to define the number of decimals when adding a new field as double to an attribute table with python in Qgis 2.1?

How to change the expression in order to define the number of decimals? layer.dataProvider().addAttributes([QgsField("fieldname", QVariant.Double)]) As I read in QGIS API Documentation: ...
1
vote
2answers
83 views

Moving shapefile using Python shutil?

I'm attempting to iterate through several shape files within a folder and only move some of them to a new folder. I'm doing this based on contents of the DBF file where I'm using dbfread to determine ...
2
votes
1answer
40 views

geopandas error “minimums more than maximums”

I posted this question on stackoverflow here, but it seems that gis.stackexchange is the more appropriate platform. I am trying to merge two geodataframes in geopandas (want to see which polygon each ...
0
votes
1answer
31 views

Remove layers using python- path orientation

Expanding on my previous question Code error - remove layer using python, i try to remove layers from mxd's (in ArcMap 10.3, python 2.7.8), that don't appear in the data frame with this code: import ...
0
votes
0answers
15 views

Kartograph syntax for json files

I googled everywhere but i didn't find how to correctly write *.json files for kartograph.py. Is there any documentation or at least some useful examples or tutorials? I wonder where to find shp files ...
2
votes
0answers
47 views

arcpy.AddIndex_management error for in_memory variable

I am trying to optimize a script that uses addJoin_management. To do this efficiently, I am attempting to add an attribute index on the join table. I am getting a generic error when i do this though. ...
4
votes
1answer
83 views

How to use third-party package in a QGIS plugin?

I'm developing a QGIS plugin and I would like to use arrow or requests packages as I'm used to manipulate dates and REST APIs. QGIS does not come with these packages (at less arrow), so when I try to ...
4
votes
2answers
51 views

Create a new point from a reference point, degree and distance

I'm trying to calculate the coordinate of endPoint using the lat/lon of startPoint as a reference. I know the distance between the start and end points and I know the azimuth to the endPoint. I ...
1
vote
1answer
58 views

How to handle temp files created during Extract by Mask (Spatial Analyst)?

I have three scripts running simultaneously that processes raster data in several directories. The problem I am encountering is that ArcGIS is creating a temporary grid file called 'Extract_recl1' ...
1
vote
0answers
23 views

How to use itemChanged signal to update data?

I'm trying to understand the itemChanged signal to be able to update some information. An example of what I'm trying to achieve could be: def setCoordText(): label1.setText(str(label1.x()) + "," ...
3
votes
0answers
24 views

How to use pythons' GeoAlchemy2 to filter on dynamically generated Points?

I'm trying to do something like this SQL query in Geoalchemy2: SELECT district_polygons.district FROM markers, district_polygons WHERE ST_Contains(district_polygons.multi_poly, ...
0
votes
0answers
47 views

Cannot Edit Python Script from ArcMap/ArcCatalog

I am unable to edit scripts in ArcMap or ArcCatalog. I navigate to the script, right-click on it and select "Edit", then nothing happens. I am using notepad++ as my editor (set in geoprocessing ...
1
vote
0answers
28 views

CF convention and GDAL projection

I'm trying to create some NETCDF4 CF compliant files from some code that generates GDAL compatible files. I was wondering whether there is a simple translation from GDAL (or proj4) projection ...
1
vote
0answers
42 views

How can i set layer polygon in center in QGIS using python?

I am trying to set a fixed zoom level whenever I layer is shifting on different polygon. I have coordinates for all the polygons , I need each polygon to be on center with certain zoom level so that ...
1
vote
1answer
51 views

Duplicate a layer applying a filter in QGIS

Is there a way, using Python, to duplicate a layer in QGIS as many times as the single occurrences of a variable contained in a field and with a filter applied on the duplicated layer based on the ...
1
vote
0answers
32 views

How to change a point of an arrow on Print Composer?

To create an arrow on the Print Composer I've used this: qC = QgsComposition(iface.mapCanvas().mapRenderer()) arw = QgsComposerArrow(QPointF(0, 0),QPointF(10,10),qC) However, I can't find an ...
2
votes
0answers
43 views

Altering legend labels in Matplotlib

I have a choropleth map which displays crime percentage change. It is plotted from a geodataframe and the choropleth intervals are determined in the background by Python. Unfortunately, the first ...
4
votes
1answer
65 views

Rename field QgsField is not valid

In pyQGIS i tried this code (contains also debug prints): def joinLayers(inputlayer, layer, index_field, name = "JOINED", dataProvider = "ESRI Shapefile"): a = [] b = [] outpath = ...
1
vote
0answers
25 views

python 2 polygon intersection

I have slope values derived from a DEM which I reclassified into NoDATA and vaules which I need. Then I made a polygon from this raster. I need to do intersection or something like that with the ...
1
vote
0answers
33 views

Projecting GeoJSON polygon object in python to calculate area

I have a script, written in python, that does many calculations - but one set of calculations hinges on determining the area of a polygon that I read in, in GeoJSON format. I can convert this object ...
1
vote
0answers
32 views

Translate ArcPy to QGIS for focal sum statistics [closed]

Sometime ago, I asked a question (Arcpy to append results of pivot table) with the result being python 2.7 script that works in ArcGIS 10.3. It is fairly simple - it iterates over all the points in a ...
7
votes
3answers
428 views

Pythonic alternative to Feature to Point (no advanced license)

I have a set of polygons I have calculated the centroids of, but am having trouble finding a way to output these values to a point shapefile. I dabbled with arcpy.MakeXYEvents_management, but it only ...
0
votes
1answer
34 views

Open ArcGIS Geodatabase as python file object

I'm developing a script to POST a .GDB to a geoprocessing service. Part of my workflow involves opening it while building the POST request: files = {'file': (open(C:\\Temp.gdb, 'r'))} r = ...
1
vote
0answers
21 views

printing multiple .gws (geomedia work station)

I have a folder with many .gws files in it. I have to open each one individually and print to pdf. This consumes a lot of time and is very tedious. I know not a lot of people work with geomedia but I ...
0
votes
1answer
54 views

Can I call 32-bit python from an ArcGIS Server 10.3.1 GP Service?

I've developed a geoprocessing service that accepts a personal geodatabase as an attachment. After this MDB is copied to the server, I'd like to use ArcPy to open it, edit some feature classes, then ...
5
votes
4answers
101 views

Transform raster donuts to circles

Let's assume I have a raster image consisting of 0's and several donut-shaped rings of 1's. This raster could for example be the result of classifying a satellite image with ponds and lakes in it into ...
3
votes
0answers
36 views

How to show only selected features from a a layer in the QgsComposerLegend?

I have developed a custom qgis plugin. I have a button to export the map canvas in the form of image along with the legend. I came up with the following code for the legend: legend = ...
-2
votes
1answer
39 views

path in imagepath in image

image contains: A green marker denoting the Start. A red marker denoting the End. How to find the shortest path from Start to End. start from the Start and reach the End by moving either ...
0
votes
2answers
72 views

extract scientific layers from MODIS HDF Dataeset using Python GDAL

I have been trying to extract scientific data layers from MODIS HDF files but without success. Before I have been doing this type of task using Arcpy, but I want the script that I am currently working ...
5
votes
2answers
82 views

How to create memory layer and populate fields?

Seems like a basic operation using PyQGIS but can't see what I am missing. I want to create a memory layer with the exact same features and attributes from a shapefile. I have looked several posts ...
0
votes
1answer
49 views

Return FeatureLayer in geoprocessing REST service

I have created a Python Script Tool that returns a FeatureLayer using the following two lines of code: arcpy.MakeFeatureLayer_management(scratch_fc, "GeocodedZIPsLayer") arcpy.SetParameterAsText(1, ...
1
vote
2answers
79 views

How to add attribute table to new shapefile using OGR?

i have made a new shapefile from the original shapefile , and now i want to copy the attribute table from the original shapefile to the new select shapefile , but i don't know how to do that? import ...
0
votes
2answers
110 views

Point in Polygon - geojson - using Shapely / Python returning incorrect results

I'm trying to test if a point is inside a polygon using this example: http://stackoverflow.com/questions/20776205/point-in-polygon-with-geojson-in-python However, my output says that none of the ...
0
votes
1answer
40 views

Python file permission [closed]

When I create a .sddraft it by default gets Owner's read and write permissions. I think I need execute permission for creating .sd file. I am using Python and my file resides in LINUX server.
0
votes
0answers
39 views

arcgisscripting.ExecuteError: ERROR 001270: Consolidating the data failed

I am working on PuTTY and trying to create service definition file in server. My Python script is creating .sddraft but I am receiving 'Consolidating the data failed' error when I run stage service ...
4
votes
2answers
63 views

How can I add an action from a QGIS toolbar to my custom toolbar programatically?

I have a toolbar and I want it to have an already existing action, but checking the documentation I only found methods to add newly created actions, not already existing ones. Is there a way to do ...
2
votes
2answers
37 views

How to select form the attribute table in with ogr

i want to select the (Sumava) from the attribute table and then make a shape file, my problem is i don't know which function should i use to select this area.if any one can help me? import ogr import ...
0
votes
0answers
31 views

pgsql2shp result as shapefile

In addition to pgsql2shp command join error, the next command line works fine in order to join a table to a shapefile but the result is a dbf table and not a shapefile as I want. I see that exists a ...
4
votes
1answer
125 views

How to extract specific information from GRIB files?

How to extract fetched GRIB data with Python and gribapi package (link goes to official ECMWF Wiki)? I tried to follow few examples from their "documentation" and do it myself, but I just cannot ...
2
votes
1answer
68 views

How to get perpendicular line script to work?

I'm trying to get this script to work by @gene but I'm not sure how to load the results into QGIS. I tried to make a memory layer but not sure how to add the geometries of the point, line and the ...
4
votes
2answers
122 views

Reconstructing MODIS time-series applying Savitzky-Golay Filter with Python/Numpy

I want to apply the 'Savitzky-Golay' (savgol) filter to my time series, MODIS dataset, to remove noise (i.e., cloud pixels, etc.) in my data. MODIS have quality flags that indicates the reliability of ...
0
votes
0answers
42 views

Avoid time out error Nominatim Geopy Open Street Maps

How to avoid the "GeocoderTimedOut('Service timed out')" error in geopy using the osm nominatim geocoder? I am not interested in using an exception and skip some entries. I already use a time delay of ...
4
votes
3answers
103 views

Change QGIS background colour using python

I would like to change the background colour of a QGIS project using python. I can change the colour using the GUI via the Project Properties dialog: However, I cannot find the equivalent setting ...
5
votes
1answer
132 views

How to replace a shapefile name in a directory using Python QGIS?

How to replace name or delete .shp file from directory using Python QGIS ? import os import processing input = "//input.shp" output = "//output_100.shp" interval = 100 ...
1
vote
0answers
27 views

Using SET methods when feature classes setup in GDB using python, comtypes, ArcObjects?

from snippetarcgis102 import CreateMXD,CType,NewObj import snippetarcgis102 import os snippetarcgis102.GetStandaloneModules() snippetarcgis102.InitStandalone() import comtypes.gen.esriCarto as ...
7
votes
2answers
83 views

Why do I get different results from PyQGIS feature.geometry().type()?

On the python console in QGIS what is the difference between the following two code snippets (activeLayer is a polygon layer): # 1) iface.activeLayer().selectedFeatures()[0].geometry().type() ...
2
votes
2answers
88 views

Generate TIN from elevation data in Python (no Arc)

I would like to generate a 3d terrain model of an area, and I am stuck on creating the TIN (which I will convert to an STL). I know there are plenty of ways to use ArcGIS, QGIS, 3DEM, and various ...
3
votes
1answer
23 views

How to replace a string with a variable inside a pgsql2shp command in Python

How to replace a string with a variable inside a pgsql2shp command in Python command = "pgsql2shp -f /test.shp -h localhost -u postgres -P postgres gis_exercise \"SELECT d.latitude, d.longitude, ...
1
vote
1answer
40 views

How to select attributes by unicode field value?

I have an attribute table in QGIS 2.10 with a string field (myfield) and when I want to make a selection based on the unique values of this field I get no selection at all. >idxmyfield = ...