Questions tagged [python]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
52 views

Define the extent of QgsRasterCalculator

I have several raster files (.tif) in a folder that have different resolution and extent but are all in the same study area. Before merging them, I want to bring them to the same resolution (5 m) and ...
0
votes
0answers
9 views

LabelImg dark translated images from gdal in python

I have translated some images from Gtiff to PNG with Gdal in Python. When I view the png image in qgis everything is fine. When I import it in LabelImg in order to annotate it and afterwards train a ...
0
votes
1answer
30 views

PyShp cuts the shapefile

I have a .las file and .shp file with polygons. The shapefile looks like follows: For each polygon, I calculated statistics based on elevation data vertices from the .las. Now I want to add fields ...
0
votes
0answers
34 views

How to specify Python Executable file as Interpreter ArcGIS Pro Custom Script Tool

I am converting a stand-alone script to a ArcGIS Pro custom script tool. When I run the script, everything runs according to plan, however I get an error when I run it as a tool. AttributeError: ...
0
votes
1answer
46 views

GTiff to PNG conversion- Gdal Python

I am trying to convert a Gtiff image to PNG using Gdal in python with gdal_translate. My gtiff has the following properties: Width 255 Height 255 Data type Float32 - Thirty two bit floating point ...
0
votes
0answers
18 views

Download Sentinel-2 bands 04 and 08 from AWS S3 of a specific area

I am completely lost. I am trying to figure out where to start. I need to develop a script that generates NDVI values ​​from Sentinel images provided by AWS S3. I've already found solutions for ...
3
votes
1answer
68 views

Is it possible to define a projection for QgsPointXY()

I am creating a QgsRectangle like this: llc = QgsPointXY(319660,4624088) # lower left corner in UTM urc = QgsPointXY(396425,4742843) # upper right corner in UTM aoi = QgsRectangle(llc,urc) ...
0
votes
0answers
22 views

How to polygonize multi-band rasters to vectors with multiple attributes?

I'm using Python, and I usually polygonize rasters using rasterio like in this thread : How to polygonize raster to shapely polygons However, now face a new problem, I have two rasters with same ...
1
vote
0answers
12 views

Attribute/dimension adding to the lasfile

.LAS files have different dimensions as x, y, z, etc. Suppose, I want to add another dimension with the name "n". How to do it correctly? I attempted to use the following pdal pipeline: ...
1
vote
0answers
23 views

Trimming polygon based on its intersection with another polygon using shapely [closed]

I have two polygons intersecting with one another (x1 and x2). How can i trim x2 by the area it intersects with x1, such that x1 and x2 no longer overlap and x1 area/shape remains constant. from ...
0
votes
1answer
66 views

Unable to rasterize polygons with rasterio in python (ValueError: Sequences of multi-polygons are not valid arguments)

