Questions tagged [python]
Python is an open source interpreted programming language used in many GIS programs.
11,840
questions
0
votes
0
answers
6
views
Finding a common point with ArcGIS Rest Api
I perform trace operation with ArcGIS Rest Service using Python in the Geographic Information System I use for the electricity network, as a result of this process, I can find which transformers a ...
0
votes
2
answers
39
views
Efficiently removing smaller polygon of overlapping multipolygons [closed]
I have a geodataframe containing around 5000 shapely mutipolygons. Each of these multipolygons contains 2-10 polygons. Some polygons overlap with polygons of other multipolygons.
gdf = geopandas....
0
votes
0
answers
28
views
How to get all what3words address present inside of polygon [closed]
When have on default polygon showed on Google map and we display the what3words grid on a Google Map. Now we want to get all w3w addresses inside the polygon.
Code and image below
<!DOCTYPE html&...
0
votes
0
answers
22
views
Using the Arctic SDI WMTS with cartopy and matplotlib
I am trying to use the Arctic SDI topographic basemap (https://arctic-sdi.org/services/topografic-basemap/) with cartopy + matplotlib in python, but seemingly without success. It seems that for some ...
0
votes
0
answers
32
views
QGIS generate grid that aligns with landsat pixels
I would like to generate a grid that aligns with Landsat pixel boundaries.
I am happy to do this with Python, QGIS, or commandline tools.
Is it possible to generate one grid that aligns with all ...
0
votes
1
answer
18
views
Copying CRS from input file for writing to output file in Python without GDAL library
I'm using Python to process rasters that have a CRS. I want to copy the CRS to the raster that is produced.
The rasters are like the following. Sorry, I don't know how to create this from scratch, ...
0
votes
1
answer
23
views
Field Calculator If Statement
I am new to python and was trying to populate a decade field based on an if else statement on another field that contains parcel years.
The code block is below:
def ifBlock(Parcel_Year_Built, ...
1
vote
1
answer
25
views
Differences in raster statistics using gdal and gdalinfo
I want to know the basic stats (max, min, mean, std) of my raster file. I use two different methods and get similar, but different results. I assume the results should be exactly the same with any ...
1
vote
1
answer
55
views
Create multiband raster in Python from X, Y
How do you create a multiband raster in Python and save it as a .tif file from a long dataframe format?
import pandas as pd
import numpy as np
from rasterio.crs import CRS
import rasterio
from ...
0
votes
0
answers
13
views
matrixSolve cannot solve underdetermined system. (Error code: 3)
I'm working with GEE in Python, processing Sentinel 1. After apply Savitzky-Golay filter, like it is applying in this answer writing by Kerste ( https://gis.stackexchange.com/questions/321082/gee-...
0
votes
1
answer
37
views
Maximum number of attempts (200) reached - Python Planet API - Order and Download a request
I want to download some data from Planet using its Python API. I follow the following tutorial planet-sdk-for-python-v2.readthedocs.io/en/latest/python/sdk-guide/#create-an-order-request
I have done ...
0
votes
0
answers
24
views
Issue in my query to filter for only roads and highways using osmosis/osmfilter in my OSM file?
I wnat to extract all the road types and speed limits from the OSM file for the US. I started with a small subset (Delaware OSM), and I ran the following query to try to get rid of unnecessary ...
0
votes
1
answer
30
views
Raster calculate in Python [closed]
I have a shapefile and raster data. I want to calculate the sum of pixels value of each polygon in my shapefile using Python then save the results to MS Excel.
For example: My shapefile has 100 ...
-1
votes
0
answers
16
views
Python opensource project that can convert .3ds into .osgb [closed]
Is it possible to use Python to convert the OSGB into 3DS or from 3DS to OSGB?
0
votes
1
answer
38
views
rasterstats zonal_statistics returns values that aren't present in passed array
I'm truly stumped on why I'm getting incorrect results with zonal_statistics. I'm passing a geometry and the raster in the normal fashion that's worked for me before, with 'data' as the raster and '...
3
votes
1
answer
96
views
From Geodataframe to PostGIS
I have a geodataframe which I am trying to save to a postgis database.
I have already created a connection to postgis in pgAdmin (username, password, localhost and table)
from geoalchemy2 import ...
0
votes
0
answers
26
views
Eliminate black border around nodata/alpha of GeoTIFF converted by rasterio
I have an image (png) that I want to place on a map:
I use rasterio to georeference the picture:
import rasterio as rio
import warnings
from pathlib import Path
from typing import Tuple
from rasterio....
0
votes
0
answers
20
views
Warp result of GDAL translate jpg to geotiff using osgeo.gdal
I am attempting to warp a geotiff created from gdal.Translate where the original file was a jpg. I first obtain the ground control points from a co-located text file. The results of gdal.Translate ...
0
votes
0
answers
29
views
Minimizing road disturbance in orthophotos for road survey using Agisoft Python API [closed]
I've successfully generated orthophoto maps for a road survey project using the Agisoft Python API. However, I've noticed that some areas of the road in the orthophotos appear to be disturbed or ...
1
vote
1
answer
32
views
Convert KML to GeoTIFF with Python (osgeo.gdal)
I have a KML file provided by a user that looks like:
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://...
0
votes
1
answer
62
views
Converting Orthomosaic TIF Image to COG (Cloud-Optimized Geo-TIFF) [closed]
I have successfully generated an orthomosaic TIF image from a road survey consisting of approximately 1200 images. These images are all located along a single line, reflecting the nature of a road ...
-1
votes
0
answers
38
views
Optimizing SQLite3 database search using a search envelope (minx/miny/maxx/maxy)
I've created an SQLite3 database with the following table:
table = """ CREATE TABLE bounds (
value varchar(255) not null,
minx float,
...
1
vote
1
answer
42
views
GeoPandas data types from PostGIS are always string
I am using GeoPandas from_postgis function to read data from PostGIS. However, the data types of the GeoPandas columns are always object.
Data I store in PostGIS is mixture of text/char, bool, integer ...
0
votes
0
answers
15
views
Problems with dissolved shapefiles in Google Earth Engine
I created a single dissolved polygon shapefile out of a set of smaller polygons in ArcGIS and imported it into Google Earth Engine using geemap (Python API). I wanted to extract values from every ...
-1
votes
0
answers
34
views
Extracting ridgelines from DEM using Python 3 without using any ArcGIS-related products like ArcPy [closed]
How do I extract ridgelines from a DEM of type "tif" using Python 3?
I am looking for algorithms for doing this task without the use of any ArcGIS-related products.
0
votes
0
answers
21
views
Generate and populate a grid from points in a geopandas dataframe [duplicate]
Context:
I have a geopandas dataframe, with two columns
'geometry': full of shapely.geometry.point.Point.
'h_mean': gathering the height of a surface at those points
I want to create a 2D spatial ...
0
votes
0
answers
12
views
QGIS loads NetCDF data offset from map
I have a standard NetCDF file with sea surface temperatures, with longitude values ranging from 0 to 360°. When I load it in QGIS, the right half of the data is plotted off the map of the projection ...
0
votes
0
answers
39
views
Error installing pyproj
I am getting the following error when attempting to install geopandas:
[~]$ pip3.9 install pyproj
Collecting pyproj
Using cached pyproj-3.6.0.tar.gz (224 kB)
Installing build dependencies ... done
...
0
votes
0
answers
29
views
Launch QGIS using a batch file
I am very new to QGIS and Python 3. I have QGIS 3.32.1 installed and Python 11. I do not have the OSGEO4W version. My QGIS sits in the Program files directory (C:\Program Files\QGIS 3.32.1).
This is ...
-1
votes
0
answers
26
views
Better solution for simplification of shape polygon with python than GRASS [closed]
I want to simplify a shape containing several adjacent polygons. There are a lot of solutions there to do it, but I found GRASS is the only one that preserves topology and keeps adjacent polygons ...
0
votes
0
answers
23
views
Using outside Python framework (ObsPy) in QGIS API (PyQGIS) [duplicate]
I would like to use ObsPy, a seismology framework for Python available at https://github.com/obspy within the QGIS Python API.
I have been able to use ObsPy to plot moment tensor solutions in an ...
0
votes
0
answers
35
views
Interpreting EPSG:4326 coordinates in a .tif file for a DEM
I am working on a piece of algorithm where I need to have access to ground altitude values from a digital elevation model. The model that I am using is SRTM1, which I access to by using the elevation ...
0
votes
0
answers
34
views
QGIS 3.32 / PyQGIS / Python - insert data-driven vector PDF as first page of each atlas feature
I have a complex atlas with irregular number of pages for each feature (from 2 to 30 pages). I need to display a complex vector in full page as first page of each feature, but QGIS composer can only ...
0
votes
0
answers
12
views
No-Data in clipping .vrt file with GDAL
I am facing some problems while clipping the raster file with the polygon shapefile.
I have 8 GeoTIFFs with different projections (different UTM Zones). My aim is to clip these rasters to the extent ...
0
votes
0
answers
22
views
Importing fmeobjects module into python script
I've tried doing doing what this post suggests but still get errors.
This code:
import sys
sys.path.append(r"C:\\Program Files\\FME\\fmeobjects\\python37")
sys.path.append(r"C:\\...
0
votes
0
answers
14
views
Change a shapefile with grids to a 2D grid world for RL
I have a shapefile with multiple grids as polygons. I want to convert this into a 2D gridworld so that I can train an RL agent. I tried different libraries but I am stuck in the part of brain storming....
0
votes
0
answers
12
views
Barplot with a basemap as a background
I have some data as a pandas DataFrame with values associated with longitude. I have plotted it as stacked bars like this:
A subset of the data as an example via df.to_dict():
{'Commodity driven ...
0
votes
0
answers
21
views
Error in projecting a shapefile from CRS of ArcMap to a Proj4 string
I am trying to export the outputs of the National Water Model (https://github.com/NOAA-Big-Data-Program/bdp-data-docs/blob/main/nwm/README.md) inside of a basin using Python.
With this code I called ...
1
vote
1
answer
37
views
Warning message when doing spatial join nearest neighbor on GeoPandas
I am trying a nearest neighbor spatial join with two point Geodataframes but a warning message is appearing.
My code:
import geopandas as gpd
yield_2013=gpd.read_file('https://github.com/kevinkuranyi/...
2
votes
1
answer
141
views
How to write PNG file from a raster using rasterio?
I have an image, which has 3 bands (RGB). I stack the image using numpy and try to write it as PNG. But I'm confused with how to work with the resulting image indexes.
import rasterio
import numpy as ...
1
vote
0
answers
54
views
How to rotate folium CustomIcon
I have dataframe; it has name, latitudes, longitudes and heading.
Heading value will between 0 and 360. According to the angle we need to rotate.
I printed my dataframe items inside folium map in ...
1
vote
1
answer
26
views
Raster is being saved with no bands names despite defining them using Rasterio
I have an ndarray which I would like to save as rasterio raster.
I have all the information I needed (image size, transform, band names etc.).
The problem is that when I try to save the image as ...
0
votes
1
answer
22
views
Set Operation `intersection` and return only one gdf
I would like to find all polygons that intersect and return the original polygons; not the intersection. Lets go with the set operation example
from shapely.geometry import Polygon
polys1 = geopandas....
1
vote
1
answer
38
views
How to get information of raster in rasterio similar to gdal?
I would like to print the raster statistics from its header. This can be done in gdal using the commands.
gdalinfo dataset.tif
or in Python bindings
src = gdal.Open('dataset.tif')
info = gdal.Info(...
0
votes
0
answers
29
views
Field missing from 'Quick Field Calculation Bar' in attribute table QGIS
I work with PostgreSQL data, but when I want to calculate the data fields in the attribute table, I can't. I tried but some fields are hidden. How can I show all data fields for calculation?
image 1. ...
0
votes
0
answers
66
views
Dissolve lines that intersect after attending some dataframe (atributte table) conditions
I need to dissolve all Linestrings from a geodataframe that intersects each other after attending some tabular conditions: 1)have the same ID and 2) have the same opening year.
I am working with ...
2
votes
2
answers
31
views
Find the length of linestring shared between polygons
I would like to find the common area between my polygons, in this example my polygons touch and share a line
df = GeoDataFrame.from_file('path')
df
...
-1
votes
0
answers
32
views
Rasterization percentile of LiDAR file in open source
I am trying to rasterize several LAS files inside a Python loop. The output that I am attempting to achieve is a percentile of the distribution of normalized heights within each cell of the raster.
...
0
votes
0
answers
15
views
Missing Pixel or Grid Value in the output while Calculating Standard Precipitation Index (SPI) using climate_indices library in Python
I am using NetCDF Gridded dataset of IMD Rainfall (NetCDF can be downloaded from here), for calculating the Standard Precipitation Index (SPI), using climate_indices library of Python
I have changed ...
0
votes
1
answer
17
views
EEException: Image.bandNames: Parameter 'image' is required
I am trying to compute the NDVI index using the MODIS Landset in Python and to visualize it in a time series chart, but I am facing an error and I cannot understand where is the problem. This is my ...