OpenStreetMap logo OpenStreetMap

PhysicsArmature's Diary

Recent diary entries

Prompt: “I have OpenStreetMaps data. I am coding a GUI Program in Python with GTK. I want to create markers and areas on top of openstreetmaps data. What libraries will let me do that?”

Response: “To create markers and areas on top of OpenStreetMap data in a Python GUI program using GTK, you can use the following libraries:

  1. PyGObject: This library allows you to use GTK and its associated libraries in Python. It provides bindings for various GTK components, including maps.

  2. Gtk.Map: This is a GTK widget that can display maps using different map providers, including OpenStreetMap. You can create an instance of this widget and add it to your GTK application’s window.

  3. Gio.Resource: This library allows you to load resources, such as images or data files, into your GTK application. You can use it to load map markers or icons to display on the map.

  4. cairo: This is a 2D graphics library that can be used to draw on GTK widgets. You can use cairo to draw areas or polygons on top of the map widget to represent specific regions.

Here’s a basic example to get you started:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio

def create_marker(lat, lon, icon_path):
    marker = Gtk.Image.new_from_file(icon_path)
    # Set marker position on the map using lat/lon coordinates
    marker.set_property('latitude', lat)
    marker.set_property('longitude', lon)
    # Add the marker to the map widget
    map_widget.add_overlay(marker)

def draw_area(coordinates):
    map_widget.queue_draw()

    def draw_callback(widget, cr):
        cr.set_source_rgba(1, 0, 0, 0.5)  # Set fill color and opacity
        cr.set_line_width(2.0)  # Set line width
        cr.move_to(*coordinates[0])  # Move to the first coordinate

        # Draw lines between the coordinates to form a closed area
        for x, y in coordinates[1:]:
            cr.line_to(x, y)

        cr.close_path()  # Close the path
        cr.fill_preserve()  # Fill the area with the chosen color
        cr.set_source_rgb(0, 0, 0)  # Set stroke color
        cr.stroke()  # Draw the outline

    map_widget.connect('draw', draw_callback)

# Create the GTK window
window = Gtk.Window()
window.connect('destroy', Gtk.main_quit)

# Create the map widget and add it to the window
map_widget = Gtk.Map()
window.add(map_widget)

# Load the icon file for the marker
icon_path = 'path/to/marker.png'
Gio.Resource.load(icon_path)

# Example marker and area coordinates
marker_coordinates = (latitude, longitude)
area_coordinates = [(x1, y1), (x2, y2), (x3, y3)]

# Create a marker and draw an area on the map
create_marker(*marker_coordinates, icon_path)
draw_area(area_coordinates)

# Show the window and start the GTK main loop
window.show_all()
Gtk.main()

Remember to replace ‘path/to/marker.png’ with the actual path to your marker icon file. You can adjust the coordinates to place the marker and draw the desired area on the map.”

Note: hashtag sign literal replaced with # to avoid formatting problems.

Location: Shiprock Agency, Apache County, Arizona, United States

Volunteer Oprotunity: AI Transcription generation for OpenStreetMapsUS

Posted by PhysicsArmature on 22 March 2023 in English. Last updated on 2 May 2023.

Goal:

  1. Find a video on the OpenStreetMaps YouTube channel.
  2. Download the audio of a talk.
  3. Run it through OpenAI’s Whisper.
  4. Send the transcript and the source URL to somebody in the OSM Community who has ownership over the OSM YouTube channel.

While you may be able to automate this, I don’t know how to do so.

What you need:

  1. GPU (possibly NVIDIA, don’t know). 5gb vram (gpu ram). This might mean RTX 2060 or newer.
  2. Strong cooling and noise isolation through building design.

Costs

  1. Electricity will create some cost as transcription is hard. Do note that it is still less then the amount needed to power on and train a normal human being on the same task for several years in addition to the quantity of humans needed to get the same throughput.
  2. This will result in wear and tare on your drives and other components.
  3. This will make your computer and room warm in the summer. You need great cooling or the ability to use the excess heat for something valuable.

Steps:

  1. Install Itch.io to assist updating.
  2. Install whisper gui frontend by Grisk with Itch.
  3. Download audio from a talk (not saying how).
  4. Plug it in and get the result.
  5. Send the URL of the talk and the transcript to unknownPerson who runs the OSM YouTube Channel in a standard format.

Sample format for an email

Hello noun, This email is to submit a transcript.

talk: https://www.youtube.com/watch?v=nsaiHhQvNSY model: whisper medium

Disclaimers:

  1. I have yet to coordinate with anyone.
  2. Human transcript writers are great and needed. They are in short supply. Let us reduce the net demand. They can save their energy for high impact legal and medical environments.
  3. Maybe the built in YouTube transcript does the job well enough. This might not be worth the effort. I don’t know.
Location: Bloomington, Hennepin County, Minnesota, United States

Problem: Map a large volume of something that has distinct color.

Solution » High Level: * Highlight a sample square * Send a wanderer around in a perimeter * When the barrier is crossed, stop * Have the end user review

