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
10 views

Reading dataset of NetCDF file

I have 2 NC files having the same dataset which I am reading by using netCDF4 in Python. After reading one of the NC file, the dataset is getting properly displayed by using np.rot90(data) which was ...
0
votes
1answer
24 views

Cascading union OGR Multipolygons?

I have 2 OGR Multipolygons that intersect, hence I want to cascade Union them. I tried this but it returns me empty and doesn't union it. Seems this works only on Polygons and not Mul;tipolygons. What'...
0
votes
1answer
13 views

Performing sjoin on polygons and lines without intersection using GeoPandas?

I want to join a GeoDataFrame with Polygons (circular, were created from Points with buffer) with a GeoDataFrame that has Linestrings. These polygons and lines do not necessarily intersect nor ...
0
votes
1answer
23 views

Plotting Dataset of netCDF using matplotlib.pyplot displays rotated plot

I have read a Dataset in NC file using netCDF4 in python and then tried to plot the dataset using matplotlib.pyplot. But issue is the plot shows the image but with 90 Degrees clockwise rotation. ...
1
vote
2answers
28 views

Distance between two points on QGIS 3.4.7 and Python 3.7

I am under the 2154 CRS (RGF 93). I want to calculate the distance in meters between two point knowing their coordinates. Let's consider two points : A(474828.85, 6756169.31) and B(874895.75, 6756159....
0
votes
1answer
18 views

Testing intersection between shapely object and geopandas GeoSeries?

This is a Python question, involving geopandas and the libraries it calls, primarily pandas and shapely. tl;dr: I am trying to run a test using if foo.intersects(bar): and am repeatedly getting one ...
0
votes
1answer
20 views

R or Python geometry checker that outputs results as table

Is there a R or Python solution that 1) checks the geometry validity of vectors and 2) outputs the results in form of a table (see table below). QGIS for example has a nice plugin that carries out ...
0
votes
0answers
23 views

Method of splitting a polygon into multiple parts through a script [on hold]

I need a tool that takes a polygon, usually shaped somewhat like the one below, and to have it split into even sections, going along it's gradient, then have some of them merged again to indicate the ...
1
vote
1answer
17 views

Join a CSV file to GeoJSON using ogr2ogr in a Python script?

