python geopandas: how can I identify linestrings that are uncontinuous? - python-3.x

There are some linestrings that are unconuous like this
enter image description here
How can I exclude them?
I've tried a few ways,but didn't work
enter image description here

solved!
this way:
len(line.boundary)==0

Related

PySide6: fail to load "jpg" format in QPixmap

I'm trying to load "jpg" picture on the QLabel in PySide6. So I used this:
mypic = QPixmap()
mypic.load("./test.jpg")
self.ui.mylabel.setPixmap(QPixmap(mypic))
However, I found there is empty in mylabel. When I debug in this program, I found that my pic is null (even after it loads the image file).
So I wonder if the jpg is not automatically supported in PySide6.
As I checked the documention of PySide6, it illustrates that the default supporting image formats include "jpg".
enter image description here
As I print the supportedImageFormats using:
print(QtGui.QImageReader.supportedImageFormats())
It returns with this:
[PySide6.QtCore.QByteArray(b'bmp'), PySide6.QtCore.QByteArray(b'pbm'), PySide6.QtCore.QByteArray(b'pgm'), PySide6.QtCore.QByteArray(b'png'), PySide6.QtCore.QByteArray(b'ppm'), PySide6.QtCore.QByteArray(b'xbm'), PySide6.QtCore.QByteArray(b'xpm')]
I found it does not include the "jpg" format by default!
Then I searched a lot of solutions, I found that this can solve my problem: add one line of code to introduce the "imageformats" plugins in PySide6 folder.
app.addLibraryPath(os.path.join(os.path.dirname(QtCore.__file__), "plugins"))
Here I printed the os.path.dirname(QtCore.__file__), and found it was my PySide6 folder.
I checked the plugins folder, and found the inner imageformats folder, and found these dlls:
enter image description here
It seems that the jpg format is supported here. So when I add the plugin path, it can solve my problem. But it still confuses me that why I should add the plugin path (The official documentation implies that this format is supported by default!).
I wonder if there is a more convincing solution because adding one line of code in my program every time seems clumsy. Or if I left out something. I sincerely want to get your help. Thank you!

How to add text annotation to existing PDF using pdf-annotate Python

I'm trying to use this Python library called pdf-annotate to add text annotation to existing PDF files. Here's the documentation of the library: https://github.com/plangrid/pdf-annotate
I got this sample code that add a square on the bottom left corner of the pdf file but couldn't figure out how to add free text instead of square. For example, I want to add a comment like "This document has been reviewed." instead of the square. This should be annotation on the existing pdf page instead of adding a new page to the pdf.
from pdf_annotate import PdfAnnotator, Appearance, Location
annotator = PdfAnnotator('sample.pdf')
annotator.add_annotation(
'square',
Location(x1=50, y1=50, x2=100, y2=100, page=0),
Appearance(fill=(1, 0, 0))
)
annotator.write('annotated.pdf')
I've been trying to review the source code in the documentation to figure out how to add text instead of square but couldn't figure it out. Does anyone know how to use this library to add text?
In my case the following worked:
annotator.add_annotation(
'text',
Location(x1=x_start, y1=y_start, x2=x_end, y2=y_end, page=0),
Appearance(content='Review...', font_size=10, fill=(0,0,0)),
)
But especially the "fill" argument is required. It gives the color of the text and must be specefied.

In Nodejs sharp package how to add two image into a single image?

I tried to combine two images into a single image using sharp package in NodeJS but i cant is there any ways to done this with sharp package
Use another module instead of sharp to append images to one another
https://www.npmjs.com/package/join-images
You can put an image in front to other with the next code:
sharp(pathToBaseImage)
.composite([{ input: bufferFrontImage }])
.sharpen()
.toBuffer()

i need help for solving this , im not able to understand the error

I'm getting this these days .but i'm not able to solve this while running a server
[enter image description here][1]
enter image description here
Somewhere in your code you've imported from django.contib, which is incorrect. It should be django.contrib (notice the missing r in contib).

Can't get to exif data .JPG image

I'm trying to read the exif data from a .JPG image. I've tried differents solutions found here and there (PIL, piexif, exifread...) and none of them worked for this set of images. It worked for other images taken from another camera but not for this one, all these different methods returning empty dictionaries. It seems that there is no exif data but (I apologies for my newbyness) when I RIGHT-click + properties (I use windows), I do see what is exif data to me : date of creation, etc...
Here is one image :
image.JPG
If another of the thousands of anonymous heroes could help me on this one, I would be very grateful...
Alright so I found a solution which I share now.
The problem is that the libraries that open metadata are not taking all possible configurations for the image file and therefore, they can handle some and some others they cannot. I finally made it using exiftool, an executable that I dowloaded on my windows on this link :
https://sno.phy.queensu.ca/~phil/exiftool/
Then I paste the executable in a folder and I add exiftool.py in that folder, that I got from :
https://github.com/smarnach/pyexiftool/find/master
Then, using this small piece of code (for example):
import exiftool
with exiftool.ExifTool("exiftool.exe") as et:
metadata = et.get_metadata_batch(files)
for d in metadata:
print("{:20.20} {:20.20}".format(d["SourceFile"],
d["File:FileCreateDate"]))
Of course, this is just to show that you indeed can access the metadata, then you can do whatever you want with that. Here is the documentation of the library exiftool : http://smarnach.github.io/pyexiftool/
Cheers, JM

Resources