Solution » Low Level [LONG]: public main { //Describe sample square Let the user draw a square //Use sample square int minR, maxR, minB, maxB, minG, maxG; set all the mins to max value and all the max values to 0

for(every pixel in the square)
{
	does it need to be change one of the above 6 ints?
}

//Explore
while(endCondition not triggered)
{
	walk around the perimieter and send it to addSquare()
	if the addSquare says add it, send it to approvedSpots[][]
	else
	{
		ignore it
		but in future versions subdivide the square into 4 areas recursivley to minSizeOfArea;
	}
}

//Encase the area
Find our approved area and go to the top most point from the center.
Drop a point down
Go through the area, if 2 points are on the same line and not necessary, delete it. }

bool addSquare(all 6 rgb values, satteliteArea[][]) { //Filter out the blatantly false average out satteliteAreaRGB if satteliteArea violates the 6 rgb areas, return false.

//Check the square
for all the pixels, how many don't belong
percentDontBelong=numberDontBelong/howmany are in the satteliteArea
    Send it }

Concerns you might have: 1. Automation in OSM? The human has to: Define the sample and approve the result. 2. Junk Data: This would be a problem with a userbase, not a computational problem. We merely create tools. 3. What about non-90 degree angles? I agree that this would be a problem, I would hope someone made a tool that acts like the blender sculpt brush of smooth and bump, but for OSM.

Production: 1. Someone might have made this sort of thing already and I just don’t know about it? If not in JOSM, than in something that costs money. 2. I know that describing a solution is easy and that I did not do the hard part such as the following. How to draw a sample area and convert the pixels into an array, than how to convert the result back.

Edit: My solution (that someone has probably already though of) for non-grid areas is the pin and line model.

Solution » High Level We walk out to the North-most pixel that is compliant with our initial model. We use our string to go around in a circle as far as we can. If alot of errors occur, we place a new pin down where we left off. Repeat the process until we are back to our start.

Location: Shelby County, Iowa, United States

Areial Mapping, beat the trees

Posted by PhysicsArmature on 8 December 2020 in English.

2 example locations: Old houses near downtown big cities. These houses have trees that grow very tall due to the time the trees have been around. It makes it harder to see the secondary buildings like garages and sheds. Sometimes it becomes harder to see the primary building of the house due to trees, or the shadows of these trees.

Big new suburb at the edge of the urban crawl. The land was stripped to the grass. The houses have been placed down. Now the satellites goes by and takes images. It is easy to see the outline of the house.

We are in a race against the trees when we map houses using Aerial Data.

Bash Scripting & mapwith.ai

Posted by PhysicsArmature on 27 April 2020 in English. Last updated on 4 January 2022.

Problem:

I need to slap down one set of 50 houses. I want to click as few things as possible. Script 1 is about this task. Script 2 is about finding the coordinates of things on your screen.

Notice: Eliminate [] before the pound sign, I needed to differentiate kramdown and BASH code. Notice 2: I have this weird spacing, otherwise journal system tries to turn a script into a paragraph.

SCRIPT 1

[]#!/bin/bash

[]#pull up script

sleep 4

[]#0.1 is to fast

for i in {1..49}

do

echo -e $i

[]#Find a house and click on it yourself

[]#Go to xy of use this feature xxxyyy

sleep 1.8

xdotool mousemove 35 243 click 1 &

[]#Go to xy of change this feature

sleep 0.3

xdotool mousemove 53 211 click 1 &

[]#Go to xy of option 1 house

sleep 0.3

xdotool mousemove 51 276 click 1 &

done

echo DONE

SCRIPT 2

[]#!/bin/bash

[]#pull up script

sleep 5

for i in {1..200}

do

xdotool getmouselocation –shell

eval $(xdotool getmouselocation –shell)

echo $X $Y

sleep 5

done

Works used:

https://stackoverflow.com/questions/8480073/how-would-i-get-the-current-mouse-coordinates-in-bash https://askubuntu.com/questions/179581/how-can-i-make-my-mouse-auto-click-every-5-seconds

Potential future targets for when I have time (Not for 2 weeks):

  • Another for loop for several sets of 50.
  • Search for the color pink on the screen and click it. Ask [Y/n] on the command prompt, then mark it.
  • Custom input that asks for pauses.
Location: Saint Cloud, Stearns County, Minnesota, United States

Tracing OSM Users

Posted by PhysicsArmature on 23 March 2020 in English.

I have realized people map what is important to them in higher quantities than other things. Thus you find the areas they have mapped over the areas they don’t map. People map the areas the know more about than the areas they don’t, thus looking at edit clusters can show where people live. Finally the tag local knowledge as a source shows where someone has been. Combining these all together can be used to track people down.

X Axis: Resolution. Y Axis: When the image was taken. Our notion of technology: Perfect arrow going up at y=x. I was mapping this park area. I looked at 5 different Satellites. The highest quality Satellite Imagery did not show a sidewalk that a the rest of the low resolution maps showed. I had two thoughts: 1. They ripped out a perfectly good map (Nope). 2. The low quality imagery is more recent.