QGIS Intersection is returning with an error - intersection

I am trying to run "Intersection" on two different shapefiles (Shape1, Shape2). The first one is with the purple colour and the second with the blue.
Previously I've run "Check validity", "Multiparts to singleparts" and "Simplify geometries" just to make things more easy.
When I run Intersection between the two shapefiles I get the message "GEOS geoprocessing error: One or more input features have invalid geometry".
Update: After doing "Validity Check" I didn't had any "Invalid Output" results, only "Valid outuput" even after changing the "Method" from GEOS to QGIS and "the one selected in digitizing settings", so I do not really figured out what is the problem.
I am new at this. Any ideas please?
The two different shapefiles
SHP1 adn SHP2 through Intersection
Error

Try using Saga GIS intersect tool in processing tools. If you have characters problems in output shape, change coding in layer properties

Related

yolov5, for a trained model, feed an image and get in return found classes with scores and bounding boxes as json

I trained my custom yolo dataset, now my requirement is to feed an image to the model and get back a json with founded classes with scores and bounding boxes.
When I run detect.py, it looks that there is no option to configure this script to my needs, and I can only get back an image with bounding box and score placed on it.
How did you solve this problem?
Did you took parts of detect.py and modified to your needs, or is there probably a solution to it?
I have found the answer to it.
Once you have your model, you need this script to make it work and send the answer to a calling program.
I had just some problems with the paths, but in the end figured it out.
If you think it can be better, please let me know:
import os
import torch
# Important: Path here is taken not from the folder where the script is positioned, but from the root project folder
model = torch.hub.load(os.getcwd()+'/yolov5','custom', path='./yolov5/runs/train/lemon3/weights/best.pt', source='local', force_reload=True)
results = model("./dataset/test/images/fridge2.jpg")
# cord_thres contains 4 corners of bounding box, 5th array parameter is confidence score
labels, cord_thres = results.xyxyn[0][:, -1].numpy(), results.xyxyn[0][:, :-1].numpy()
print(labels, cord_thres)

How to access text in UI element with JXA?

When you open a Terminal or iTerm window, you are shown a string like
Last login: Fri Jul 10 00:00:00 on ttys000
(base) my_username#my_hostname ~ %
I would like to be able to read this string into a variable in JXA.
This is how far I got until now.
1. Accessibility Inspector
With Accessibility Inspector I have discovered the hierarchy of UI elements which lead to the string I am looking for.
2. UI Browser
I have used UI Browser to navigate trough the hierarchy and obtain an Apple Script code to access the element; but I need JXA code.
3. Translating into code
In order to try to access the above UI hierarchy with JXA I have first enabled the Safari JavaScript debugger as explained here
and then I have written this code to invoke the debugger:
i_term = Application('iTerm')
i_term.quit()
i_term.activate()
delay(0.2)
debugger
Now, within the console of the debugger, I have tried to access the object by using the same variable naming shown in the first code snippet from this answer, that is
i_term.windows()[0].groups()[0].splitterGroups()[0].scrollAreas()[0]
At this point I have two problems:
I actually don't know if the object that I am trying accessing exists, because in the console I get uninformative output. I just know that i_term.windows()[0] is correct since if I type i_term.windows()[0].name() I get the string "zsh", which is the title of the window.
I don't know what's the name of the method/variable for the text UI element.
More generally, how I am describing in this other question (link coming in a edit I will soon make), I have tried printing in many ways the "content" of the variables I am working with, but I can't see the methods/values they contain. For instance: I would like to be able to see the list of methods/variables of i_term, in particular to know that it contains the method windows(), but I have found no way of getting this information. Being able to get this information would make possible to write the code much more easily, even with the current lack of documentation.
How can I obtain the string value of that text?
Why are you wanting to achieve your goal through UI scripting ? It's the most difficult kind of script to implement well, and the most likely to break.
I don't know whether you're aware, but the contents of a terminal window in both Terminal.app and iTerm.app can be retrieved through their AppleScript properties.
iTerm:
Application('com.googlecode.iterm2').windows[0].tabs[0].sessions[0].contents()
// OR: .currentWindow.currentSession.contents()
Terminal:
Application('com.apple.Terminal').windows[0].tabs[0].contents()
// OR: .windows[0].selectedTab.contents()
Side-bar:
To obtain an object reference—if one exists—to any given UI element on your screen, you need:
A definitive, unobstructed pixel belonging solely to the UI element in question, for which you can discern its (x, y) coordinates relative to the top-left of your screen. The "l" of "login" seems good:
Access privileges granted for Script Editor and System Events.
Then, when you run the command:
tell application id "com.apple.systemevents" to click at {x, y}
and, provided that the pixel you identified at coordinates (x, y) remains in view when the command executes, then the return value of the command will be the object reference to the UI element occupying the pixel at those coordinates.
If it returns missing value, the element isn't accessible.

