Compute distance in grid to find service area - python

I am trying to assess the potential of Python to calculate the service area of two points.
The idea is to create a map showing which terminal is more efficient in serving a given cell based in distance or cost or time (different map for each).
The image shows point A and point B as terminals, I am trying to calculate the service area (or influence area) for each of the terminals.
In the example on the right the domain is homogeneous, and in the example on the left we have rail (green) and waterway (yellow). The different transportation modes will change the cost and time to market of any shipment to/from A and B. Intermodal operations are possible when any of the modes intercept i.e. green to white, white to yellow, yellow to green, etc.
By service area I mean a given cell is closer/cheaper/faster to a A or to B. Once I have this information than I´d be able to create a service area map of A and B.
My question is if python is the right tool for this. As you might notice I am not familiar with programming and would appreciate any tips (tutorials, etc).
Please feel free to ask any questions back if the problem description is not clear.
Domain of the problem:

You can solve this problem in almost any programming language.
Python is a high-level programming language, meaning it takes care of things like memory management. This makes it somewhat slower but easier to learn as you have to write fewer lines of code to do what you want.
It is also versatile, well supported and established, making it a good candidate for a first language.
However, ultimately, the question is what you are going to do with it? For example, if you want to develop something for the web, then going with JavaScript is probably better.
Here a rough guide where different programming languages are used
Otherwise google "which programming language should I learn" to find any of millions of articles on this topic.

Related

Path detection and progress in the maze with live stereo3d image

I'm producing an ugv prototype. The goal is to perform the desired actions to the targets set within the maze. When I surf the Internet, the mere right to navigate in the labyrinth is usually made with a distance sensor. I want to consult more ideas than the question.
I want to navigate the labyrinth by analyzing the image from the 3d stereo camera. Is there a resource or successful method you can suggest for this? As a secondary problem, the car must start in front of the entrance of the labyrinth, see the entrance and go in, and then leave the labyrinth after it completes operations in the labyrinth.
I would be glad if you suggest a source for this problem. :)
The problem description is a bit vague, but i'll try to highlight some general ideas.
An useful assumption is that labyrinth is a 2D environment which you want to explore. You need to know, at every moment, which part of the map has been explored, which part of the map still needs exploring, and which part of the map is accessible in any way (in other words, where are the walls).
An easy initial data structure to help with this is a simple matrix, where each cell represents a square in the real world. Each cell can be then labelled according to its state, starting in an unexplored state. Then you start moving, and exploring. Based on the distances reported by the camera, you can estimate the state of each cell. The exploration can be guided by something such as A* or Q-learning.
Now, a rather subtle issue is that you will have to deal with uncertainty and noise. Sometimes you can ignore it, sometimes you don't. The finer the resolution you need, the bigger is the issue. A probabilistic framework is most likely the best solution.
There is an entire field of research of the so-called SLAM algorithms. SLAM stands for simultaneous localization and mapping. They build a map using some sort of input from various types of cameras or sensors, and they build a map. While building the map, they also solve the localization problem within the map. The algorithms are usually designed for 3d environments, and are more demanding than the simpler solution indicated above, but you can find ready to use implementations. For exploration, something like Q-learning still have to be used.

Programming approach to calculating Lowest/Highest Combined Surface(s)

Lowest/Highest Combined Surface(s)
I'm looking for a methodology (and/or preferably a software approach) to create what I'm calling the Lowest (or highest) combined surface for a set of polygons.
So if our input was these two polygons that partially overlap and definitely intersect
My Lowest Combined output would be these three polygons
Given a number of "surfaces" (3d polygons)
We've gone through a variety of approaches and the best solution we could come up with involved applying a point grid to each polygon and performing calculations to return the lowest sets of points at each grid location. The problem is that the original geometry is lost in this approach which doesn't give us a working solution.
Background
I'm looking at a variety of "surfaces" that can be represented by 3d faces (cad Speak) or polygons and usually are distributed in a shapefile (.shp). When there are two surfaces that interact I'm interested in taking either the lowest combined or highest combined surface. I'm able to do this in CAD by manually tracing out new polygons for the interaction zones - but once I get into more than a handful of surfaces this becomes too labor intensive.
The current Approach
My current approach which falls somewhere in the terrible category is to generate a point cloud from each surface on a 1m grid and then do a grid cell based comparison of the points.
I do this by using AutoCAD Civl 3D's surface Generation Tools to create a TIN from each polygon surface and then using its Surface. This is then exported to a 1m DEM file which I believe is a gridded output format.
Next each DEM file is brought into Global Mapper where I generate a single point at the center of each "elevation grid cell". Next this data is exported to a .csv file where each point contains a variety of attributes such as what the name of the surface this point came from and what its altitude is
Next once I have a set of CSV files I run them through a python script that will export the lowest point (and associated attributes) at each grid. I do everything in UTM because the UTM grid is based on meters and it makes everything easier.
Lastly we bring the point file back into global mapper - coloring each point by what surface it started from.
There a variety of issues with this approach - sometimes things don't line up perfectly and there is a variety of cleanup I have to do
Also the edges end up being jagged - as is the case because I've converted nice straight lines into a point cloud
Alternatively we came up with a similar approach in Arc GIS using the Surface Comparison tool, however it had similar limitations to what we ran into with my approach.
What I'm looking for is a way to do this automatically with a variable number of inputs. I'm willing to use just about any tool to have this done, as it seems like it shouldn't be too difficult a process
Software?
When I look at this problem from a programmers point of view it looks rather straight forward - but I'm at a total loss how to proceed. I'm assuming Stack Overflow is the correct stack exchange for this question - but if it should be somewhere else - I'm happy to move it to a different exchange.
I wasn't sure if something like Mathematica (which i have zero experience) with could handle this situation or whether there was some fancy 3d math library in python that could chop polygons up by how they interact and then give me the lowest for co-located polys.
In any case I'm willing to try anything out so please if you have an idea of what tools and/or libraries I can use to do this please share! I have to assume that there is SOMETHING out there that can handle this type of 3d geometric processing
Thanks
EDIT
Because the commenters seem confused I am not asking for code - I am asking for methodologies, libraries, support tools, or even software packages that can perform these operations. I plan to write software to do this, however, I am hoping I don't need to pull out my trig books and write all these operations by hand. I have to assume there is somebody out there that has dealt with something similar before.

