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.

0
votes
0answers
6 views

How can I convert list of polygons to multipolygon

I have a list of polygons where each polygon is a wkt form as follows: list_polygons = ['POLYGON ((-88.131229288 41.900200029,-88.12973798 41.900104202,-88.129785999 41.894907769,-88.131352409 41....
2
votes
1answer
452 views

QGIS 3.0.3 python error “/bin/sh: gdal_polygonize.py: command not found”

I have recently downloaded QGIS on my Mac to preform an analysis for my dissertation. I am trying to convert my raster data to polygon data using the gdal_polygonize.py tool provided by QGIS. ...
3
votes
1answer
30 views

Making Shapely box larger using GeoPandas?

I'm creating a box that covers the the area of a GeoPandas GeoDataFrame, so that I can use it as an inverted map to later cover up unwanted spill-over data. import geopandas as gpd import geoplot as ...
0
votes
0answers
26 views

Python or GDAL equivalent to ArcPy GetParameterasText [on hold]

I am wondering if there is any equivalent to arcpy.GetParameterAsText in Python and/or GDAL (not using ArcPy). I would like to create a script that prompts a window asking for a file location (as when ...
5
votes
2answers
6k views

GDAL python cut geotiff image with geojson file

I wrote the function which cutting geotiff image by bounding box. First image is original. At second you can see result off my code. I don't use gdalwarp or any console utilities. But I have no idea ...
0
votes
0answers
8 views

installation problem with mpi4py [on hold]

I am using windows 10, and I want to use mpi4py for parallel computing. I used "pip install mpi4py" to install MPI, but when I want to assign number of processors in cmd, I face this error: 'mpiexec' ...
2
votes
1answer
29 views

Writing Non Spatial Table into Geopackage - Python

Just wondering how to write a non spatial (aspatial) table to geopackage using python. I have attempted using Fiona, geopackage = 'some_geo.gpkg' layer = 'test_layer' schema = {'geometry': {'type'...
0
votes
0answers
16 views

Installing cgal for use in Python?

I have a project which needs some of cgal features. How can I use cgal library in Python? I tried installing cgal-bindings but is comes up with this error: Complete output from command python ...
1
vote
1answer
1k views

Using GDAL to read data from GRIB file in Python?

I am attempting to use GDAL to read corresponding latitude, longitude, and temperature values from a GRIB file. I would like to store these data points in a 2-D list. I was able to do this using the ...
0
votes
0answers
17 views

Extracting location from tweets whose location or x y coordinate is not available [on hold]

I am trying to retrieve location from tweet text whose location of the user is turned off how do i go about it??
0
votes
0answers
30 views

Sorting massive amounts of geospatial data based on location and scale using Python? [closed]

I have a few terabytes worth of geospatial data. Raster, matrix, imagery and vector, everything from point shapefiles of gas stations in a local area to country overviews. Some of the data is good (...
0
votes
0answers
11 views

Change color of rubberbands used when Vertex tool is active

When using the Vertex Tool, I see a rubberband. I'm actually hoping these are 2 rubberbands in reality, because I would like to color each one based on their length using Python. Is it possible to ...
0
votes
0answers
7 views

Resampling Sentinel-1 to Landsat 8 size and location

I am training a convolutional neural network to classify landcover and I would like to ingest both Landsat 8 and Sentinel-1 into my classifier. Currently it is working reasonably well for Landsat 8 ...
1
vote
1answer
33 views

Extracting raster

I've been using my own code to extract multiple rasters using a single shapefile. I've just substituted the strings (inputs, file paths etc.) to my code: import subprocess, os, glob, gdal ...
0
votes
0answers
11 views

Using population data as Z-axis to make a 3D map in Python [on hold]

I want to make a 3D thematic map with the different status' population data as the height in Python. Now I have the shapefile of the status and the population data. But I don't know how to link the ...
1
vote
1answer
37 views

Calculating minimum distance in meters of two polygons (defined in lat/long coordinates)?

I'm new to GIS and I'm a bit lost in the terms and concepts, so I'm not sure I'm asking a valid question, but I need to calculate the minimum distance (in meters) of two polygons which are defined in ...
0
votes
0answers
14 views

Basemap and EPSG 3857

I have my MatPlotLib basemap set up in Mercator projection: map = Basemap(projection='merc', llcrnrlon=-10., llcrnrlat=30., urcrnrlon=36.5, urcrnrlat=46.) I need to create an ...
0
votes
1answer
329 views

Geopandas - Import CSV: make polygons from X,Y Coordinates based on ID

I'm working on a script, where I want to import a CSV file with coordinates and an ID which should be used to make a polygon shapefile from those. CSV file looks like this (example): ID, X, Y 10,15....
-1
votes
1answer
42 views

NameError: global name 'layer' is not defined

I've modified code of a plugin go2nextfeature as below import os from collections import OrderedDict from geo_utils import utils as geo_utils, vector_utils as vutils from qgis.core import * from ...
-1
votes
0answers
8 views

The Spyder in Anaconda runs Python scripts slowly [on hold]

I have a question about how fast of Spyder running a python scripts. I have 36 scenarios and 80 points in each scenario. At the very beginning, it takes me about 20 minutes to finish one scenario. ...
0
votes
1answer
75 views

using histogram2d with categorical dimension

This is a scatterplot of business addresses in Melbourne by ANZSIC division names. sns.pairplot(x_vars=["x coordinate"] , y_vars=["y coordinate"] , data=d , hue=...
0
votes
1answer
481 views

get date from image using python API in Google Earth Engine

I am trying to extract the date as a string from an image in google earth engine, but can't seem to get it right. This is the code I have so far. date = ee.Date(image.get('system:time_start')) This ...
0
votes
1answer
261 views

gdal_translate with custom corner coordinates in python

I wish to convert this Python code using a gdal command line tool to using the gdal python library. I am using it to convert some PNG satellite images I am downloading to georeferenced TIFFs. I ...
20
votes
3answers
7k views

Smoothing/interpolating raster in Python using GDAL?

I am developing in Python and using GDAL from OSGEO to manipulate and interact with rasters and shapefiles. I want to take a shapefile that has point features and interpolate it into a surface raster....
1
vote
1answer
24 views

Using GDAL Warp results in odd pixel sizes and gaps

I am mosaicking one meter and three meter rasters to two meters in Python with GDAL Warp using the following code: cl_string = "-of GTiff -co COMPRESS=LZW -tr 2 2 -tap -r near -overwrite \ -multi -wo ...
-1
votes
0answers
12 views

Save pictures from different files to one file [on hold]

This is my code: imagePatches = glob('C:/Users/Touati/Documents/cancer_dataset/Dataset/**/*.png', recursive=True) imagePatches.save("C:/Users/Touati/Pictures/test/{}.png".format(item),"png") I get ...
5
votes
2answers
35 views

Distance to a ridge as function of angle (Python)

No success googling this for a while, but likely I just don't know correct terminology. Also, tell me if you see another exchange more suited for this. Given: A boolean 2-dim array that stores if a ...
1
vote
1answer
24 views

Multiple shapefiles to one GeoPandas GeoDataFrame

I'm trying to vertically concatenate multiple shapefiles that reside in one directory, into one geodataframe. They all have the same table schema and same CRS. I am trying to use the code from this ...
3
votes
1answer
35 views

Cheapest path through polygons and lines from point to point

I want to find the cheapest path or the least cost path from one point to another point. The points are part of a vector map and do not lie on a network. All features being part of the map have ...
4
votes
2answers
2k views

How do I write a GeoPandas dataframe into a single file (preferably JSON or GeoPackage)?

I'm new to GIS and having a basic beginner problem. I've got data in the form of a geopackage .gpkg from GADM.org. I can read in and use the data without problem using Geopandas (via built-in Fiona)....
0
votes
1answer
27 views

Text File MultiPolygon/Polygon to PostgreSQL using Python/Psycopg2

I am writing a python script attempting to insert GeoJSON Polygon coordinates into a Postgres table. I am writing a basic insertion code since I am new to GIS domain. The code look like this: ...
1
vote
1answer
22 views

How to reverse the MultiLineString command to a list of arrays

Let's you have a list of coordinates that you can convert to a line string: coords = [((0.0, 0.0), (0.0, 20.0)), ((20.0, 0.0), (20.0, 20.0)), ((1.0569687968009744, 14.934839039628798), (5....
18
votes
8answers
71k views

Installing GDAL and OGR for Python?

I am developing some code in Python, and I want to use the GDAL/OGR python bindings. What is the minimum I need to install in order to use the GDAL and OGR python bindings? What is the easiest way to ...
0
votes
2answers
15 views

Geoviews Attribute error

I just installed GeoViews with success and I tried to follow one example at the first page of their site and this already gave me an error. In fact, there are two errors of the same type that occurred ...
0
votes
0answers
21 views

Installing QGIS on OSX: “QGIS requires Python 3.6” but 3.6 is already default Python

I'm trying to install QGIS on OSX Mojave from the official installer. I have system Python 3.6 installed, as the default: $ which python $ ls -al /usr/local/bin/python lrwxr-xr-x 1 me admin 44 18 ...
0
votes
0answers
11 views

Extracting surface reflectance values of stratified sampled points in Google Earth Engine

I created 400 stratified sampling points (100 for each of the four classes) using this script: https://code.earthengine.google.com/cbba16d87066b45e61e7d2f7e06bd5c5. Then I exported the result as an ...
2
votes
0answers
23 views

Dissolve Line Strings to one string - “No Shapely geometry can be created from null value”

I have a layer with 7000 LineStrings, all represent bus routes: It seems that all the bus routes are contiguous, but I'm not sure of it. I'm trying to use python shapely to dissolve all those ...
0
votes
0answers
20 views

Problem with Fill Sinks - ArcHydroTools

I'm getting use FillSinks of ArchHydroTools with Python but some problems are happen My code is: Import arcpy Import ArcHydroTools ArcHydroTools.FillSinks('projectraster.tif','fil.lyr', "10", "...
1
vote
1answer
160 views

django-raster rendering raster url

i want to add raster functionality in django using postgis database using django-raster package and this docs. here my code : models.py from django.contrib.gis.db import models class RasterWithName(...
0
votes
1answer
16 views

Display longitude latitude points on xy raster file in meters and with projection of Albers Conical Equal Area

I'm new to Python and I have a data set which contains longitude and latitude coordinates(WGS84) points, and a .img raster file of CONUS in meters and with the projection of Albers Conical Equal Area. ...
0
votes
0answers
12 views

Open NITF containing multiple images using Python GDAL

I have a file in NITF 2.1 format, which contains multiple images within it (in ENVI speak "image segments"). But with Python's GDAL, opening the file only gives me access to the first image. How can I ...
1
vote
0answers
83 views

PyQGIS raster image shifted from vector shapefile

I previously asked a question about my raster image being larger and shifted over from my vector image here, but now I realize that the raster image is only shifted to the left and up from the vector ...
1
vote
0answers
28 views

Error : Could not load source layer for INPUT

Very simple piece of code. I'm trying to run this as a stand alone Python script, not in the console. Keeps giving the error "Could not load source layer for INPUT" , shape not found. But the os....
3
votes
1answer
69 views

Using libraries other than PyQGIS to develop plugin for QGIS?

I develop a plugin for QGIS. Before to integreted it in the QGIS I developped it with GIS library (Fiona, shapely, geopandas, ...) and it work well. Now I try to build it with plugin_builder of QGIS. ...
3
votes
1answer
204 views

Python/PostGIS - Type “Geometry” Does Not Exist

I am a total novice with both PostGIS and Python - I am just trying to get this game running. I have followed the instructions here and here and am now at a dead end. I have pgAdmin 4 downloaded and ...
3
votes
2answers
896 views

Seeking methods for converting coordinate datum and format in Python? [closed]

Related to an earlier Q&A of Missing grid shift files for cs2cs.exe?, what are the various methods to convert coordinate datum and format in python? (Windows Vista, python 3.4) For example, ...
0
votes
1answer
132 views

ValueError using MapProxy decorate image middleware with WMS

I am successfully using Mapproxys decorate image middleware to apply a watermark to WMTS tiles. I am using the following code: def annotate_img(image, service, layers, environ, query_extent, **kw): ...
0
votes
1answer
81 views

Transforming a polygon to a linestring

Is it possible to (trivially, via a tool in python) to convert a polygon to a linestring? if so, how? If not, why?
0
votes
0answers
36 views

pyinstaller stops in the middle of process

I try to create a .exe from a .py script. I use Pyinstaller. The script runs fine with no errors in Pycharm. If I open the .exe my Tkinter opens I can choose the files etc.. And then in the middle of ...
12
votes
2answers
8k views

Area in KM from Polygon of coordinates

I have polygons from coordinates in (python shapely) that looks like this POLYGON ((24.8085317 46.8512821, 24.7986952 46.8574619, 24.8088238 46.8664741, 24.8155239 46.8576335, 24.8085317 46.8512821)) ...