Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [python]

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

1
vote
1answer
5k views

Installed pywin 32 — still getting error — “No module named win32com.client.”

I'm trying to install pywin32 (32 bit 2.7) so that I can run python from ArcGIS 10.2.1 (32 bit), and have access to the pywin modules. But I am getting the error "No module named win32com.client." I ...
1
vote
1answer
53 views

List of lat-long, need values in a raster

Apologies in advance as I am not a GIS specialist by any means. I have a set of 1 million points and I'm trying to find their values in a geotiff raster. I've tried various versions of this answer ...
3
votes
1answer
841 views

Using pysal to map location of coordinates?

I am trying to map which county a set of coordinates I have are in. I want the code to go through each coordinate, check which county it is in, and then print the corresponding county. However, ...
0
votes
0answers
15 views

Python matplotlib not available error with QGIS 3.6 Noosa despite upgrading Python on Mac

While generating contours in QGIS 3.6 Noosa on Mac I get an error saying "python matplotlib not available". I've downloaded the latest Python version but the problem persists.
-2
votes
0answers
16 views

How to generate envelope of a raster in Python

I will answer my own question above: import gdal from gdalconst import GA_ReadOnly from shapely.geometry import MultiPoint data = gdal.Open('/folder/data.tif', GA_ReadOnly) geoTransform = data....
0
votes
1answer
57 views

ERROR 1: NUMPY driver was compiled against GDAL 2.1, but the current library version is 2.2

When running my Python program, the following error came out: ERROR 1: NUMPY driver was compiled against GDAL 2.1, but the current library version is 2.2 What can I do to fix this?
1
vote
0answers
25 views

Python rasterio for saving GeoTIFF files and read in ArcGIS or QGIS

