Skip to main content

Questions tagged [bash]

The Bourne-again shell (Bash) is a Bourne shell (sh) implementation with numerous additions. Bash is the default shell in many Linux distributions and on macOS. It is available on most modern operating systems, and has been ported to Windows.

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

Replicating QGIS's mean +/- standard deviation in bash

My raster values range is -82.6999969482/-5.16682815552, so in QGIS I get -44.9364/-23.4497 after applying the mean +/- standard deviation (x 2.00) like here below: How has this been calculated? The ...
Gery's user avatar
  • 2,135
2 votes
1 answer
124 views

Why can ogr2ogr upload data to a not previously existing table faster than to an existing empty one?

Recently I observed that it takes much less time for ogr2ogr to upload data to a PostGIS database if I do not create the destination table first. I would like to understand why this happens. Below is ...
zabop's user avatar
  • 2,214
0 votes
2 answers
89 views

Fatal Error when trying to download addons for GRASS 8.3.1

I get an error with g.extension r.stream.order: ERROR: Failed to get branch from the Git repository <https://github.com/OSGeo/grass-addons/>. fatal: unable to access 'https://...
Nikolay Yasinskiy's user avatar
1 vote
1 answer
232 views

Create a bounding box for a GeoTIFF using GDAL on the commandline

How can I create a bounding box for a GeoTIFF using GDAL on the commandline? I often have a folder of TIFFs that I want to generate GeoJSONs for. I'd rather not make a Python script, since it's a lot ...
nboyko's user avatar
  • 541
1 vote
1 answer
73 views

Calculate mode of multiple rasters using gdal_calc

I have been using following bash script to calculate mode of 18 raster layers. for folder in raster*; do echo $folder output_file=${folder}/$(basename ${folder})_maj.tif ...
coder_001's user avatar
3 votes
1 answer
263 views

ogr2ogr: Make polygon from points

I have a set of points in a csv file like this (ie. a square): -77.63333333;-11.75 -77.63333333;-12.25 -77.3;-12.25 -77.3;-11.75 -77.63333333;-11.75 -77.63333333;-11.75 After getting rid of the semi-...
Gery's user avatar
  • 2,135
2 votes
1 answer
449 views

Create a location for GRASS GIS command without GUI is not understood by GRASS from bash

On CentOs 7.. I installed GRASS by yum install grass So, using this great tutorial: https://xycarto.com/2020/05/03/basic-grass-gis-with-bash/ I try to get started with GRASS. I made a folder ...
Nikolay Yasinskiy's user avatar
1 vote
0 answers
279 views

Pan sharpening using GDAL when pan band is on the same dataset

I have tiff with 5 bands, when the fifth band is the panchromatic band. I want to use the 5th band in order to pan-sharp the image. I have used this tutorial in order to do the process. As I have all ...
ReutKeller's user avatar
  • 2,149
1 vote
1 answer
253 views

How to get feature count of a GeoJSON into a bash variable?

