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
16 views

clip raster by a space series layer using Python [closed]

I have 316 polygons, rectangular, split from a fishnet. All the 316 polygons need to be masked from the same raster layer. All the files are in the same reference system. I was wondering can I use ...
0
votes
0answers
21 views

Computing fractions of different strata within a polygon from raster [closed]

I have a single band raster with 13 different land-cover classes. I also have a grid shapefile with 10x10km cells covering the raster. Within each cell of the grid, I want to compute the fractions of ...
0
votes
1answer
31 views

Inaccurate georeferencing when plotting raster files using rasterio

I am trying to develop a plot of a raster image with a background map. I used rasterio for reading the raster file and contextily for obtaining the background map following this tutorial. The plotted ...
1
vote
1answer
39 views

Write numpy ndarray as TIFF with rasterio does not work

I have ndarray with shape of (12, 773, 1231) ((12 bands)). I want to save it as array in order to reproject it. I have image with the same shape and image but reprojected so I baiscally want my ...
0
votes
1answer
41 views

How to create a GeoPandas GeoDataFrame from rasterio features?

I try to create a GeoDataFrame of paches of same values in a binary raster using rasterio and GeoPandas. data_file is a binary TIFF raster with 0 where there is no deforestation and 1 if there is a ...
0
votes
1answer
23 views

Python Class Variables different on each import [closed]

I've got a confusing issue with a python class variable. It's part of a multi-process RPC Object proxy, I'd be happy to share the entire solution later. It passes back and forth full python objects/...
0
votes
3answers
78 views

How to determine left and right side of crossing lines?

Given two lines of which we know the starting XY points and intersecting point, I need to find which line is left and which line is right. The lines are always crossing and can be turned in any ...
1
vote
1answer
31 views

How to override shapefile geometry type in OGR

I'm new to ogr. I tried to copy a WFS layer to shapefile using CopyLayer but I get this error. ERROR 6: Geometry type of `Multi Curve' not supported in shapefiles. Type can be overridden with a layer ...
1
vote
2answers
40 views

Masking a NetCDF file using a shapefile of points with rioxarray

I took the proposed solution from this question (How to mask NetCDF time series data from a shapefile in Python?) and tried to implement it. However, whenever I apply this solution it seems to set all ...
1
vote
0answers
9 views

How to load a module in earthengine Python API?

I want to translate an analysis JavaScript file from JS to Python. It starts with the loading of a module : var temporalSegmentation = require('users/wiell/temporalSegmentation:temporalSegmentation') /...
0
votes
0answers
21 views

QGIS3.x using processing algorithms outside of python console (when writing a plugin)

For a school assignment I need to write a QGIS plugin. Part of the plugin that i'm writing needs to use the 'select by location' processing tool on a previously created buffer. The codelines that I ...
1
vote
0answers
16 views

Plotting city locations on Python 3 [closed]

My question is a follow-up of this: plotting US cities on a map with matplotlib and basemap. I would like to use some Python library to plot on a map city locations, starting from a list like this: ...
0
votes
0answers
20 views

Creating shapefile using GDAL OGR? Script runs but does not create the files

This script runs but does not create the shapefile files. It works, however, if I were to replace the driver for GeoJSON and create a GeoJSON file. Context: I'm working through Chris Garrard's "...
2
votes
1answer
56 views

What is the algorithm that Shapely used to check if two polygons intersect?