After following the steps in the tutorial of the Planet website (https://developers.planet.com/tutorials/convert-planetscope-imagery-from-radiance-to-reflectance/), I want to save each individual band ...
37
votes
4answers
23k views

Simple thematic mapping of shapefile using Python?

I wish to visualize geographical data in Python, without using ArcGIS/ArcPy, and make a map. On the internet I found how to make a thematic map using Python: Here is some code that I tried: ...
0
votes
0answers
322 views

Generating Custom Map image using Python with small installation footprint? [duplicate]

As a part of reporting requirements there is a need to generate region maps. These highlight various regions (countries or states/provinces) with different colors (or shades of a color) depending on ...
8
votes
1answer
1k views

Choosing Python 3 libraries for GIS analysis? [on hold]

I am trying to do some spatial data analysis in Python 3 now, and I was wondering what the best libraries are for GIS in Python 3. The Fiona library was developed with Python 3.3 but the Python 3+ ...
0
votes
0answers
22 views

Python rasterio save GeoTIFF files

After following the steps in the tutorial of the Planet website (https://developers.planet.com/tutorials/convert-planetscope-imagery-from-radiance-to-reflectance/), I want to save each individual band ...
1
vote
1answer
121 views

Shapely floating problems with split()

Based on the answer of sgillies I want to use Shapely's interpolate() to find the points at which to split. But I experience that split() is sensitive to the points being precisely on the geometry you ...
14
votes
2answers
10k views

How to draw polygons from the python console?

I've been visiting and revisiting the page on geometry handling in the PyQGIS Cookbook: http://documentation.qgis.org/2.0/en/docs/pyqgis_developer_cookbook/geometry.html but can't seem to figure out ...
2
votes
0answers
38 views

OpenCV Remap image from rectified image coordinates

I have orthorectified a drone image using ground control points. This results in a (4096 x 2160) array of recified X coordinates and a (4096 x 2160) array of Y coordinates. I want to remap the ...
1
vote
1answer
52 views

Drawing graticule with GDAL/OGR

I'm trying to generate a graticule with user-defined range of latitude, longitude, and interval; however, my code only displays one line of latitude and one line of longitude when loading it in QGIS. ...
9
votes
3answers
14k views

Converting shapefile to SVG keeping internal data?

I am very new to GIS. I found a tutorial on how to make a choropleth using Python tools. I want to follow it but use my own data and map. However the tutorial uses a US map SVG file and I need to use ...
0
votes
0answers
22 views

.xyz file(coordinate files) in python [on hold]

I have got a .xyz file (coordinate file which contains coordinates of atoms). Is there a way to convert it to .txt file in python? OR How can I read and write on a .xyz files in python ?
0
votes
2answers
14 views

Reclassifying vector polygons based on text string to integer

So I am trying to reclassify a text string by searching for bits of strings and converting those strings to an integer value in a new field within the field calculator. e.g. I want to find all values ...
3
votes
1answer
477 views

Pymodis downloading?

I'm trying to download and process MODIS imagery using pymodis. I have Python 2.7.8 (Spyder), numpy 1.9.1 and gdal 1.11.1. I've also installed WXPython. I originally tried to use the modis_download....
2
votes
1answer
93 views

Open Data Cube how to continue after the creation of the database?

I have some questions about using Open Data Cube. First of all I have successfully installed the virtual environment with miconda and the database with PostgreSQLPortable-10.1.1. Now I have already ...
0
votes
0answers
8 views

Parsing an input parameter to gdal:rastercalculator formula in QGIS 3.6 Python script

For training purposes I'm writing a QGIS 3.6 Python script. The script takes as inputs a raster layer and band, and three float numbers (refmult, refadd, sunel) and computes a simple formula: ((layer@...
0
votes
0answers
17 views

Error with Script Publishing Service from MXD with UNC Paths

I have script that attempts to publish a service which consists of a single tiff. I am using boilerplate ESRI code for this one: # initialize imagery_date = 'some date' folder_name = 'name of ...
0
votes
0answers
11 views

How convert OSM relation to GeoJSON -based all kind of roles

I just want to convert OSM data to GeoJSON where it is pretty simple with node and way tags of OSM data, but relation which is giving complex can't find the logic to convert OSM relation to GeoJSON ...
0
votes
1answer
24 views

Create mean raster stack from raster stack

I am trying to create a mean stack image(1 panchromatic layer) from a stacked tiff image(13 panchromatic layers). How do i go about doing this? My code: from osgeo import gdal import numpy as np #...
1
vote
1answer
28 views

Replicate QGIS operations in PyQGIS [on hold]

What is the best practice for calling QGIS/SAGA/GRASS algorithms from pure Python e.g. the command prompt or in PyCharm? I know that from QGIS -> Processing -> History, I can retrieve the code and ...
1
vote
0answers
21 views

Blank MapCanvas Window [on hold]

I am constructing a GUI using PyQT4 and QGis. Rigth now I can open the MapCanvas whith same buttons of Zoom In/Out using this code: from qgis.gui import * from qgis.core import * from qgis.PyQt.QtGui ...
3
votes
1answer
186 views

Creating function in function editor in QGIS

After my previous question Weighted values of field in QGIS, I successfully adapted the following formula in Expression dialogue "Value" / (sum("Value") / (count(CASE WHEN "Value" >= 1 THEN +1 END)...
1
vote
0answers
163 views

GeoDjango application using SpatiaLite database

I want to create a simple GeoDjango app with SpatiaLite database but I have this error at migrate: django.core.exceptions.ImproperlyConfigured: Unable to load the SpatiaLite library extensio`. ...
9
votes
3answers
12k views

How to select features using an expression with pyqgis?

How can I select features with pyqgis using an expression? I tried to use an QgsExpression but the select method doesn't take it: exp = QgsExpression("'ogc_fid' = 482") cLayer = canvas.currentLayer()...
1
vote
1answer
22 views

How do I open / move the focus to a layout in ArcGIS Pro using Python?

I have an ArcGIS Pro project which contains multiple layouts. I've got a Python toolbox with a script which, among other things, chooses which of the layouts is appropriate for a specific map. At ...
1
vote
1answer
20 views

Is it possible to print a map in PyQgis3 of a database table without rendering the layer in the project gui?

There is a way to print a map using pyqgis3 without rendering the vector layer in the project interface? (by giving just the connection to the table, the map extent and the style )
0
votes
1answer
250 views

Using GDAL or Python, how can I merge/combine 3 NITF images (RGB) into one image and keep the RPC metadata intact?

I'm looking to merge 3 imagery bands that are saved as separate files. The file format is NITF. The reason they are saved as NITF is because they have RPC metadata embedded into the images. I would ...
1
vote
0answers
15 views

Extracting certain landcover type in CONUS with Google Earth Engine?

I am new to Google Earth Engine and I would like to export the pixels with landcover type of deciduous broadleaf forest (MCD12Q1 with LC_Type1 equals to 4) in google earth engine. And the following is ...
1
vote
0answers
40 views

Files locked after running a Python script

I can run a Python script that uses qgsVectorLayer, qgsRasterLayer and many functions like processing:runalg("qgis.difference"......) and os.popen("gdalwarp -q -cutline.......) but if I want to run it ...
-1
votes
0answers
19 views

QGIS 3.4 using pygis for deleting columns v2

I have tried now to implement the code from BERA into the code from J. Monticolo. in order to get a script that is able to delete a set of columns from an attribute table. Previos Post. But I am ...
2
votes
3answers
152 views

Extracting pixel time series from Google Earth Engine

I have written a short program in Python to extract a time series for any given pixel for MODIS data stored in the Google Earth Engine. The code is working fine and returns a data frame containing the ...
0
votes
1answer
137 views

How to know if a coordinate is within a polygon in shapefile not working?

I have coordinates (lat and lng) in an Excel document a shapefile which contains all the different Canada provinces shapes. I would like to be able to generate a new field in Excel in order to ...
1
vote
0answers
516 views

Patch processing of multiple HDF5 files using Python and Gdal (gdalwarp)

I am trying to extend this process http://geoinformaticstutorial.blogspot.com/2014/06/reading-and-map-projecting-amsr-2-data.html wherein a set of raster data with separate geolocation arrays are ...
7
votes
5answers
9k views

Merge overlapping lines in ArcGIS

I have a polyline shapefile containing a number of lines, some of which overlap. By overlap, I mean that they follow exactly the same path for some of their route, but also have bits that are not ...
0
votes
1answer
207 views

AttributeError: 'QgsVectorLayer' object has no attribute 'setCacheImage'

When I call the following (using QGIS 3.0.2): self.layerCatalog = QgsCore.QgsVectorLayer( "MultiPolygon?%s" % s_fields, nameLayer, "memory") if self.iface.mapCanvas().isCachingEnabled(): ...
1
vote
0answers
24 views

Read laz files are stored on IBM COS

I have a problem with reading laz files that are stored at IBM cloud object storage. I have built pywren-ibm library with all PDAL requirements - one of them with docker. I then deploy it to IBM ...
0
votes
2answers
115 views

Testing if os.path.exists with ArcPy?

I am having trouble getting the os.path.exists to recognize that a file exists. I keep getting "File does not exist". I reduced the code to the absolute necessary to address my question. I believe ...
6
votes
1answer
126 views

Installing QGIS to virtual environment?

I'd like to install QGIS. I'm on a system that defaults to Python 2.5x and I downloaded python 3.7x with homebrew. I created a virtual environment with this code. brew install pyenv brew install ...
0
votes
1answer
29 views

Keep getting “no such file or directory” DriverError in GeoPandas [on hold]

I am new to using GeoPandas and Jupyter Notebook. I am able to define a name, let's say regions as regions = gpd.read_file('FilePathHere.shp') Then I am able to plot the shapefile. When I start a ...
-1
votes
0answers
35 views

How to georeference image in QGIS using Python code? [on hold]

I stitched images from my drone and I have longitude and latitude of centre of image. Also I know that drone was taking images from 50m height and focal length of camera is 35mm. Image is oriented to ...
0
votes
2answers
58 views

How to inverse the orientation of the holes coordinates of a polygon in geopandas

I have a polygon shapefile which I am reading with geopandas. The polygon contains holes. My purpose is to add a random point inside each hole. In order to create the points inside the holes (...
0
votes
0answers
24 views

Geopandas ImportError: DLL load failed (in pyviz tutorial geographic data examples) win7

I'm trying to run the geographic data examples from pyviz tutorial. I'm getting the error list in modules below. My Geopandas module work fine (and the others dependent modules) with 3.5 python ...
11
votes
3answers
4k views

What are pros and cons of Python add-ins vs .NET add-ins to ArcGIS for Desktop?

I found in ESRI .NET help: Python All ArcGIS Desktop applications include an embedded scripting language called Python. Many areas of ArcGIS—particularly geoprocessing—are accessible through ...
1
vote
1answer
34 views

Opening .vrt file with rasterio in Python?

I have 3 raster files (.tiff files) which are geographically 3 consecutive tiles of a particular area. I am trying to make a .vrt file of 2 out of these 3 files using the gdalbuildvrt python command. ...
3
votes
1answer
664 views

Specifying extent in GDAL WriteArray?

Is it possible to specify the extent when creating an empty raster in GDAL? I looked everywhere, but can't seem to find anything. The portion of my script where I write the raster would look ...