How to add culvert in DEM-Raster? - raster

Is it possible to edit a DEM raster? I want to insert or add a culvert/outlet like in the sketch. Any other solutions?
WIN10- QGIS Madeira 3.4.3-

Related

Adafruit MagTag: Dither a jpg from placekitten.com and display on MagTag

Pimoroni has an example that grabs a jpg online and displays it on one of their Inky e-ink displays.
I am wondering if it is possible to do the same thing with an Adafruit MagTag using CircuitPython. In the latest version of CircuitPython, there are BitmapTools that seem like they may be able to convert a .jpg file into a .bmp that is dithered appropriately for an e-ink display. There just doesn't seem to be any example code that shows how to do this.
Is it possible?
Any examples of using bitmaptools.dither(dest_bitmap: displayio.Bitmap, source_bitmapp: displayio.Bitmap, source_colorspace: displayio.Colorspace, algorithm: DitherAlgorithm = DitherAlgorithm.Atkinson)→ None
The code would look a little like this ...
import board
import displayio
import adafruit_imageload
display = board.DISPLAY
bitmap, palette = adafruit_imageload.load("/purple.bmp",
bitmap=displayio.Bitmap,
palette=displayio.Palette)
# Create a TileGrid to hold the bitmap
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
# Create a Group to hold the TileGrid
group = displayio.Group()
# Add the TileGrid to the Group
group.append(tile_grid)
# Add the Group to the Display
display.show(group)
# Loop forever so you can enjoy your image
while True:
pass
... but we would pull in a .jpg and have to do a little work on it so that the greyscale image becomes a dithered .bmp.
Any ideas?
I can pull in a .jpg. I just can't process it and display.
I was also looking for an API or something that might be able to pre-process the image from https://placekitten.com so that it would already be a dithered bitmap file. Does that exist?

Merging multiple orthophto tif to gpkg with gdalwrap - artefacts, transaprent background (nodata value)