Getting specific data from video surveillance web-interface in Zabbix

guys! I'm looking for a solution or some ideas on how to solve my task.
There is a video surveillance camera(vendor: Hikvision) with an accessible web-interface.
In the web-interface, there is a field Device Name containing data I need to retrieve by means of the Zabbix server and further to use this data for renaming discovered hosts.
Since Hikvision cameras support SNMP, I've tried the SNMP agent in Zabbix. I turned out that Hikvision MIB doesn't contain data from that field.
Also exploring web-interface through Developer tools in Google Chrome I stumbled upon the string Request URL: http://10.90.187.16/ISAPI/System/deviceInfo which gives such response in XML format:
<DeviceInfo xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<deviceName>1.5.1.1</deviceName>
<deviceID>566eec0b-6580-11b3-81a1-1868cb48861f</deviceID>
<deviceDescription>IPCamera</deviceDescription>
<deviceLocation>hangzhou</deviceLocation>
<systemContact>Hikvision.China</systemContact>
<model>DS-2CD2155FWD-IS</model>
<serialNumber>DS-2CD2155FWD-IS20170417AAWR749464587</serialNumber>
<macAddress>18:68:cb:48:86:1f</macAddress>
<firmwareVersion>V5.4.5</firmwareVersion>
<firmwareReleasedDate>build 170124</firmwareReleasedDate>
<encoderVersion>V7.3</encoderVersion>
<encoderReleasedDate>build 170123</encoderReleasedDate>
<bootVersion>V1.3.4</bootVersion>
<bootReleasedDate>100316</bootReleasedDate>
<hardwareVersion>0x0</hardwareVersion>
<deviceType>IPCamera</deviceType>
<telecontrolID>88</telecontrolID>
<supportBeep>false</supportBeep>
<supportVideoLoss>false</supportVideoLoss>
</DeviceInfo>
Where the tag <deviceName>1.5.1.1</deviceName> contains required data and now the question is how to put two and two together by means of Zabbix.
Digging into Zabbix documentation I've found an article about creating an Item based on HTTP agent with XML request . Unfortunately there are not any exmaples how to do it exactly.
Has somebody had such experience? Any clues will be helpful
You can create an HTTP Agent item, set it to TEXT type and point it to http://10.90.187.16/ISAPI/System/deviceInfo (don't forget the authentication, if required!), Zabbix will retrieve the full XML.
To get the desired value you have to create a dependent item, point it to the previous item and set up a preprocessing step.
Create a single XML Xpath preprocessing rule with parameter string(/DeviceInfo/DeviceName) to get the 1.5.1.1 value
If you want to get the firmware version, create another dependent item and set up the XPath to string(/DeviceInfo/FirmwareVersion) and so on for every element you need.
If you want a single value you can use a single item, adding the preprocessing rule to the http agent item. I use my solution for flexibility, maybe one day I'll need another XML element or maybe a firmware update will add some element to the page.
Dependent items are more flexible, but of course the full XML uses more storage in the database for stuff you don't need right now: it's a tradeoff, either way works!

How to use --attach-data-disks when creating new VM using Azure CLI2?