I would like to have the number of features in a GeoJSON loaded into a bash variable. An example GeoJSON, example.geojson: { "type": "FeatureCollection", "features": [ { &...
zabop's user avatar
  • 2,214
0 votes
1 answer
136 views

Convert a layer from WGS 84 to WGS 84 / Pseudo-Mercator during GRASS import

I have a bash script that does the following: export PATH=$PATH:/usr/local/grass/bin GRASSDATA=/output/grassdata && \ MAPSET=PERMANENT && \ MAP=outputAmtrakMap && \ rm -rf $...
Mayor of the Plattenbaus's user avatar
1 vote
1 answer
298 views

Which is the correct way to write commands in GRASS GIS on Windows?

I learnt how to use GRASS GIS from an Ubuntu machine, directly using the command line. I wrote my commands in a text editor (e.g., Notepad++), and I just copied and pasted the lines I was interested ...
LT17's user avatar
  • 303
1 vote
1 answer
2k views

How to fix ogr2ogr: command not found

I am an intern and was told to run this script, but I'm having some problems getting it to work and no one in my department has been able to offer any advice. I am using Windows 10 and running the ...
goatmilkshake's user avatar
2 votes
2 answers
330 views

Merging large number of .shp files via command line with ogrmerge.py

I have a directory containing many (about 100,000) .shp files. I would like to merge them together via the command line using ogrmerge.py like this: $ ogrmerge.py -single -o output.shp *inputs.shp I ...
cmaggiostrong's user avatar
1 vote
1 answer
29 views

i.vi writing null data to output raster on first attempt

I have the following lines of code in a bash script I wrote using osgeo's GRASS command line tools: i.vi viname=ndvi output=$ndvi_fn nir=$nir_fn red=$red_fn --overwrite while r.info $ndvi_fn -r | grep ...
Nick Brady's user avatar
1 vote
1 answer
264 views

Merge ERA5-Land and ERA5 time series

I am merging some ERA5-Land and ERA5 (netCDF) time series: extract individual ERA5 and ERA5-Land maps and apply scale and offset factors -- this by looping the following for BAND in $(seq 1 8784) ;...
Nikos Alexandris's user avatar
1 vote
0 answers
149 views

How to create a "normal" color image from multiband RGB images with GDAL CLI?

I am working on a personal project to automatically pull and process Sentinel 2 data and create viewable images with a bash script. So far I have succeesded with most of the steps but I'm stuck at the ...
Stefan Gofferje's user avatar
3 votes
1 answer
1k views

Importing a CSV inside PostgreSQL with ogr2ogr through a pipe

I can successfully import a CSV file inside PostgreSQL with the following command line: ogr2ogr -f "PostgreSQL" PG:"host=localhost port=5432 user=user password=password dbname=dbname&...
raylight's user avatar
  • 1,153
0 votes
1 answer
212 views

Extract Layer with Wildcard (*) or by Index

In the Geopackage below (in.gpkg) I would like to extract the first layer (i.e. pinios_eudem2_basins) and write it to a new Geopackage (out.gpkg). However I would like to do this not by name, but with ...
andschar's user avatar
  • 1,255
1 vote
0 answers
277 views

Error: free(): invalid pointer displayed when executing ogr2ogr on ubuntu 20.04

Hello I'm getting an error when executing ogr2ogr tool when running bash file: free(): invalid pointer save_maps_to_db.sh: line 5: 301101 Aborted (core dumped) ogr2ogr -f "$format" PG:"...
IBot's user avatar
  • 111
1 vote
1 answer
117 views

Using a bat file to run r.report on large number TIFFs

I need to process a large number of TIFFs or ASC that are also large in size, I was wondering if theres a way to run a bash script to call on r.report from GRASS to get the stats for my rasters and ...
Amrie Singh's user avatar
1 vote
0 answers
327 views

ogr2ogr clip one GeoJSON with another

I'm trying to clip the NYC streets layer using a NYC borough polygon layer. This works: ogr2ogr -clpsrc manhattan-borough.geojson manhattan-streets.geojson nycStreetCenterline-simplified.geojson -...
Matt's user avatar
  • 1,191
6 votes
3 answers
335 views

Renaming shapefile from Terminal

Shapefile comes with a bunch of friends (often referred to as sidecar files) that all need to have the same basename. While software like QGIS deals with that very well I sometimes have the need to ...
Matthias Kuhn's user avatar
4 votes
3 answers
162 views

Merging GRASS GIS calls in Linux bash terminal/scripts

I normally use bash scripts (ie. #!/bin/bash) to include different Linux-based tools (eg. awk, sed, cut), software (eg. GMT, GDAL, SAGA), and even languages (eg. #!/usr/bin/env python). However, so ...
Gery's user avatar
  • 2,135
0 votes
0 answers
472 views

Mapserver - msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation failed

I am trying to use MapServer to load tiles overtop of my Google map. When hitting the endpoint, I am getting the error: msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation ...
Steve Teller's user avatar
0 votes
1 answer
315 views

"no such field as `OGR_GEOMETRY'" when changing Multipolygon to Polygon with altering geometry in shapefile

The attempt is to change from multipolygon to polygon (shapefile) using: ogrinfo tmpem122.shp -sql "alter table tmpem122 alter column OGR_GEOMETRY type geometry(polygon, 4326) using st_geometryn(...
Gery's user avatar
  • 2,135
2 votes
0 answers
96 views

PROJ: proj_create: Error -7: unknown unit conversion id

I am attempting to use a bash script to reproject wrf output using the following: ${gdal} -of GTiff -a_srs '+proj=longlat +datum=WGS84 +ellps=WGS84 +lat_1=30 +lat_2=60 +lat_0=42.1200065612793 +lon_0=-...
Francis Tarasiewcz's user avatar
1 vote
1 answer
2k views

How to write docker-compose.yml after enabling postgis_raster for PostGIS Docker Image

I'm using the docker image of https://github.com/postgis/docker-postgis and it works fine with the commands below which is also defined in README file. docker run --name some-postgis -e ...
Berke Şentürk's user avatar
1 vote
1 answer
305 views

Converting a single shapefile with multiple features into independent GeoJSON files using ogr2ogr

Let's say there's a single shapefile that contains multiple features. Most of which are polygons. How can one convert those features into separate independent GeoJSON files? Can this be done with ...
Abel Melquiades Callejo's user avatar
2 votes
0 answers
113 views

How to aggregate multiple NC files into gridded data

I would like to convert daily total NO2 column data into an aggregate form similar to the monthly mean tropospheric NO2 columns on said website in order to later extract statistics using shapefile(s), ...
Nicholas L's user avatar
2 votes
1 answer
255 views

Convex hull that follows irregular points distribution

Based on an irregular distribution of points (longitude,latitude), I obtained the convex hull below (I use saga_cmd with polygon convexity in 1). Would you have a way to create a convex hull that ...
Gery's user avatar
  • 2,135
0 votes
0 answers
82 views

Calling GDALGetRasterHistogram( ) from R

I need to calculate a histogram (pixel-count by each unique value, actually) for more than 256 values , the default number of buckets in gdalinfo. I understand that GDALGetRasterHistogram can deal ...
gonzalez.ivan90's user avatar
2 votes
1 answer
712 views

Recursively find all GeoTIFF in current and subfolders and clip using GDAL

I have thousand of GeoTIFF file in subfolders, and I would like to crop all of them using shapefile and save in a Crop folder. My working directory is: /Data/2000/image_20000101.tif /Data/2000/...
user97103's user avatar
  • 537
6 votes
1 answer
1k views

Adding file info using ogrinfo -sql UPDATE expression

I try to add the filename with the tool ogrinfo in a bunch of shape files for later merging reasons under Debian 8 and gdal 2.4.0. I stuck by expressing a valid statement for UPDATE part. For the ...
huckfinn's user avatar
  • 3,593
1 vote
0 answers
202 views

GDAL or rasterio to find minimum extent of multple files in command line

I have two files, GeoTIFFs (.tif) in this case which need to be cropped to each other's minimum overlap, and have matching spatial resolutions. I also want to round their Pixel Size to a whole number (...
NW_Photo_Laureate's user avatar
2 votes
2 answers
2k views

Convert a tab (Mapinfo) file to ESRI Shapefile with ogr2ogr

I want to convert a tab file created with MapInfo to an ESRI Shapefile (.shp) using ogr2ogr in command line. I did the following ogr2ogr -f 'ESRI Shapefile' "file.shp" "file.tab" but it gives an ...
nat's user avatar
  • 289
1 vote
0 answers
548 views

Convert a raster to a polygon with gdal in command line

I want to convert a raster (agric.tif) to a polygon layer (agric.shp). I want to use gdal in command line since the QGIS (raster to polygon) seems to takes for ever (still running over an hour). I am ...
nat's user avatar
  • 289
1 vote
1 answer
227 views

gdal_grid does not work in cron but works in terminal

I use the gdal_grid interpolation command. When I work in the terminal everything works perfectly. However, when I try to run the command in the bash script from cron then it does not work. Bash ...
kamfulebu's user avatar
  • 351
0 votes
1 answer
712 views

How to convert an ASCII file (with lat,lon coordinates) to a shapefile using OGR?

I have an ASCII file with the following columns : ID, longitude, latitude, value Is it possible to use OGR (ogr2ogr or ogrinfo) in command line in order to open the ASCII file and convert it to a ...
nat's user avatar
  • 289
0 votes
0 answers
489 views

Alter and update a shapefile with a field from an ASCII file using ogr

I have a vector file "map.shp" with a field ID. I have an attribute table (data.txt) with the following fields: ID, value1, value2. The field ID is the same in both files. I want to update map.shp by ...
Nat's user avatar
  • 219
2 votes
0 answers
103 views

Rasterio CLI warping multiple rasters like another raster in all minus one feature

I'm writing a bash script to warp all the rasters in a specific directory to match another raster. I'd like to warp all these rasters iteratively in to match the other raster in all was except shape ...
Hexadecimalism's user avatar
3 votes
1 answer
444 views

dbf to shp within BASH (ogr2ogr would be ideal)

I have a CSV with many points and attributes that I'm trying to convert into a shapefile but I'm having no luck. I have installed gdal-bin and can use my terminal environment to create a shapefile ...
Pictory's user avatar
  • 194
0 votes
1 answer
7k views

Merge different KMZ layers to a unique KMZ file, a bash script

I have different .kmz files, each one contains a .png and a .kml, let's say: a.kmz, b.kmz, c.kmz. I would like to use a bash script to obtain a unique .kmz file, let's say d.kmz, that contains all the ...
Luka's user avatar
  • 3
1 vote
0 answers
129 views

Linux (unix) bash, import multiple fgdb to PostGIS using find & ogr2ogr command

I have multiple file geodatabases in different folders and this is the command I made so far: find -path "*/V*/*.gdb" -o -path "*/W*/*.gdb" -o -path "*/R*/*.gdb" -o -path "*/WM*/*.gdb" | while read ...
Pil Kwon's user avatar
  • 1,040
0 votes
1 answer
204 views

gdalwarp for clipping images using multiple polygon in a bash shell for loop

C:\OSGeo4W64\bin\gdalwarp.exe -dstnodata 0 -q -cutline D:\hillsborough_Images_work\split_Polygon\120-140k\Hillborough_FINAL_140000_region_IGD_120570003d29ed0dc.shp -crop_to_cutline -dstalpha -tr 0....
Neeraj Singh's user avatar
0 votes
1 answer
80 views

Python 2.7, PgAdmin III & BASH 4.3.48: Error Invalid Provider when calling py script in bash script

I am working in Ubuntu 16.04 LTS This is my bash script; # Binarize raster for later polygon creation path=/home/rose/Desktop/test/DSM_BM24_2017_1000_4735.tif pathdir=$(echo $path | cut -d "/" -f 1,...
Rose's user avatar
  • 315
3 votes
1 answer
570 views

Pipe, redirect or stream to osmfilter from "standard in" (stdin)

So many tools support chaining, or piping in data from standard input. This can decrease times needed for disk writing and also better use the memory of a machine. Examples of chaining: GDAL - "...
philshem's user avatar
  • 195
2 votes
1 answer
74 views

Change column to row using awk inside of GRASS command [closed]

I have 2000+ raster files and counting their statistics. For now I am exporting all to Excel, but to work on it, I need better segregation. My output: Name1 1 123 2 243 3 455 Name2 1 432 3 655 ...
AngelaG's user avatar
  • 135
2 votes
3 answers
444 views

Loop using variable - r.mapcalc GRASS GIS

I am doing threshold classification of NDVI rasters. One equation looks like that: r.mapcalc 'prog_r43_n65=if(ndvi_r43_n65>=0.6,1,2)' Now I want to make a loop for more than 2000 rasters, so I ...
AngelaG's user avatar
  • 135
4 votes
2 answers
2k views

Calculate buffer / multi-ring buffer of geometry with GDAL / gdalUtils

I wonder if there is any way to calculate a buffer on a spatial data set with basic command line GDAL or the R interface gdalUtils. To specify the Q: I have a lot of points around the globe. For ...
loki's user avatar
  • 514
7 votes
2 answers
3k views

gdal_calc - How to calculate where raster A is not equal to raster B?

I have two binary rasters with values NaN and 254. I want to generate a new raster that consists of the pixels that have value NaN in raster A and 254 in raster B and vice versa - those should be 1, ...
bellackn's user avatar
  • 241