I try to merging multiple orthophoto photos (tif format) into gpkg fromat for using in qfield app. I found some answer how to do this in R with package gdalUtils.
I used this part of code:
gdalwarp(of="GPKG",srcfile=l[1:50],dstfile="M:/qfield/merge.gpkg",co=c("TILE_FORMAT=PNG_JPEG","TILED=YES))
Process was succesfully finished but when I looked results I found some artefacts.
In a photo you see merged gpkg file with added layer of fishnet (tif lists) and artefacts. Artefacts looks like small parts of original list of tif which are reordered and probably also overlaped.
First I was thougth that there is some error in originall orthophoto tif. But then I created raster mosaic, raster catalog, merged tif to new tif dataset and I also published raster catalog to esri server and created tpk file from them and artefacts did not show. Is problem my code? Thank you
Edit:
I found solution for my problem. If I create vrt then artefacts do not show so i used this code:
gdalbuildvrt(gdalfile = ll, output.vrt = "C:/Users/..../dmk_2017_2019.vrt")
gdalwarp(of="GPKG",srcfile="C:/Users/..../dmk_2017_2019.vrt",
dstfile="C:/Users/..../dmk_2017_2019.gpkg")
gdaladdo(filename="C:/Users/..../dmk_2017_2019.gpkg",r="average",levels=c(2,4,8,16,32,64,128,256),verbose=TRUE)
I have another question. What to do to get transparent nodata value (background)?
I tried with - srcnodata=255 255 255 but this helped only that black background become white I tried also with argument dstalpha but without succes. In qgis its possible this with setting transparenty:

R select spatial polygon with point inside

I have a shapeFile and a spatialPointsDataframe ... I would like to select all polygon where there is point(s) inside, and merge points information in shp#data
word<-readOGR(dsn="data/world/ne_110m_admin_0_countries.shp", layer="ne_110m_admin_0_countries")
xy<-cbind(geoloc$longitude,geoloc$latitude)
spxy<-SpatialPoints(xy)
spdfxy<-SpatialPointsDataFrame(spxy,geoloc)
spdfxy#data<-merge(spdfxy#data,data2000geo)
tps<-!is.na(over(spdfxy,word)) ##retourne the indexe of atribut of y renvois les atribut de word
But after that I don't know how select polygones. i have tried
vitiWord<-word[tps]
but it's doesn't work
for download exemple -> link
I 'have find some thing...
I don't realy know if it work because I would like to use ggplot after and it doesn't work well, but whit
jointure<-over(word,spdfxy) #over from sp library
word#data<-cbind(word#data,jointure)
You have all variable from point in the spatialDataFrame !!

Creating Shapefiles in R

I'm trying to create a shapefile in R that I will later import to either Fusion Table or some other GIS application.
To start,I imported a blank shapefile containing all the census tracts in Canada. I have attached other data (in tabular format) to the shapefile based on the unique ID of the CTs, and I have mapped my results. At the moment, I only need the ones in Vancouver and I would like to export a shapefile that contains only the Vancouver CTs as well as my newly attached attribute data.
Here is my code (some parts omitted due to privacy reasons):
shape <- readShapePoly('C:/TEST/blank_ct.shp') #Load blank shapefile
shape#data = data.frame(shape#data, data2[match(shape#data$CTUID, data2$CTUID),]) #data2 is my created attributes that I'm attaching to blank file
shape1 <-shape[shape$CMAUID == 933,] #selecting the Vancouver CTs
I've seen other examples using this: writePolyShape to create the shapefile. I tried it, and it worked to an extent. It created the .shp, .dbf, and .shx files. I'm missing the .prj file and I'm not sure how to go about creating it. Are there better methods out there for creating shapefiles?
Any help on this matter would be greatly appreciated.
Use rgdal and writeOGR. rgdal will preserve the projection information
something like
library(rdgal)
shape <- readOGR(dsn = 'C:/TEST', layer = 'blank_ct')
# do your processing
shape#data = data.frame(shape#data, data2[match(shape#data$CTUID, data2$CTUID),]) #data2 is my created attributes that I'm attaching to blank file
shape1 <-shape[shape$CMAUID == 933,]
writeOGR(shape1, dsn = 'C:/TEST', layer ='newstuff', driver = 'ESRI Shapefile')
Note that the dsn is the folder containing the .shp file, and the layer is the name of the shapefile without the .shp extension. It will read (readOGR) and write (writeOGR) all the component files (.dbf, .shp, .prj etc)
Problem solved! Thank you again for those who help!
Here is what I ended up doing:
As Mnel wrote, this line will create the shapefile.
writeOGR(shape1, dsn = 'C:/TEST', layer ='newstuff', driver = 'ESRI Shapefile')
However, when I ran this line, it came back with this error:
Can't convert columns of class: AsIs; column names: ct2,mprop,mlot,mliv
This is because my attribute data was not numeric, but were characters. Luckily, my attribute data is all numbers so I ran transform() to fix this problem.
shape2 <-shape1
shape2#data <- transform(shape1#data, ct2 = as.numeric(ct2),
mprop = as.numeric(mprop),
mlot = as.numeric(mlot),
mliv = as.numeric(mliv))
I tried the writeOGR() command again, but I still didn't get the .prj file that I was looking for. The problem was I didn't specified the coordinate systems for the shapefile when I was importing the file. Since I already know what the coordinate system is, all I had to do was define it when importing.
readShapePoly('C:/TEST/blank_ct.shp',proj4string=CRS("+proj=longlat +datum=WGS84")
After that, I re-ran all the things I wanted to do with the shapefile, and the writeOGR line for exporting. And that's it!

R tcltk: title for a tkframe

I think this is a simple question but can't figure it out. I'm trying to build a frame and hoping I can add a title to it. For example, I like to create a slider in a frame. But to identify the frame I'd like to add a title to it. I have no reputation so I can't add a picture, but something like the word "title" below:
--- title --------------------------------
| ===[ ]=================== |
-----.-----------------------------------
Or:
How can I do it?
Look at the ttklabelframe function in the tcltk package.
There is a package called rpanel, where somehow the frames are all titled. You might want to look into that one.

Resources