What is the algorithm that Shapely used to check if two polygons intersect? from shapely.geometry import Polygon p1 = Polygon([(0,0), (3,0), (3,1), (1,1), (1,2), (3,2), (3,3), (0,3)]) p2 = Polygon([(4,...
0
votes
0answers
27 views

Reading some NOMADS grib files fails

I am trying to read in a file from https://nomads.ncep.noaa.gov I can read all multigrid files like here but my script fails to read files from other links that are supposed to be Grib files such as ...
0
votes
0answers
19 views

Is there a way to detect the status of the Esri world imagery basemap service programmatically prior to opening an MXD?

We have a web application that programmatically exports an MXD to a PDF. In this MXD, we have Esri's world imagery service added in one of the dataframes. However, when the imagery service is down ...
-2
votes
0answers
24 views

Add a dot in Latitude field

I am cleaning a dataset, in which i found many latitude values without dot. I know that all of them are missing the dot after the first number, and i would like to add it through python. Example: lat ...
1
vote
1answer
13 views

Rasterio symbology

I am having a problem with a raster dataset. I am trying to use a symbology for a continuous raster type but the result is as shown in the image. The code is: import os import numpy as np import ...
1
vote
1answer
114 views

QGIS Linux: qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found

I would like to run code in Linux without GUI. I'm getting some error. How should i solve that? >>> qgs = QgsApplication([], False) QFactoryLoader::QFactoryLoader() checking directory path &...
1
vote
1answer
29 views

Using gdal.Warp() on netCDF file. Simple case fails

I'm using the python API to GDAL to try to do a simple geographic warp of a netCDF4 satellite file to a small sub region. My python program fails to produce any output but does not throw any ...
0
votes
0answers
8 views

QGIS Database Manager - 'Not connected' error on MacOS

Mac OS 10.12.6 3.10.11-A Coruña I have connected to a Spatialite .sqlite file in the Data Source Manager, but when I try to import the contents in the Database Manager, I get an 'Not connected' error ...
0
votes
0answers
26 views

How to rotate orthographic projection using basemap

I'm working with the python basemap library and am plotting data over Greenland using an orthographic projection. However I find that due to the location of the coordinates, basemap auto plots the ...
2
votes
1answer
132 views

Georeferencing of PNG and Convert to TIFF using Python

I have a PNG image which I am trying to georeference using four corners of coordinate information of the defined input image. When I am trying to convert PNG to TIFF, I am getting 3 bands (R,G,B) ...
0
votes
0answers
26 views

QuickOSM error occurred in executing Python Code

So I'm trying to download a dataset using QuickOSM, and I keep getting the same error over and over again. I thought at first the selection size was too big, but making it smaller didn't fix it. I ...
0
votes
1answer
29 views

Using “raster.transform” function of “rasterio” in Python

When I execute the "raster.transform" function in Python it returns me a matrix. What I can understand is that it tells me my data has a 10 m pixel resolution, It also tells me that my left ...
2
votes
2answers
67 views

Get state but want country in GeoPy and Nominatim

I use the geopy library in Python to find the location of countries. I use country names as input, like: geolocator = Nominatim(user_agent="anonymous@gmail.com") geolocator.geocode(&...
2
votes
0answers
15 views

Get field list of input layer using @alg decorator

I'd like to write a simple algorithm to sum up a numeric column in an input vector layer. I can't connect the FIELD input to the SOURCE layer. I tried to add 'parent' parameter but it is unknown ...
0
votes
0answers
37 views

Classifying a GeoJSON LineString type file based on Strahler Order with Python

I am working on a Python project working with a GeoJSON file (Linestring type). The aim of this project is to classify lines based on Strahler Order (Wikipedia : https://en.wikipedia.org/wiki/...
2
votes
0answers
37 views

Adding support to FileGDB driver when fiona/gdal/osgeo were installed through Anaconda

Is there a way to tweak the fiona/gdal/osgeo packages installed through Anaconda so that they can be used to read/write GDB files using the ESRI FileGDB driver? I have found multiple answers online, ...
1
vote
0answers
18 views

GeoPackage Lookup Tables

What is the best practice for creating and maintaining lookup tables in a GeoPackage? I am writing Python using OGR to create and write a single vector layer in a GeoPackage. Some of the feature ...
0
votes
0answers
15 views

Python API For Generating GeoJSON or WKT From Interactive Map

I am looking for a Python API for generating GeoJSON or WKT interactively using a GUI based map interface. I have fun some website where one can generate the WKT polygon using by drawing a polygon ...
0
votes
0answers
67 views

Removing duplicate points in GeoPandas using distance and time

I have a list of of coordinates that have areas mapped out on a map user_id id latitude longitude requested_at 84 106 13.0472367 77.5022635 12-10-2020 14:59 84 107 13.0472789 77.5024498 ...
0
votes
2answers
43 views

How to substring a number out of a string field using Python field calculator in ArcGIS? [duplicate]

Using ArcGIS Desktop 10.7 I want to substring numbers as text out of a string field into a new string field with field calculator so that I can use them for layer symbology. The field contains highway ...
1
vote
0answers
17 views

GDAL - Command Line vs. Spyder (Python) Functionality

I am trying to retrieve information from a GeoTiff using the GDAL API in Python (Spyder). Within Anaconda I have my base environment which contains gdal v2.3.3, but I also created a virtual ...
0
votes
1answer
35 views

Contextily add_basemap uses wrong extent and zoom level

I'm trying to add a contextily basemap to a Matplotlib figure containing a GeoPandas data frame. When I just plot the data frame using df.plot the map extent is calculated correctly. However, when I ...
1
vote
1answer
65 views

Find points in the same direction

Given a vector of two points with direction from point 1 to point 2: latitude_1 longitud_1 latitude_2 longitud_2 41.378118 2.169557 41.389474 2.156421 Find points in the dataset that are in ...
2
votes
1answer
44 views

GeoPandas won't read PostGIS Polygon Table

I want to read my data on postgis using geopandas but it won't read. It works on Linestring data, but not on Polygon. When I open the postgis data using QGIS and it works fine, the polygon reads good. ...
1
vote
1answer
68 views

Determining the Unit of Spatial Resolution of a raster image in Python

I have some raster images, and I would like to determine the GSD using Python. I know that I can use rasterio.transform() or gdal.GetGeoTransform() to extract the spatial resolution of the image. ...
3
votes
1answer
74 views

Adding graticules to Folium map [closed]

Are there any chances to add grid on Folium map? Something like on this picture.
0
votes
0answers
28 views

Symmetrical Difference using fiona and shapely

I have a polygon that I want to merge into an existing polygon. To do this I first need to run symmetrical difference between the two overlapping polygons, and then merge them. Before symmetrical ...
2
votes
1answer
58 views

Exporting only certain features from Attribute Table into CSV

I followed this tutorial to build a plugin and finished all without any problems. (the plugin's function is exporting attribute table to csv file) https://www.qgistutorials.com/en/docs/3/...
0
votes
1answer
34 views

Is geonames.org legit? [closed]

I recently was looking for the long/lat data on several different U.S. zip codes (several thousand) and came across this website made a while ago called: "geonames.org". I went to the ...
5
votes
1answer
91 views

Defining a Python function to calculate a value using multiple fields

I am using the Calculate Field tool in ArcGIS Pro to get it to calculate fire hydrant flow data. I need data from the table fields PitotPressure, COE, and HydrantOrificeFlowed in an attribute table to ...
3
votes
1answer
33 views

Only integer part of field values read by pyshp when creating point shapefile from QGIS

While using flopy that bases some of the functions in the export.shapefile_utils module on pyshp (namely shp2recarray), I've come across a behavior I cannot understand. Whenever I read some point data ...
3
votes
2answers
65 views

Quick way to get WKT from a GeoDataFrame's geometries in GeoPandas?

Is there a quick way to produce a column/series containing the WKTs of all the geometries in a GeoPandas GeoDataFrame? I got around this using the apply function (see example below), but I just ...
1
vote
0answers
37 views

PyQGIS: problem with parametrs

I would like to select records 0-10 in INPUT. Algorithm works in QGIS Python console, but in cmd I'm getting error: "Could not load source layer for INPUT: C:/Users/ja/Inne/Desktop/budynki/...
0
votes
0answers
19 views

Why does merging from neignboring UTM Zones with rioxarray result into unsharp image?

I am am trying to merge raster files from the Sentinel 2 Constellation (after some processing) with rioxarray for the UTM Zones 32 and 33. It's looking good, execpt when an larger area for example the ...
1
vote
1answer
48 views

Mapping multiple polygons on Folium

I have a list of of coordinates that have areas mapped out on a map Zone zone_name users distinct_users geometry 1 A 635 51 POLYGON ((13.05584728590942 77....
0
votes
0answers
19 views

How to convert large size hyperspectral from tif to lan

I tried to convert hyperspectral from .tif to .lan format. There are three file with size about 1.5GB , 750MB and 200MB respectively. I use this code from osgeo import gdal src_fname = 'file.tif' ...
1
vote
1answer
66 views

How to change the font size of the color bar of a GeoPandas choropleth plot

When I try to use the legend_kwds argument to change the font size of my colorbar, I keep getting this error: TypeError: init() got an unexpected keyword argument 'fontsize' ax = df.plot(figsize=(20,...