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.

2
votes
0answers
30 views

QGIS 3 crashes when adding a PostGIS view as a map layer?

I am trying to load a PostGIS view public.view1 into QGIS (3.6) as follows (per Add PostGIS layer to QGIS via Python Console): tablename = "view1" geometrycol = "geom" from qgis.core import ...
0
votes
0answers
28 views

Preserving Geometry of Shape file after merging edges using Networkx

I have a stream network and I want it to convert in a graph like data structure having vertices with only degree 1 and 3. The degree of the vertex is the number of edges incident to that vertex. The ...
0
votes
0answers
13 views

gdal FlattenTo2D makes geom null

I have a df that has geoms as ogr geom in 3D. I was trying to convert to 2D but it empties out the geom. ipdb> df['default_geom'][0] <osgeo.ogr.Geometry; proxy of <Swig Object of ...
0
votes
1answer
45 views

Transforming a image to a shape defined by image corners in earth coordinates - Python

I have a source satellite image. It is a rectangular shape x by y. I also have the stored lon/lat coordinates of the corners and the center point in the xml meta file. Is there a way with the gdal or ...
0
votes
0answers
21 views

What is the geom_type at CreateLayer() in ogr for xyz-GeoJSON?

My GeoJSON-File is a Multipolygon which creates several triangles with a X, Y and Z coordinate. Z determines the height of the specified point for X/Y. If i try to render my GeoJSON into a shapefile ...
1
vote
1answer
32 views

Use Python to find points based on 'month' and 'year' fields

I have a shapefile based on 27 locations, with historical values at each location for each month of the year going back to 1974. The file has 11,000 values. I have been trying to work on a script to ...
1
vote
0answers
24 views

QGIS.3 crashes when running python script of processing frame

