Questions tagged [python]

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

Filter by
Sorted by
Tagged with
-1
votes
1answer
56 views

Python implementation to generate Delaunay triangulation based spatial weight matrix [closed]

I'm looking for Python implementation for Delaunay triangulation based spatial weights. There are a lot of spatial weights techniques available in a Python geospatial library PySAL but Delaunay ...
2
votes
1answer
1k 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`. ...
0
votes
0answers
36 views

Cropping TIFF in Python using GDAL returns NoneType object

I tried to clip a TIFF in Python, but I always get a NoneType object instead of a gdal.Dataset. The most promising solution I've come about so far is this: t = os.path.join(dir_omk(plot)) # gives path ...
1
vote
1answer
17 views

Making many offset lines that are always a set distance from the previous

I've discovered the Offset lines tool in Vector Geometry, which allows you to make a parallel line next to the input at a specified offset distance. What I would like to do is specify how many ...
2
votes
1answer
612 views

Large queries in Overpass Turbo ran out of memory

I would like to query a large bounding box in Openstreetmap using the overpass API from within python. A solution similar to this one would be ideal. My extent, however is very large, and I would ...
2
votes
1answer
316 views

GeoPandas fill polygon gap according to gap area

I have several polygons with holes and I would like to fill the gaps with sizes smaller than a certain area import geopandas as gpd from shapely.geometry import Polygon # Initializing a polygon with ...
8
votes
3answers
3k views

What is the simplest way to get the average of multiple raster images while ignore nodata?

I am looking for the simplest approach to take the average across multiple raster images, which contain a lot of nan values. The mean value should ignore any nan. The gdal_calc does not work, because ...
2
votes
2answers
55 views

Calculating the area of multiple polygons using GeoPandas

I am writing a Python script to calculate the area of polygons, as I have a small polygon, I am getting the area of polygon 0.000. A shapefile contains multiple shapefiles. I am thinking due to the ...
1
vote
1answer
46 views

Filter scene overlap in image collection

How can I filter areas of scene overlap so that each pixel only has data from one landsat scene? My goal is to have as many images as possible while also maintaining a uniform number of images across ...
2
votes
1answer
24 views

Python GDAL RasterizeLayer: Select attribute value in case of shape overlap

I want to rasterize a MultiPolygon Shapefile layer in Python and use values of one column to write to the raster. However, I cannot preclude that features of the Shapefile overlap. Is there a way to ...
2
votes
2answers
324 views

Creating perpendicular lines along stream at points

Using ArcPy, I'm trying to figure out how to draw perpendicular lines along my Streams feature class. I have a set of points, that are snapped to my stream centerline. I've seen the "Generate ...
1
vote
1answer
34 views

PyQGIS-Code in Plugin doesn't store features completely in memory layer

Within a QGIS plugin I download data which is then converted into a list of QgsFeatures. My way of storing for a long time was to use addFeatures on the provider object, but now in QGIS 3.16 LTR, not ...
4
votes
1answer
66 views

Removing overlapping parts of polygons from the same layer in QGIS

I'm working on a favourability mapping based on geologic inputs. One of those inputs is composed of fault zones which in my case are represented as one unique polygon layer with one attribute that ...
-1
votes
1answer
26 views

Boolean operations on polygons using Python [closed]

I have 2 polygons and I would like to subtract one from the other. Is there any Python library that can do this for me? In the image below I'm trying to subtract the darker polygon from the lighter ...
2
votes
1answer
319 views

How to clear the cache of QGIS 3.10 with Python?

I want to add new attributes to a new and empty shapefile layer. The problem is, that QGIS 3.10 takes attributes from the shapefile layer which was used before when loading it to the GUI. So there ...
1
vote
1answer
43 views

Using geopandas GeoDataFrame in gdal.Grid for spatial interpolation viz IDW, nearest neighbour etc

I want to interpolate the point data using IDW with GDAL osgeo.gdal.Grid. IDW_gdal = gdal.Grid(Output, input, zfield="rs", algorithm = "invdist", ...
0
votes
1answer
23 views

gdal2tiles has no attribute 'generate_tiles'

I created a new conda environment with python version 3.7 Then installed conda install -c conda-forge gdal=2.4 Then installed gdal2tiles pip install gdal2tiles and then python test.py #test.py ...
1
vote
0answers
28 views

Fill shapefile column with raster value, shapefile with alias name and calculated field

I've to sample raster values to fill a column of point shapefile using Python, and for this I've no problem. But this shapefile has some fields with alias name and some fields that result from an ...
0
votes
2answers
299 views

Arcpy Geocoding Script Fails (vague messaging)

Using ArcMap 10.6 to load a Python script that will geocode 25,000 addresses. It looks like it fail during the actual gecoding attempt with an error: ERROR 000010: Geocode addresses failed.Failed to ...
0
votes
1answer
58 views

GeoPandas has new warning and cannot read_file()

I have written a script long time ago which worked with no problem, using GeoPandas in order to read shapefile to my jupyter notebook. Today I have run my script and when I import geopandas I get new ...
2
votes
1answer
67 views

How to write attribute-only tables in Geopackages with GeoPandas

I searched around and found similar questions (Writing Non Spatial Table into Geopackage - Python), but that discussion is on a slightly different topic. Is there a way to write attribute-only tables ...
0
votes
0answers
23 views

Icons that do not resize in Folium

My understanding is that Folium still does not have capability to create labels for polygons. Tooltips do not work for my use-case since I can have hundreds of small polygons and I don't want users to ...
0
votes
1answer
206 views

Automatically create local copy of hosted feature service and sync

does anyone know if its possible to write a python script to automatically create a local copy of a hosted feature service from ArcGIS online in to ArcMap so that it can be modified locally and then ...
0
votes
1answer
343 views

Can't open QGIS 3.8 plugin manager on OSX

I have not been able to open the plugin manager in QGIS 3.8. I am running Sierra OSX. This is the message that I get when I try to open the plugin manager: An error occurred during execution of ...
0
votes
0answers
13 views

Displaying map from ArcGIS REST API using Python

Is there any way to display an ArcGIS map from a standalone ArcGIS Server URL ie (https://xxx.xx.xxx/acgis/rest/services/MapServices/xxxxxmap/MapServer/) using Python? ideally ipyleaflet.
0
votes
0answers
25 views

How to speed up GDAL polygonize

I have a classified raster with two classes and I'm using GDAL python API to convert the raster to polygon using this function gdal.Fpolygonize(raster, raster, dataset, 0, [], callback = None) The ...
1
vote
0answers
23 views

Open QGIS project from PyCharm or other Python IDE

I have QGIS project and Python script. I know how use QGIS Python console to run script. Is there any way to open a QGIS project in PyCharm and to run the Python script there?
1
vote
1answer
88 views

How to link a script to a button in startup.py

I created a startup.py file in order to customize my toolbar. In particular, I would like to create buttons that could launch my various scripts that I created. So I defined an icon to display it on ...
4
votes
2answers
338 views

QGIS plugin development environment variables?

I want to develop a plugin gor QGIS3. I downloaded Osgeo4w network installer 64Bit. I created a bat file as following for set my environment variables; @echo off call "%~dp0\o4w_env.bat" call ...
0
votes
0answers
22 views

How to query by Node ID in esy.osm.pbf

I've written the following Python code to query airports in Greater London: osm = esy.osm.pbf.File('/Users/michael.nares/Downloads/greater-london-latest.osm.pbf') airports = [entry for entry in osm if ...
2
votes
1answer
53 views

Parsing through a Sentinel-2 tile

I downloaded a Sentinel-2 product and opened with rasterio.open() all the bands I want to use. This returns matrixes with size 10980 X 10980 I need to parse through the image using blocks of 120 X 120 ...
4
votes
1answer
50 views

Reading single row in PyShp with shapefile.Reader

I use PyShp and shapefile.Reader to read shapefile files. If I want to read a whole file I use: with shapefile.Reader(file) as shp: for row_num, row in enumerate(shp.iterRecords()): print(...
1
vote
0answers
30 views

How to set band names of multi-band GeoTIFF asset upon upload to Google Earth Engine

I have created a multi-bands GeoTIFF using xarray in Python following this answer. When I display this raster or open it in QGIS, all the bands are named following the variable they represent: ...
2
votes
2answers
58 views

Matching points to polygons and handling points NOT in polygons

I have two GeoDataFrames: one with 191k address points and another with 18 polygons representing catchment areas for specific schools. Theoretically, every address should fall into one of the zones. ...
3
votes
1answer
598 views

Automating recording fields in a shapefile via pyshp

I am following the tutorial here for how to convert a csv to shp using pyshp. I am almost there, with one issue. In the tutorial, the person loops over the rows in the csv, and for each field, assigns ...
0
votes
0answers
23 views

Accessing polygon geometries from a geodataframe - keep getting a key error [duplicate]

I have two geodataframes. One of about 5000 points (geolocated by me using GoogleV3, and one of 25000 polygons (from a govt-provided shapefile). Every point will be in one (and unless only one) ...
1
vote
2answers
31 views

Does Shapely support serialization of GeoJSON with empty and non-empty coordinate sequences?

The shapely.geometry.shape method will fail with an IndexError if a Multi[Point|LineString|Polygon] has an empty coordinate sequence, and I am curious if this is the intended functionality, note the ...
0
votes
2answers
43 views

How to query using ST_GeometryFromText

I am trying to make a query using ST_GeometryFromText. When I run the code I recive the error posted below fieldGeometry is an object in WKT format How can I make this query correctly? Code: def ...
1
vote
0answers
50 views

Differentiating between stacked parcel shapefile and general parcel shapefile using Python [closed]

I am totally new to this domain. I would like to detect stacked parcel shapefile and mapped respective data or outlines created to all stacked parcels. In a general case where only one parcel on land ...
2
votes
1answer
545 views

When does Shapely's “polygonize_full” detect a dangle?

Shapely's polygonize_full operation, which merges line segments into polygons, returns four geometry collections: polygons, dangles, cuts and invalid ring lines. Dangles are defined in the ...
2
votes
1answer
38 views

Using QgsDxfExport in Python script leads to crash

I am trying to export a QgsDxfLayer from QgsVectorLayer, but it crashes at dxf.addLayers().Might I forget something essential ? ... dxfLayers = [] dxfLayers.append(QgsDxfExport.DxfLayer(vecLayer, -1)) ...
5
votes
2answers
81 views

QGIS Python API set label color based on attribute field

I'm trying to set the text label color and size based on the attribute table. I got the size setting correctly but not the color. My current result looks like this (The symbol has been set to be ...
1
vote
2answers
4k views

Cannot convert float Nan to integer with raster data

I have a script that basically takes a low resolution raster grid and creates elevation band text file for this raster based on a high resolution DEM. The data can be accessed from here. On Conda ...
1
vote
0answers
42 views

Creating a code that computes the distance between two properties given northings and eastings

I was given a file with different properties in different sheets containing coordinates for each corners. I need to create a program that computes the distance between two lots. I'm not sure how to ...
0
votes
0answers
13 views

Update GeoServer raster layers

I have created time dimension mosaic layer with *.tif files and PostgreSQL data connection. I tried to update layer with adding new tif files to data folder and using geo.reload() from geoserver-rest ...
2
votes
1answer
68 views

Retrieving OpenStreetMap data with Python using GeoJSON geometry as boundary [closed]

I'd like to : Select OSM map from a polygon geometry defined by a .geojson file Extract data (ex : parks area, building height,...) included in the geometry Any idea?
0
votes
1answer
57 views

Rasterizing shapefile with attribute value as pixel value labels with GDAL in Python

I am new to GDAL and geom shapefiles. I have a 3-band .img file (with other associated files) as raster images. And also a shapefile which includes 10000+ features (multi-polygons), the properties of ...
0
votes
0answers
29 views

Choosing the right projection using PyProj

I'm starting with GIS work trying to analyze movement of cars on a track. I've understood that in order to use a library like shapely I need to transform from GPS spherical coordinates to Cartesian ...
3
votes
2answers
115 views

Calculate area and perimeter of coordinate points in Python

I have a set of points that make up a polygon. I need to find the area and perimeter for the shape in Python. I have used the shapely library to calculate the area and perimeter but it is nonsensical ...
3
votes
1answer
49 views

Meaning of different elements of delivered json-Data-Structure when geocoding with Python and OpenStreetMap

I'm trying to do some geocoding in Python with the library geocoder and OpenStreetMap: import geocoder g = geocoder.osm('11 Wall Street, New York') print(g.json) Where can I get information about the ...

1
3 4
5
6 7
201