I'm trying to create a new VM using existing Managed disks and I keep running into problems because the parameters are not very well documented.
One problem that I haven't figured out is the format of --attach-data-disks
From the name and description of the parameter this seems to be the way you can attach data disks to the VM that you are creating and I am assuming because it is --attach-data-disks and not --attach-data-disk that you can attach multiple disks using this parameter.
What I don't know is what format to use when passing multiple disks. I have tried separating them using commas but the error that I got seemed to indicate that it viewed the comma delimited list of drives as one long name for a drive.
Here is an example of what I am trying to do:
az vm create -g test-group -n testvm2 --os-type windows --attach-os-disk testvm1-osdisk-20181213-033052 --attach-data-disks "testvm1-datadisk-000-20181213-033052,testvm1-datadisk-001-20181213-033052,testvm1-datadisk-002-20181213-033052"
Error I'm getting:
Deployment failed. Correlation ID: 9999. {
"error": {
"code": "InvalidParameter",
"message": "Id /subscriptions/99999999/resourceGroups/lbacompensafe/providers/Microsoft.Compute/disks/testvm1-datadisk-000-20181213-033052,testvm1-datadisk-001-20181213-033052,testvm1-datadisk-002-20181213-033052 is not a valid resource reference.",
"target": "dataDisk.managedDisk.id"
}
}
I'm running the commands from Powershell, not Bash, if that makes a difference.
Figured it out. It is in fact a space delimited list. I didn't try this sooner because I incorrectly assumeed it would need some sort of grouping or it would look like different parameters, but just listing them out like
--attach-data-disks disk1 disk2 disk3
Will add them in that order. Wish the docs would have just said so. Would have saved me a bunch of time.

Tilecache failing to generate tiles using Mapnik

I downloaded the Australian OSM extract and moved it into a database called gis using osm2pgsql.
I have changed generate_tiles.py to only generate tiles for Australia:
bbox = (-180.0,-90.0, 180.0,90.0)
render_tiles(bbox, mapfile, tile_dir, 0, 5, "World")
minZoom = 10
maxZoom = 16
bbox = (101.1,-6.9,165.5,-45.9)
render_tiles(bbox, mapfile, tile_dir, minZoom, maxZoom)
When I attempt to generate tiles with:
export MAPNIK_MAP_FILE="osm.xml" && export MAPNIK_TILE_DIR="/tmp/tilecache/" && ./z0generate_tiles.py
Lots of directories are created in /tmp/tilecache with png tiles. The tiles have state boundaries and country names and there does appear to be highways.
But.. when I navigate to the address:
http://localhost/osm/tilecache-2.11/index.html
I only see countries and states, but no labels and no streets. I figure it is probably a permissions issue with accessing the postgis data. I have gone into psql and issued:
GRANT ALL PRIVILEGES ON DATABASE gis TO PUBLIC
In /etc/tilecache.cfg I have:
[cache]
type=Disk
base=/tmp/tilecache
[osm]
type=Mapnik
mapfile=/home/(my user_name)/bin/mapnik/my_osm.xml
spherical_mercator=true
tms_type=google
metatile=yes
[basic]
type=WMS
url=http://labs.metacarta.com/wms/vmap0
extension=png
It would seem that mapnik is not able to communicate with postgis. I have logged into postgres and executed:
GRANT ALL PRIVILEGES ON DATABASE gis TO PUBLIC
I generated the my_osm.xml file with the following:
./generate_xml.py osm.xml my_osm.xml --dbname gis --user (uname) --password (pword) --accept-none
It generated without any errors.
That's about as far as I can take it. New files are being created when accessed via the web, they just don't have any road information.
Any ideas?
One comment:
generate_tiles.py and tilecache are different applications and don't know about each other. So, your tilecache config will only be read by the tilecache application. But, if tilecache is used with 'tms_type=google', like you have done, the cache schemes used by each
program should match.
Couple things to check on your missing roads:
Sometime problems with old geos libraries can lead to lacking data imported by osm2pgsql, so make sure there are a lot of rows in the plant_osm_line table:
select count(*) from planet_osm_line;
Also, make sure you are running the latest Mapnik version, at least 0.7.0, ideally 0.7.1.
Try rendering a few maps with nik2img.py and make sure mapnik does now output any warnings that might be causing this - a common issue can be missing proj4 epsg definitions for EPSG:900913