Best approach to mapping interior point cloud with LIDAR

Recently started playing with and built a 3D LIDAR using an Arduino, 2 servos and a Garmin Lite 3 LIDAR. Stationary mapping works great, but now I would like to move into interior mapping with a handheld unit. With an exterior unit I would of course rely on GPS, but what is the best approach for obtaining a decent interior point cloud?
I could of course rely on additional sensors to "map" the movement of the unit—but I would assume that the result would not be that great—or, and this solution I personally would have a harder time implementing, plot points based off of the the change of existing plot (i.e. the unit identifies that it is moving away from a corner of the room).
Any tips, example, etc. would be appreciated. Cheers!
Indoor mobile mapping is often done with Simultaneous Localization And Mapping (SLAM). SLAM algorithms and their implementations is an area of active research; one project to check out is OpenSLAM. They provide source code that could be used to build your own SLAM solution, and their paper (pdf) includes more background and the results of some real-world tests.
In terms of additional hardware you will need, an Inertial Measurement Unit (IMU) provides information about the attitude and acceleration of your system. These are more-or-less a requirement for all mobile systems, whether in a GNSS-denied environment or not.
Good luck!

Rating control in Python

Does anyone know a useful implementation for a rating control in wxPython / Python ?
I want to have a functionality where user will rate a particular document as being relevant or not-relevant and I want to capture this in a star-based rating system.
Since, I have already done other GUI development in wxPython, it would be really helpful if someone points me how this can be done in Python .
I
Depending on the interpretation of "useful", there are definitely solutions in the standard library. They will provide you with a usable solution, but not with eye candy or a particularly nice user experience.
There's wx.Slider (example), which could easily be utilized. With a given scale the user can give a rating by dragging the slider towards the upper or lower bounds of a numeric scale.
Another solution is wx.RadioButton (example) representing a group of options of which only one can be selected at a time. This is a usable implementation for labelled options - e.g. select bad, medium or good rating for the document.
If you dislike the options given above, you would probably ending up implementing your own control. This might be a little challenging at first, but could get you the star rating often seen in web applications. You might want to head to wxPython custom control SO question. A quick search didn't provide me with any existing implementations.

Driving Distance Between GIS Points

I have a large number of GIS (latitude, longitude) coordinates, and I'd like to get the distance between them. Is there a service that will calculate the shortest path for me? I know about google maps, but I'd like something I can use from Python, and that can handle a large batch of requests at once.
I'm looking for the driving distance, so a straight distance won't do.
Thanks
So I take it based on your question and the answers posted that you are asking what program to use? If you can find a way to get a copy for free or cheap (like through work, school, etc) I'd recommend ArcGIS 9.x. It has its quirks, but it's highly supported by the user community and there are a lot of forums and help/training books available for it. Also, they have adopted Python as their official scripting language for the program (Sweeeet!).
Another option that is less expensive is GRASS. It's a free, open-source, well established, powerful and multiplatform GIS program. It might have a bit steeper learning-curve than ArcGIS, but I've heard very good things about it considering it's a free program.
This website lists info on free, open-source (FOS) GIS programs http://opensourcegis.org/ and could give you some good info on your other choices.
I couldn't tell if you were asking a question about how to measure the distance between two points and finding shortest travel distances in a GIS program or if you were just mentioning that's the kind of stuff you would need to do. Either way, ArcGIS is well suited for those tasks. Some of the tools in ArcGIS's ArcToolbox already have commands to help you find optimal transportation routes. This link lets you explore some of the tools available ArcToolbox Help. Most of the tools in ArcToolbox have a GUI batch processing option automatically included as well. Measuring point to point distances on an individual basis is easy in ArcGIS, and if you needed to measure a bunch of point to point pairs, you could write a quick Python script to easily do it for you.
I think I've answered all of your questions. Feel free to let me know if there is something I missed or that doesn't make sense. Hope this helps, buddy.
Check out OpenStreetMap. You can download their map data and have it lying around on your local system. http://wiki.openstreetmap.org/wiki/Routing discusses the various routing systems for their data.
You are aware that the traveling salesman problem is np-complete?
using Qgis:
Use the delimited text plugin to import the data
save the import as a shape file
Open the shape file
using the ftools plugin, calculate the matrix distance
If you have interconnections between the points you could use Dijkstra's algorithm for a 'shortest path from a single point' or Floyd's algorithm for an 'all pairs' shortest path computation.
Neither are particularly complicated, however they do assume you know the lengths of the roads between the points. You will need to have this data to compute a driving distance.

Categories

Resources