Questions tagged [python]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

Preserve coordinates when converting tif image to numpy ndarray

I have satellite image that I want to convert into numy array (and then to pandas). I already know how to do that thanks to Stefan, but th eproblem is that it does not preserve the coordinates data. ...
-1
votes
0answers
15 views

GeoPandas plot range problem

I read a .csv file with geometry like this: trajs = pd.read_csv("trajs.csv") trajs["geom"] = trajs["geom"].apply(wkt.loads) trajs = gpd.GeoDataFrame(trajs, geometry="...
1
vote
0answers
13 views

PyGIS error: proj_create_from_database: Cannot find proj.db

Hello i have problem with QGIS. When i run my code in QGIS Python console it works but when i try in console im getting error. Code: import sys from qgis.core import QgsApplication, ...
0
votes
1answer
10 views

Geojson to Masks

I need to use the geojson file and tiff images to produce masks. Is there a python program that takes geojson file and tiff image as input and produces masks?
0
votes
0answers
12 views

Iteratively polygonize MultiLineString

I have an implementation of alpha-shape below. My goal is to compute the polygons for a list of alphas but do it as fast as possible. LineProfiler showed that almost all of the time is spent in list(...
0
votes
0answers
12 views

Exporting district level precipitation data for series of months using Google Earth Engine Python API

I am trying to export precipitation data for a range of months at the district level of Somalia using GEE's phython api. I'm using the following code #import Somalia district shape file and convert to ...
0
votes
1answer
18 views

Find geographic position of one raster on another raster in GDAL Python

How do I find georeferenced raster2 position on another georeferenced raster1 with GDAL in Python in pixels? For example -10,10 or 200,300 (pixels from 0,0 of raster1 to 0,0 of raster2). Assuming that ...
0
votes
0answers
12 views

Rasterio doesn't show the coordinates when using “imshow ”

I have sentinel 2 image and I use rasterio to display it. I am using "imshow" to display it. when I display it, it doesn't show any coordinates: src=rasterio.open('14072020.tif') #Display ...
1
vote
1answer
8 views

Correcting Worldview-3 data to ground reflection/bottom of atmosphere with open source?

I have some worldview-3 imagery that needs to be corrected from digital numbers to actual reflection values (preferably bottom-of-atmosphere). But the tricky part is I am looking for open source ...
0
votes
0answers
7 views

Problems while importing data from Nominatim

I am parsing some geo-data with the help of Python and requests to Nominatim API and face the problem.There are two screenshots and data on two screenshots is slightly different(notice trimmed area). ...
0
votes
0answers
9 views

Plotting two shapefiles in same plot. Legend of 1st shapefile hidden by second shapefile. Python GeoPandas

With ax = gdf.plot(cmap="jet", column=ColumnaAVisualizar, categorical=True,figsize=(12,12),legend=True) ax2=ZDE.boundary.plot(ls="--",color="k", label="Zona de ...
0
votes
0answers
7 views

WFS layer invalid in standalone python script

I have a project in 3.10.11 (ltr) loading a layer from a Geoscience Australia WFS. http://services.ga.gov.au/gis/services/Geomorphology_Scale_Guide_WM/MapServer/WFSServer In the python plugin console ...
0
votes
0answers
16 views

GDAL GetNoDataValue from HDF5 band

I am opening HDF5 file like this: import gdal hdf_ds = gdal.Open("myhdf.h5", gdal.GA_ReadOnly) band_ds = gdal.Open(hdf_ds.GetSubDatasets()[0][0], gdal.GA_ReadOnly) In documentation it is ...
1
vote
1answer
33 views

PyGIS Error: Algorithm qgis:joinattributesbylocation not found

i would like to join attributes by location but im getting error. Please help me :) I use QGIS 3.16 from qgis.core import * QgsApplication.setPrefixPath("C:/Program Files/QGIS 3.16/apps/qgis&...
0
votes
1answer
20 views

Does OWSLib have spatial filters?

I am trying to apply spatial filter on a WFS layer, but owslib.fes has only BBox spatial filter. Other spatial filters such as Intersects, Disjoint, Contains etc. are missing and unable to find. I ...
0
votes
0answers
21 views

Mosaic multiple 7gb TIFF into one big TIFF

I have data of 10 sets each with 361 channels in format of ENVI. Each set contain: 7gb format-less file (BSQ #UPDATE) 2.4gb .ENP file 9kb .HDR file I try to mosaic all of them in one big file. What ...
0
votes
0answers
33 views

Use core code of QGIS in my own Python scripts

I would like to know if I can use the code of the default functions that come in QGIS, for example the Intersection function. When you click on the help button it redirects you to the user guide where ...
0
votes
1answer
29 views

Raster Images in Python to be ported to Swift in the future

I am working with a grey scale image from a DEM. No matter how much Googling or reading I do I can NOT find a solution for Getting elevation values from a raster images pixels. It should be as simple ...
0
votes
0answers
20 views

Remapping a raster map using GDAL in Python

I have a numpy array of data in Python that is a processed version (outliers set to zero, for example) of data from an Albers Conical United States (US) map: PROJCS["Albers Conical Equal Area&...
3
votes
1answer
33 views

How to Group Parameters in PyQGIS Processing Plugin

The PyQGIS Processing Plugin I'm writing has a lot of parameters, most of which are advanced and won't be necessary for most users. I'm concerned that a user will be confused if they see all these ...
0
votes
0answers
21 views

Merge GPX tracks with PyQGIS / Python

I am having problems with my Python script (completely new to PyQGIS). I want to import all GPX-files from an given directory to QGIS, then change the Geometry type from MultiLineString to LineString (...
0
votes
0answers
15 views

GDAL/Python intersection does not include fields from method layer

As stated in title. I'm intersecting two layers and expecting fields from both input and intersect/method layers in the result. This is the behavior as describe in API docs (https://gdal.org/python/...
0
votes
0answers
9 views

Scale bar for standalone PyQGIS layout clumped together

I'm trying to implement a scalebar for my layout in a standalone application. This is my current code: def createLayout(Main): layers = Main.canvas.layers() project = QgsProject.instance() ...
0
votes
1answer
29 views

Pairing line segments that follow a similar path

I have a shapefile with a regional travel model comprised of straight line features (model.shp, blue in the image). These lines roughly match the actual paths of the roadways they represent (road.shp, ...
1
vote
0answers
34 views

Is there a method to smooth polygons and force all angles to be 90 degrees?

Is there a way to smooth jagged polygons and get nice 90 degree angles like in the image below? Are any algorithms or methods available? I've tried GeoPandas' .simplify() function, which uses the ...
0
votes
1answer
28 views

Keep getting a black tiff when rasterizing a shapefile with GDAL

I have a shapefile that looks like the follows: And here's how the attribute table looks like: I'm trying to rasterize it with a reference raster and my code is as follows: input_vector = ...
1
vote
1answer
21 views

NetCDF get_dims too many values to unpack

I am working with a NetCDF file (.nc) - 600+MB. import netCDF4 from netCDF4 import num2date import numpy as np import os import pandas as pd # Open netCDF4 file file_location = '2m dewpoint ...
2
votes
1answer
23 views

Control histogram axis and legend with show_hist of rasterio

I have load raster (Sentinel 2) with Rasterio and I would like to create histogram of the pixels. The problem is that I beleive the graph gives automatically the X label and also the legend labels. ...
-2
votes
0answers
22 views

Create report using Python [closed]

I have two dataframes which is generating data in this form, now I need to generate report to send this information to user using Python code, how can I generate report using Python script? The way ...
1
vote
1answer
30 views
+50

Rasterio doesn't show the image in RGB

I have download raw landsat 8 image with Rasterio. The image was download from GEE. . The image has 11 bands. I'm trying to display the image with grey scale/color scale as DN values, but for some ...
3
votes
1answer
29 views

Accessing the values in a list in PyQGIS. (print (list[0]) is not working

I have got this code in PyQGIS to to save a selected feature into a variable. class selectTool(QgsMapToolIdentifyFeature): def __init__(self, iface): self.iface = iface self....
-2
votes
0answers
18 views

How do I sum values in a column to each other by sequence? [closed]

Suppose I have a column like this in my data frame (my data frame have 6 columns and 22 lines): a b c 1 2 4 2 3 6 7 8 9 I want to sum the the value numbers in the sequence in the column. For ...
0
votes
0answers
25 views

Rasterio: Issue with `writing a dirty block from GDALRasterBand::IRasterIO` even with `LibTiff` > 4.0 on Windows and Mac, but not Linux

I was hoping someone might have some insights. I am using python rasterio to compress some large GeoTIFF imagery files. By large I mean 2-3 GB compressed, or on the order of 60,000 x 60,000 pixels ...
0
votes
1answer
69 views

Cannot get projection from raster dataset using .GetProjection()

I can't figure out how to get the projection info from a raster file using gdal. I thought my raster had a bad srs so I used a script from # https://gdal.org/tutorials/raster_api_tut.html to create a ...
0
votes
2answers
29 views

Python GeoPandas: fill small gaps between Linestrings in a graph to get only one connected component? [closed]

I have a graph in Python GeoPandas with many connected components. And I want to create a graph with only one connected component. Does there exist some convenience functions to fill the gaps in ...
0
votes
0answers
18 views

How to translate from GeoJSON to GeoDataFrame [duplicate]

I want to convert GeoJSON into a GeoDataFrame, but it doesn't work. GeoJSON is stored in a dictionary variable. If you know of a solution, I would like to know how to solve this problem. This is my ...
0
votes
0answers
18 views

Python GDAL VRT reading using 50% of available memory. How to limit this?

When reading in areas of a VRT with vrt.ReadAsArray(...) I see RAM usage will keep increasing up to about 50%. This is fine but becomes a problem for when running on a computing cluster with huge ...
2
votes
1answer
50 views

Add scale bar to canvas using PyQGIS

Is it possible to get the decorator scale bar onto the map canvas inside a standalone PyQGIS application? It is possible to get a scale bar on the QGIS Desktop version by View -> Decorations -> ...
1
vote
0answers
28 views

Attribute error: 'NoneType' object has no attribute 'GetLayer' geoPDF

I have written some code to export projection information from geoPDF’s. For some reason on some of the files I get the following error and other are fine. AttributeError: 'NoneType' object has no ...
1
vote
0answers
21 views

Download ALL data for an area from OpenStreetMap

I am trying to download ALL the OpenStreetMap data for a certain region. Meaning, I want the roads, the stores, the rivers, the parks, the traffic signals, the bus stops, ... everything. I'm ...
0
votes
0answers
15 views

Model designer issue, QGIS 3.14 on iMAC

I tried to make Model in Model designer but I don't see my new fields in designer window, but only the offer of the existing layers. What's wrong and what did I miss? There is no connection lines.
0
votes
1answer
20 views

Use ST functions in GeoDjango Project

I have a Geo-Django project in which i am using postgres as database. I have a table with geometry column. I am filtering data and getting results which is working fine. Problem is I want the geometry ...
0
votes
1answer
42 views

GeoPandas to DXF [closed]

I have ten geodataframe; I would like to export each one of them to DXF: geodataframes= [gdf1,gfd2,gdf2] for geodataframe in geodataframes: #geodataframe to dxf it would be possible?
-1
votes
1answer
22 views

Maps with Cartoframes outside jupyter [closed]

I use Pycharm as IDE for python. I can not see the visualization of carto within pycharm. This is a problem of configuration or literally to see the maps I MUST use jupyter as IDE?
4
votes
0answers
61 views
+50

How to choose limited number of points to represent a point grid

I need to choose a few points to represent the grid below, e.g: 8 points in the grid below. This point need to be geographic distributed This points needs to be geographic distributed. Lets see a bad ...
1
vote
1answer
22 views

How to visualize a NetCDF Dataset

Suppose I have a rather large NetCDF file that I open as a dataset using xarray. import xarray nc_in = r"....\D_P_WGS84_comp.nc" nc_ds = xarray.open_dataset(nc_in) It is composed of ...
3
votes
0answers
25 views

Finding union of many geodataframes using GeoPandas

I have a series of many GeoPandas Polygon objects, each with an associated exposure time. My goal is to find the union of all the Polygons in order to create an exposure time map. For each Polygon in ...
1
vote
0answers
27 views

Importing processing from QGIS into IDLE

I have been trying to make a program that creates a virtual raster based on the files that are input. Whenever I run my code it says. Traceback (most recent call last): File "C:/Users/Zach/...
0
votes
0answers
31 views

Apply cloud mask to Landsat Imagery in Google Earth Engine Python API and output NAs instead of 0s

I am trying to mask clouds using the python API in Google Earth Engine, but the masked values are exporting as 0s instead of NAs. I am basically following the code here Apply cloud mask to Landsat ...
1
vote
1answer
48 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
2 3 4 5
185