I am trying to take a polygons shapefile, loop through all the polygons/rows, and rasterize each one, where each raster file output rasterizes its associated polygon as if it were isolated (the only ...
2
votes
1answer
44 views

Converting pointcloud data in UTM in txt to LAS

I have text file with point cloud data in UTM format, say sample=[632535.222, 4858488.332, 150.555] I am currently using laspy, the parsing from txt is ready, and I plan to generate a new las file ...
2
votes
1answer
47 views

Using geocube in Python to rasterize each polygon in shapefile

I have a shapefile of polygons that I brought into Python in Jupyter Notebook via GeoPandas as a geodataframe. There are hundreds of polygons in this shapefile, and I want to create an individual ...
0
votes
1answer
31 views

When using Fiona, DBF missing headers when no records provided

I'm creating a Esri Shapefile using Fiona. If I don't add any records, the dbf created by Fiona does not include the headers defined by the schema. My customers claim that results in an invalid ...
0
votes
1answer
38 views

Setting multiple GDAL environment variables when installing multiple versions

I have set up GDAL v1.1.1 32bit to work with Python 2.7.18 32bit on windows 10 and everything including the bindings are working fine. Now I have found out that on this version of gdal it is not ...
1
vote
1answer
40 views

Geopandas buffering successfully created buffers but deleted all attribute data

I am trying to use Python and GeoPandas to create variable distance buffers for a polygons shapefile I have. I brought this shapefile into python using GeoPandas. One of the columns of the ...
0
votes
1answer
19 views

Merging rasters in specified order using GDAL

Assume we have a raster file of the entire globe that has origin on Greenwich. What I'd like to achieve is to have a custom representations of map with different points being in the center. Something ...
0
votes
0answers
25 views

Fiona schema property name length

Is it possible to increase property name length in schema? If I define schema like this: my_schema = { 'geometry': 'Point', 'properties': {'Here is very long property name': 'float:12.3'} And in ...
0
votes
1answer
51 views

gdal_calc in python without gdal path

I have the below python script which executes my raster calculation perfectly using GDAL. However, I was wondering if there is a way to use gdal_calc without the path to gdal? gdal_path = r'"C:/...
1
vote
1answer
41 views

Changing GeoJSON key name

I have a multi-level GeoJSON file and I need to create a new geometry field within it that is a copy of the old geometry field but with a different key name. The new geometry field would exist in the ...
0
votes
1answer
64 views

Point inside the polygon

I'm working in Python with a .las file which I open with laspy and a .shp file which I open with the shapefile library. I have multiple polygons in the shapefile and the task is for each polygon to ...
1
vote
0answers
16 views

Identifying missclassified pixels in random forest classifier python sklearn

I have a dataframe that contains 10 predictors (PCA from Landsat Data). The data is loaded as pandas dataframe and it contains in addition to predictors, also x_coor and y_coor information for every ...
1
vote
1answer
37 views

Efficient VRT GeoTIFF image stack reading

My aim is to read time series with Python from a stack of spatially aligned GeoTIFF files as efficient as possible. The time series is not only limited to one pixel, but can also relate to a certain ...
1
vote
0answers
36 views

Finding distance from point to closest LineString given multiple LineStrings efficiently using Python

I have a dataset with many Points and I also have a GeoJSON file consisting of road networks using LineStrings. I want to estimate traffic by seeing which roads have the largest points on or beside ...
1
vote
1answer
138 views

Rasterio mask doesn't work with shapely polygon

I have raster which I want to mask with shapely polygon.According the rasterio documentation, rasterio.mask can work with shapely geometry.However, in this case, it doesn't work. whenever I use my ...
0
votes
1answer
159 views

GDAL 3.4.0 not working with Python (error: USE_PATH_FOR_GDAL_PYTHON=YES)

I am trying to run gdal in python using a script like this: import os gdal_path = r'"C:/Program Files/QGIS 3.22.1/apps/Python39/Scripts"' gdal_calc_path = os.path.join(gdal_path, 'gdal_calc....
0
votes
0answers
16 views

Write to a LAS file does not work using lasio

I have a .las file that I am opening using lasio.read('filename.las'). I need to set the negative values for STRT (start depth) to 0, which I can successfully view that I have set it to 0. But when I ...
0
votes
0answers
139 views

Unable to import python Rasterio package even though it is installed

I am trying to use the python package Rasterio for raster analysis within Jupyter Notebook. However, when I run import rasterio I receive the following error: ImportError ...
5
votes
3answers
312 views

Converting polygon to list of coordinates with shapely

I received a code, that expects a list of coordinates such as this as input area_polygon = [{'lat': 46.037286, 'lng': 14.471329}, {'lat': 46.036733, 'lng': 14.467378}, {...
0
votes
0answers
16 views

How to generate shapely.geomtery.polygon from GTFS feed

I want to generate a graph using osmnx.graph.graph_from_polygon method. It requires a shapely.geometry.polygon as an input. Using GTFS Feed, is it possible to generate the polygon. I am aware, it can ...
1
vote
1answer
34 views

Get the sum of an attribute within a set radius for each row using GeoPandas

I have grid map that contains cells. Each cell is represented as a row in the dataframe, and each row contains the average population "pop" attribute. What I need is that for each of these ...
1
vote
0answers
38 views

Why count() doesn't work but size() does in Pandas? [closed]

I have a point and a polygon data and in this line I'm simply making a spatial join and group its output to count incidents per area. Currently this line works but I don't understand why it works. I ...
3
votes
1answer
35 views

GeoPandas gaps after dissolve

I have a GeoDataFrame and I use dissolve to remove polygon boundaries. forests_dis = forests.dissolve(by='Forest').explode() But there are gaps in the output (black lines). If I zoom a lot, then I ...
5
votes
3answers
304 views

How to create variable distance buffers around polygons in Python

I have a shapefile of polygons and I would like to create buffers around the edges of each polygon. However, rather than use a single buffer distance for all of the polygons, I am trying to find a way ...
0
votes
0answers
25 views

Gdal grid command line vs Python API

I'm trying to interpolate a considerably large set of points(.shp) using using gdal grid IDW. No problems at all using QGIS or the following Gdal command line: gdal_grid -l teste_b -zfield vlr_elemen -...
-1
votes
1answer
49 views

Importing libraries in JupyterNotebook

import solaris as sol from solaris.data import data_dir import os import json I already installed solaris: git clone https://github.com/cosmiq/solaris.git cd solaris git checkout [branch_name] conda ...
0
votes
1answer
155 views

Converting LAZ to LAS using laspy

I would like to convert .laz file to .las. I am using Python and I have installed laspy with lazrs extension. I tried in Pyscripter (v4.0) following solution (this solution was mentioned here: Reading ...
2
votes
1answer
34 views

OGR create polygon giving four corners from raster pixel position

How do I create a geometry from pixels positions in GeoTiff? ds = gdal.Open("image.tif") myarray = np.array(ds.GetRasterBand(1).ReadAsArray()) shape = ogr.Geometry(ogr.wkbLinearRing) And ...
0
votes
1answer
55 views

How to extract the boundaries of Shapely MultiPoint? [closed]

I have a shapely MultiPoint object but need to extract the boundaries into a Polygon object. I'm currently using the convex_hull of the MultiPoint object but my MultiPoint sets can have sharp inward ...
0
votes
0answers
37 views

OGR Python created polygon from lon and lat instead of pixel position

I got a raster in WGS84 UTM zone 34N (EPSG:32634). And I am creating a polygon that represents the raster extent like this: import ogr import gdal raster = gdal.Open(tif) transform = raster....
0
votes
1answer
29 views

Sum of values in raster

Upon importing a raster file, how can I get the sum of all values given in the raster file? import rioxarray as rxr raster= rxr.open_rasterio( 'raster.tif', masked=True ).squeeze() ...
2
votes
1answer
38 views

Upgrading pip on QGIS 3.16

I'm trying to run the Aequilibrae package on QGIS 3.16.14 (on windows)and to do so, it seems that I need to update my pip package. I tried the command : -m pip install --upgrade pip on the integrated ...
0
votes
1answer
91 views

How to apply GDAL polygonize?

I am desperately trying to vectorize raster files in a loop for which I came across GDAL's polygonize function (https://gdal.org/programs/gdal_polygonize.html). However, I don't get the hang of it. To ...
1
vote
1answer
38 views

How to rasterize polygons using GDAL commands in python?

I have the following polygons shapefile consisting of polygons of the five boroughs of New York City from "NYC Open Data", linked here: https://data.cityofnewyork.us/City-Government/Borough-...
0
votes
0answers
31 views

Export TMS raster layer to file

I want to write plugin to clip and export TMS raster layer with selected zoom level and world-file by map extent or vector mask. Wile I learn a possible ways, I found an old question: Export raster ...
3
votes
1answer
38 views

Assign values from one column to another conditionally using GeoPandas

I'm having trouble creating an if else loop to update a certain column in my GeoDataFrame. Here I group by and summarize point counts per zone from points feature class to polygon feature class and I ...
2
votes
3answers
162 views

Rasterizing polygons in shapefile using GDAL

I have the following polygons shapefile consisting of polygons of the five boroughs of New York City from "NYC Open Data", linked here: https://data.cityofnewyork.us/City-Government/Borough-...
3
votes
2answers
93 views

pygeoda - LISA for round polygon

I have just started to use pygeoda package and I have tried to calculate LISA . I had originally raster which I polygonized to have polygon for each pixel: I have applied MORAN I and LISA on the ...
0
votes
1answer
39 views

How to polygonize NDVI raster using GDAL?

I have raster with NDVI values. I would like to polygonize the raster to get vector where each polygon is a pixel. I have tried gdal.Polygonize as described in the documentation and that runs without ...
-1
votes
1answer
50 views

Seeking Python support for WMTS 1.0.0

I am trying to access a WMTS server what only supports version 1.0.0. With OWSlib 0.25 I get: from owslib.wms import WebMapService base_url= 'https://cyanoalert.brockmann-consult.com/api/latest/' wms ...