I have a CSV which I would like to join to a GeoJSON. I found this answer which I tried to implement but I can't get it to work just yet. Here's an extract of my python: join_command = ['ogr2ogr', '...
0
votes
1answer
31 views

Read shapefile with Fiona - AttributeError: 'NoneType' object has no attribute 'get'

I am trying to read in the following shapefile below with fiona: import fiona from shapely.geometry import shape polygons = [shape(feature['geometry']) for feature in fiona.open("myshapefile.shp")] ...
2
votes
1answer
23 views

Normalized interpolation doesn't work for WGS84

I am trying to interpolate linestring on WGS84 coordinate system by factor 0.5. LineString length is 427 meters (measured by different tools), so I expect to get line with length=213.5 meters. But I ...
0
votes
0answers
12 views

Calculate monthly sum of rainfall raster with python or shell? Gdal? [on hold]

I have rainfall data in raster file (.tif) every 3h for several years in a folder. Each file has the date into the name with the format: YYYYMMDD.HH.tiff I want to calculate daily and monthly sum of ...
0
votes
0answers
11 views

Updating GeoNode metadata using pyCSW?

We deployed our geospatial data services using GeoNode 2.10, and would like to update/import the metadata for layers published on the GeoNode. Because our metadata is stored in another server and have ...
0
votes
1answer
25 views

Converting ArcGIS Polygon data to Lat/Long? [on hold]

I have downloaded some ArcGIS data from here: ArcGIS Data and there is an explanation of the schema here: ArcGIS Data Documentation How do I convert the values in the array to lat/long? i.e. Here'...
2
votes
1answer
34 views

Re-project GeoJSON from pixel-space to lat-long in Python

I have created a GeoJSON of linestrings in pixel space using Python. However, I now need to re-project the file to match the same projections and extent of the .tiff file I wish to layer the GeoJSON ...
0
votes
0answers
9 views

Connect optimal path and optimal destination [on hold]

I have the following problem which can be solved in 2 stages: The first stage is to calculate the least cost path for transporting the produce from a pixel on the field to the edge of the road, for ...
1
vote
1answer
27 views

Python: Convert shapefile to GeoJSON whilst stripping and renaming fields

I'm writing a Python script to convert shapefiles into GeoJSONs but I would like to remove many of the fields as they are redundant and rename the ones I am retaining. Here's an extract of where I ...
3
votes
2answers
38 views

PostGIS st_makeline extra columns in result

From a table of point data, there are some groups of points that can define a line (cross sections of a water course). 'cross_section' is the name of the table with the point data, geometrypoint the ...
0
votes
0answers
34 views

Writing data from QGIS to an Excel template with Python [on hold]

I have an Excel template and I'd like to get the information from attribute table into my template in .xls I'm new to Python but I already know how to put data from a folder to the Excel (with ...
0
votes
0answers
27 views

What signal can be used to get the selection change on a feature?

Right now I am using: self.iface.mapCanvas().selectionChanged.connect(FunctionThatReactsToTheSignal) But this one sends two signals, one for the deselection of the previous feature and one for te ...
1
vote
0answers
21 views

Hide columns in QgsAttributeTableView with Python

I use this code to initialize QgsAttributeTableView and hide some columns in it in my custom widget: def __init__(self, layer, canvas, hidden_columns, cache_size=5000, parent=None): """...
0
votes
1answer
23 views

arcpy.SelectLayerByAttribute_management reference a field and a variable

I have tried every which way but the right way. I can't seem to get the quotes in the right spot. I have a float field called speeds and I want to compare it to a float variable I am calling ...
1
vote
0answers
62 views

What is the correct way to delete temporal files from geoprocess tools in ArcGIS, ArcPy?

I found that geoprocessing tools like arcpy.gp.SegmentMeanShift makes a lot of heavy temporal files (script is shown below) that keeps lock while the script shell its open, so you can't delete them, ...
3
votes
1answer
45 views

Error using rasterio's sample method

I'm using rasterio's sample function to get values from a (single-layer) raster based on a list of x,y locations: for val in myraster.sample(locations): print(val) This works fine for the first ...
1
vote
1answer
28 views

GeoPandas does not identify points inside polygon

I am trying to intersect some points with a polygon in GeoPandas. First I create a Point GeoDataFrame from a text file. import geopandas as gp import numpy as np import pandas as pd from shapely....
0
votes
0answers
14 views

How to populate an item's tables list for a ArcGIS API for Python Map Service Item?

I am trying to obtain a specific table from a Map Service item, however the table list is empty. The layers list correctly reports back 5 layers. My code snippet below: search_result = gis....
2
votes
2answers
36 views

Programmatically determining version of ArcGIS API for Python?

I would like to obtain the version of ArcGIS API for Python for logging/diagnostic purposes. Is there a way to determine this before a connection is made? I know that once I have the GIS object, I ...
2
votes
1answer
28 views

How to get the source name of a feature layer

I have feature layers that have a different name in the TOC then that they do in the GDB. I cannot change either of these and I need the name of the feature class from the GDB in order to make my ...
0
votes
0answers
26 views

Changing Color of Border After Clipping using Google Earth Engine?

I require nighttime satellite imagery over a particular geometry, clipped by Census Tract. I have uploaded shapefiles into EE. I am going to loop through particular shapes and dates to export images ...
2
votes
1answer
50 views

Getting spatially referenced tiles from WMTS

I have been able to download tiles from a WMTS request in .tif format using owslib in standalone python: from owslib.wmts import WebMapTileService wmts = WebMapTileService('wmts_url') img = wmts....
0
votes
1answer
23 views

Count number of pixels from .msk in Python to derive study area size

Apologies I am totally new to GIS in Python. I am trying to find out the total area of the Barents Sea mask the NSIDC use to calculate their products and therefore I need to know how many pixels the ...
-2
votes
0answers
21 views

Polygons vector shapefile conversion to xyz format using Python [closed]

I have to convert a vector multipolygons shapefile to an xyz file where x and y are the lon and lat of points in the vector file extent, and z is equal to 0 for a point outside polygons, and equals 1 ...
0
votes
0answers
11 views

How to join the Least Cost Path with Optimal Destination?

I have the following problem which can be solved in 2 stages: The first stage is to calculate the least cost path for transporting the produce from a pixel on the field to the edge of the road, for ...
0
votes
0answers
38 views

Converting NetCDF dataset array to GeoTiff using rasterio Python

I have read a NetCDF file using the netCDF4 library and then read one of its datasets ("Evapotranspiration") into a variable (variable contains array) using the following code. Subsequently now I am ...
0
votes
0answers
19 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.
1
vote
0answers
27 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 ...
0
votes
0answers
24 views

.xyz file(coordinate files) in python [closed]

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 ?
1
vote
1answer
20 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@...
1
vote
1answer
66 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. ...
0
votes
0answers
19 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
26 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 ...
2
votes
0answers
46 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 ...
0
votes
0answers
28 views

How convert OSM relation to GeoJSON -based all kind of relation member 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
34 views

Replicate QGIS operations in PyQGIS [closed]

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
26 views

Blank MapCanvas Window [closed]

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 ...
1
vote
1answer
83 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 ...
1
vote
1answer
23 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 ...
2
votes
0answers
43 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
22 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 ...
0
votes
1answer
25 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 #...