I am new to qgis python scripting. QGIS always randomly crashes when I am trying to run the script as a processing algorithm. Here is my code: class OverlayCheckProcessingAlgorithm(...
0
votes
0answers
8 views

NDFD Grib2 geotransform

I am trying to transform the projection for my data in grib2 format to long/lat, but I'm not sure I'm using the correct EPSG. The data says it uses a "Lambert_Conformal" projection with a WGS84 ...
1
vote
1answer
75 views

Select by location inside a for loop in Python Terminal at QGis 2.18.17

I have two shapefiles (drenagem and rio_pri). I need to loop through every feature from rio_pri and save all those features from drenagem that intersect rio_pri. So I wrote the following code to be ...
1
vote
1answer
33 views

OGR SetAttributeFilter with multiple fields?

I am trying to open a layer using OGR in Python and filter the features using SetAttributeFilter() where two fields are greater than zero. from osgeo import ogr driver = ogr.GetDriverByName('ESRI ...
2
votes
0answers
22 views

How to get display of individual polygons from vector shapefile?

I am creating a shapefile with adding 20 polgons to it. poly = ogr.Geometry(ogr.wkbPolygon) for p in range(20):#20 should be replaced by pix_no ridx = rind1[p] ...
1
vote
1answer
41 views

Filling a dictionary whose values are a list container

import arcpy, datetime arcpy.env.overwriteOutput = True # Number of days to subtract tdelta = datetime.timedelta(days=21) fiberCable = r'C:\Users\broadhurstn\Documents\ArcGIS\Default.gdb\...
0
votes
0answers
23 views

How to downsample raster image for nightlights data in Python?

I'm working with the nightlights data - 30 arc second grids, spanning -180 to 180 degrees longitude and -65 to 75 degrees latitude. I want to downsample it to 5 arc-min resolution. Now my question is ...
1
vote
1answer
42 views

How do I access stroke color and width of a simple marker with python in QGIS?

I'm trying to set up style properties of a vector layer using python. I was able to modify the marker properties but I cannot modify those of Simple Marker, like width or color. Here is my code : ...
0
votes
0answers
31 views

GDAL OGR Polygon.Contains(Point) returns false but point is contained in QGIS map

I'm sure I must be missing something here but for the life of me I can't see what it might be. I have been struggling for the last hour with an issue with the Contains() method in OGR. I am iterating ...
0
votes
0answers
20 views

Grib Metadata with GDAL in Python

I'm trying to use GDAL in python to conditionally select raster bands from a grib file based on the time when the weather feature was measured (think temperature). If I run GetMetadata() on the ...
1
vote
1answer
28 views

Determining whether the geometry field in a SQLite table has z coordinates using Python

In the Shapely package, there is a function that allows you to determine whether coordinates include a Z value. It is object.has_z. Is there a way that a similar command can be carried on the ...
1
vote
0answers
21 views

Transforming TM75(29903) squares to ETRS89(3035)?

A bit of a long winded explanation here so please bear with me. I have received grid square data in ETRS89(3035) which I need to cross reference with out own grid squares which are in TM75(29903). ...
4
votes
1answer
48 views

Adding up several rasters to show the change

I want to add several images such that their change is shown in different colors. Such as the following in which I simply added two images in their grayscale. But I would like to have a colored ...
1
vote
0answers
30 views

GML file converted to ESRI shapefile with ogr2ogr missing spatial reference information

I am trying to convert Sentinel-2 cloud masks from GML format to ESRI shapefiles. I have managed to use ogr2ogr in a python script as described in the answer to Using ogr2ogr to convert GML to ...
3
votes
1answer
62 views

Looping through file names in QGIS?

I am working with a Mac OSX El Capitan, QGIS 3.4.5 Madeira and Python 3.6.1. I have a question which I believe is essentially a python one but applied into QGIS. I intend to program some algorithms ...
0
votes
0answers
37 views

Setting reference frame for shapefile with pyshp?

I'm using pyshp to create new shapefiles with Python 3. My code runs without errors, but when I open the resulting file in ArcMap I get this error: The following datasource you added is missing ...
0
votes
0answers
38 views

Filtering anomalous pixels from masked raster in Python?

I am struggling to succesfully filter out anomalous pixels from a Sentinel-1 image band mask (Pixel based), produced in Python. I am new to Python. By anomalies, in this situation, I mean ...
0
votes
1answer
41 views

geopandas: “LineStrings must have at least 2 coordinate tuples” when reading gpx files

I am trying to use geopandas to read in some gpx files (generated from a Garmin vista HCX). For many gpx files, given this code: >>> import geopandas as gpd >>> data = gpd....
0
votes
1answer
54 views

Generating new ID for column if ROW - PREVIOUS_ROW >= 45 seconds? [closed]

I don't want this code to be distributed
0
votes
2answers
39 views

Iteratively Filling a Dictionary and Updating a Feature Class

import arcpy fiberCable = r'C:\Users\broadhurstn\Documents\ArcGIS\Default.gdb\FIBERCABLE' fibercableToConduit = r'C:\Users\broadhurstn\Documents\ArcGIS\Default.gdb\FibercableToConduit' conduit = r'C:\...
1
vote
1answer
80 views

psycopg2.ProgrammingError: function does not exist

I am using Python code cur.callproc('function_a',[parameter1, parameter2]) for executing one function and this code is correct when I use a user having full DB permissions. But when I use a private ...
1
vote
1answer
38 views

How to work with overpass ways in Python?

I would like to calculate the distance of some points to the nearest motorway, for that i would obviously need a series of vectors/lines etc. to represent the motorway. On Overpass Turbo, the query ...
1
vote
3answers
50 views

Numpy masked array to raster

I am trying to transform a masked array, result of a NETCFD4 file, to a raster. The array is saved as a masked array, with shape (500,805), and the mask is the value 32768.0. The array looks like: ...
2
votes
0answers
33 views

Build cascade controls in QGIS

On this occasion I need someone to guide me, to implement cascading form controls in QGis 2.18. I am using a code for the attributes "area" "county" and "town" to perform a dynamic filter. The problem ...
0
votes
1answer
35 views

Reading in AW3D30 GeoTIFF files and processing them in Python?

I am new to GIS processing, and I am using Python 3.6 to do so. My current task is to read in several files of geographic data (specifically tiles of elevation data from JAXA), combine them for my ...
2
votes
1answer
30 views

Select layer by attribute using expression qtcreator/pyqgis

I'm trying to make a function like ArcGIS's select using Python 3.6 , QGIS 2.8.6 and QtDesigner, so this is my code: def execute(self): layers = self.iface.legendInterface().layers() ...
0
votes
0answers
36 views

gdal_translate not recognizing file format [duplicate]

I am trying to convert a .dat file to a .tif file using gdal_translate. The .dat file comes with an associated .Hdr file of the same name with the metadata (these are geospatial data from SNODAS). ...
0
votes
1answer
37 views

ERROR ArcPY parsing error SyntaxError: invalid syntax (line 2)

I'm trying to convert multiple lines to points so I typed the code bellow but it keeps on showing me this error: Parsing error SyntaxError: invalid syntax (line 2) liste_ligne =["E1_H20A_H35_D21E",...
3
votes
1answer
34 views

Using regexp_match in PyQGIS script to select features?

I am learning to use Python scripts to automate tasks in my work. I am a beginner in Python and PyQGIS. I would like to select entities in a layer using regexp_match. It works well in QGIS but I can'...
1
vote
2answers
40 views

Python upload to service fails in FME but works in ArcGIS

I have added a shutdown Python script to my FME workbench to publish the TIFFs written as a service. import fme import arcpy AGSconnection = "W:\\Entity\\ABZ\\myfolderpath\\gbepabz-file.name.ags" ...
0
votes
1answer
28 views

Fast road snapping for big data

I hope this question is not too general. I'm dealing with a lot of data from vehicles (1.000.000 GPS points per day) and I want to snap the data to a big city's street network. The timely order is not ...
1
vote
0answers
35 views

Removing file from os results in WinError 32

Using PyQGIS for a standalone plugin, I try to remove a file I created before as an output file for QGIS processing: layers = [layer for layer in QgsProject.instance().mapLayers().values()] ...
4
votes
0answers
36 views

Randomized organic warp of adjacent polygons that preserves topology and fixed nodes

I'm looking for algoritms to modify a set of polygons to make them appear more organic. They still need to maintain their topology and furthermore some of the nodes might be fixed. Please see the ...
0
votes
0answers
14 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
43 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'...
1
vote
1answer
53 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
30 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
47 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
37 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 ...
1
vote
1answer
31 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 ...
1
vote
1answer
29 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', '...
2
votes
1answer
28 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
17 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 ...
-1
votes
1answer
31 views

Converting ArcGIS Polygon data to Lat/Long? [closed]

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'...